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> 301da177e4SLinus Torvalds #include <linux/smp_lock.h> 3162239ac2SAdrian Bunk #include <linux/fs.h> 321da177e4SLinus Torvalds #include <linux/init.h> 331da177e4SLinus Torvalds #include <linux/kernel.h> 340296b228SKay Sievers #include <linux/kobject.h> 3520380731SArnaldo Carvalho de Melo #include <linux/net.h> 361da177e4SLinus Torvalds #include <linux/sysrq.h> 371da177e4SLinus Torvalds #include <linux/highuid.h> 381da177e4SLinus Torvalds #include <linux/writeback.h> 391da177e4SLinus Torvalds #include <linux/hugetlb.h> 401da177e4SLinus Torvalds #include <linux/initrd.h> 410b77f5bfSDavid Howells #include <linux/key.h> 421da177e4SLinus Torvalds #include <linux/times.h> 431da177e4SLinus Torvalds #include <linux/limits.h> 441da177e4SLinus Torvalds #include <linux/dcache.h> 451da177e4SLinus Torvalds #include <linux/syscalls.h> 46c748e134SAdrian Bunk #include <linux/vmstat.h> 47c255d844SPavel Machek #include <linux/nfs_fs.h> 48c255d844SPavel Machek #include <linux/acpi.h> 4910a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 50b0fc494fSSteven Rostedt #include <linux/ftrace.h> 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds #include <asm/uaccess.h> 531da177e4SLinus Torvalds #include <asm/processor.h> 541da177e4SLinus Torvalds 5529cbc78bSAndi Kleen #ifdef CONFIG_X86 5629cbc78bSAndi Kleen #include <asm/nmi.h> 570741f4d2SChuck Ebbert #include <asm/stacktrace.h> 586e7c4025SIngo Molnar #include <asm/io.h> 5929cbc78bSAndi Kleen #endif 6029cbc78bSAndi Kleen 617058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args); 627058cb02SEric W. Biederman 631da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds /* External variables not in a header file. */ 661da177e4SLinus Torvalds extern int C_A_D; 6745807a1dSIngo Molnar extern int print_fatal_signals; 681da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 691da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 70fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom; 71fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task; 72fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks; 731da177e4SLinus Torvalds extern int max_threads; 741da177e4SLinus Torvalds extern int core_uses_pid; 75d6e71144SAlan Cox extern int suid_dumpable; 761da177e4SLinus Torvalds extern char core_pattern[]; 771da177e4SLinus Torvalds extern int pid_max; 781da177e4SLinus Torvalds extern int min_free_kbytes; 791da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 809d0243bcSAndrew Morton extern int sysctl_drop_caches; 818ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 82bebfa101SAndi Kleen extern int compat_log; 835096add8SKees Cook extern int maps_protect; 849745512cSArjan van de Ven extern int latencytop_enabled; 85eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 8631a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 8731a72bceSPaul E. McKenney extern int rcutorture_runnable; 8831a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 891da177e4SLinus Torvalds 90c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 911c4cd6ddSIngo Molnar #if defined(CONFIG_HIGHMEM) || defined(CONFIG_DETECT_SOFTLOCKUP) 92c4f3b63fSRavikiran G Thirumalai static int one = 1; 93195cf453SBron Gondwana #endif 94195cf453SBron Gondwana 95195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 96c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 979383d967SDimitri Sivanich static int neg_one = -1; 98c4f3b63fSRavikiran G Thirumalai #endif 99c4f3b63fSRavikiran G Thirumalai 100c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_MMU 101c4f3b63fSRavikiran G Thirumalai static int two = 2; 102c4f3b63fSRavikiran G Thirumalai #endif 103c4f3b63fSRavikiran G Thirumalai 104c4f3b63fSRavikiran G Thirumalai static int zero; 105c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 106c4f3b63fSRavikiran G Thirumalai 1071da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1081da177e4SLinus Torvalds static int maxolduid = 65535; 1091da177e4SLinus Torvalds static int minolduid; 1108ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1111da177e4SLinus Torvalds 1121da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1131da177e4SLinus Torvalds 114a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 1151da177e4SLinus Torvalds extern char modprobe_path[]; 1161da177e4SLinus Torvalds #endif 1171da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 1181da177e4SLinus Torvalds extern int sg_big_buff; 1191da177e4SLinus Torvalds #endif 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds #ifdef __sparc__ 1221da177e4SLinus Torvalds extern char reboot_command []; 1231da177e4SLinus Torvalds extern int stop_a_enabled; 1241da177e4SLinus Torvalds extern int scons_pwroff; 1251da177e4SLinus Torvalds #endif 1261da177e4SLinus Torvalds 1271da177e4SLinus Torvalds #ifdef __hppa__ 1281da177e4SLinus Torvalds extern int pwrsw_enabled; 1291da177e4SLinus Torvalds extern int unaligned_enabled; 1301da177e4SLinus Torvalds #endif 1311da177e4SLinus Torvalds 132347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1331da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1341da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1351da177e4SLinus Torvalds #endif 1361da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 137951f22d5SMartin Schwidefsky extern int spin_retry; 1381da177e4SLinus Torvalds #endif 1391da177e4SLinus Torvalds 1401da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1411da177e4SLinus Torvalds extern int acct_parm[]; 1421da177e4SLinus Torvalds #endif 1431da177e4SLinus Torvalds 144d2b176edSJes Sorensen #ifdef CONFIG_IA64 145d2b176edSJes Sorensen extern int no_unaligned_warning; 146d2b176edSJes Sorensen #endif 147d2b176edSJes Sorensen 14823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 14923f78d4aSIngo Molnar extern int max_lock_depth; 15023f78d4aSIngo Molnar #endif 15123f78d4aSIngo Molnar 152d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 153d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 1549ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 155d8217f07SEric W. Biederman static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, 15634f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 157d6f8ff73SRandy Dunlap #endif 1589ec52099SCedric Le Goater 159d8217f07SEric W. Biederman static struct ctl_table root_table[]; 160e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 161e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 162e51b6ba0SEric W. Biederman .ctl_table = root_table, 16373455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 164e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 16573455092SAl Viro .set = &sysctl_table_root.default_set, 166e51b6ba0SEric W. Biederman }; 167e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 168e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 16973455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 170e51b6ba0SEric W. Biederman }; 1711da177e4SLinus Torvalds 172d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 173d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 174d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 175d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 176d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 177d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1782d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 179d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1800399cb08SRobert Love #endif 1811da177e4SLinus Torvalds 1821da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 1831da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1841da177e4SLinus Torvalds #endif 1851da177e4SLinus Torvalds 186f20786ffSPeter Zijlstra extern int prove_locking; 187f20786ffSPeter Zijlstra extern int lock_stat; 1889bc9a6bdSEric W. Biederman 1891da177e4SLinus Torvalds /* The default sysctl tables: */ 1901da177e4SLinus Torvalds 191d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 1921da177e4SLinus Torvalds { 1931da177e4SLinus Torvalds .ctl_name = CTL_KERN, 1941da177e4SLinus Torvalds .procname = "kernel", 1951da177e4SLinus Torvalds .mode = 0555, 1961da177e4SLinus Torvalds .child = kern_table, 1971da177e4SLinus Torvalds }, 1981da177e4SLinus Torvalds { 1991da177e4SLinus Torvalds .ctl_name = CTL_VM, 2001da177e4SLinus Torvalds .procname = "vm", 2011da177e4SLinus Torvalds .mode = 0555, 2021da177e4SLinus Torvalds .child = vm_table, 2031da177e4SLinus Torvalds }, 2041da177e4SLinus Torvalds { 2051da177e4SLinus Torvalds .ctl_name = CTL_FS, 2061da177e4SLinus Torvalds .procname = "fs", 2071da177e4SLinus Torvalds .mode = 0555, 2081da177e4SLinus Torvalds .child = fs_table, 2091da177e4SLinus Torvalds }, 2101da177e4SLinus Torvalds { 2111da177e4SLinus Torvalds .ctl_name = CTL_DEBUG, 2121da177e4SLinus Torvalds .procname = "debug", 2131da177e4SLinus Torvalds .mode = 0555, 2141da177e4SLinus Torvalds .child = debug_table, 2151da177e4SLinus Torvalds }, 2161da177e4SLinus Torvalds { 2171da177e4SLinus Torvalds .ctl_name = CTL_DEV, 2181da177e4SLinus Torvalds .procname = "dev", 2191da177e4SLinus Torvalds .mode = 0555, 2201da177e4SLinus Torvalds .child = dev_table, 2211da177e4SLinus Torvalds }, 2222be7fe07SAndrew Morton /* 2232be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2242be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2252be7fe07SAndrew Morton */ 2261da177e4SLinus Torvalds { .ctl_name = 0 } 2271da177e4SLinus Torvalds }; 2281da177e4SLinus Torvalds 22977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 23073c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 23173c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 23273c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 23373c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 23477e54a1fSIngo Molnar #endif 23577e54a1fSIngo Molnar 236d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 23777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 23877e54a1fSIngo Molnar { 23977e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 240b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 241b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 24277e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 24377e54a1fSIngo Molnar .mode = 0644, 244b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 245b2be5e96SPeter Zijlstra .strategy = &sysctl_intvec, 246b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 247b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 24877e54a1fSIngo Molnar }, 24977e54a1fSIngo Molnar { 25077e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 25121805085SPeter Zijlstra .procname = "sched_latency_ns", 25221805085SPeter Zijlstra .data = &sysctl_sched_latency, 25321805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 25421805085SPeter Zijlstra .mode = 0644, 255b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 25621805085SPeter Zijlstra .strategy = &sysctl_intvec, 25721805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 25821805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 25921805085SPeter Zijlstra }, 26021805085SPeter Zijlstra { 26121805085SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 26277e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 26377e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 26477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 26577e54a1fSIngo Molnar .mode = 0644, 26677e54a1fSIngo Molnar .proc_handler = &proc_dointvec_minmax, 26777e54a1fSIngo Molnar .strategy = &sysctl_intvec, 26877e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 26977e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 27077e54a1fSIngo Molnar }, 27177e54a1fSIngo Molnar { 27277e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 2732398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 2742398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 2752398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 2762398f2c6SPeter Zijlstra .mode = 0644, 2772398f2c6SPeter Zijlstra .proc_handler = &proc_dointvec, 2782398f2c6SPeter Zijlstra }, 2792398f2c6SPeter Zijlstra { 2802398f2c6SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 28177e54a1fSIngo Molnar .procname = "sched_child_runs_first", 28277e54a1fSIngo Molnar .data = &sysctl_sched_child_runs_first, 28377e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28477e54a1fSIngo Molnar .mode = 0644, 28577e54a1fSIngo Molnar .proc_handler = &proc_dointvec, 28677e54a1fSIngo Molnar }, 2871fc84aaaSPeter Zijlstra { 2881fc84aaaSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 2891fc84aaaSPeter Zijlstra .procname = "sched_features", 2901fc84aaaSPeter Zijlstra .data = &sysctl_sched_features, 2911fc84aaaSPeter Zijlstra .maxlen = sizeof(unsigned int), 2921fc84aaaSPeter Zijlstra .mode = 0644, 2931fc84aaaSPeter Zijlstra .proc_handler = &proc_dointvec, 2941fc84aaaSPeter Zijlstra }, 295da84d961SIngo Molnar { 296da84d961SIngo Molnar .ctl_name = CTL_UNNUMBERED, 297da84d961SIngo Molnar .procname = "sched_migration_cost", 298da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 299da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 300da84d961SIngo Molnar .mode = 0644, 301da84d961SIngo Molnar .proc_handler = &proc_dointvec, 302da84d961SIngo Molnar }, 303b82d9fddSPeter Zijlstra { 304b82d9fddSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 305b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 306b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 307b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 308fa85ae24SPeter Zijlstra .mode = 0644, 309fa85ae24SPeter Zijlstra .proc_handler = &proc_dointvec, 310fa85ae24SPeter Zijlstra }, 3111fc84aaaSPeter Zijlstra #endif 3121799e35dSIngo Molnar { 3131799e35dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 3149f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3159f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3169f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3179f0c1e56SPeter Zijlstra .mode = 0644, 318d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3199f0c1e56SPeter Zijlstra }, 3209f0c1e56SPeter Zijlstra { 3219f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3229f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3239f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3249f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3259f0c1e56SPeter Zijlstra .mode = 0644, 326d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3279f0c1e56SPeter Zijlstra }, 3289f0c1e56SPeter Zijlstra { 3299f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3301799e35dSIngo Molnar .procname = "sched_compat_yield", 3311799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3321799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3331799e35dSIngo Molnar .mode = 0644, 3341799e35dSIngo Molnar .proc_handler = &proc_dointvec, 3351799e35dSIngo Molnar }, 336f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 337f20786ffSPeter Zijlstra { 338f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 339f20786ffSPeter Zijlstra .procname = "prove_locking", 340f20786ffSPeter Zijlstra .data = &prove_locking, 341f20786ffSPeter Zijlstra .maxlen = sizeof(int), 342f20786ffSPeter Zijlstra .mode = 0644, 343f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 344f20786ffSPeter Zijlstra }, 345f20786ffSPeter Zijlstra #endif 346f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 347f20786ffSPeter Zijlstra { 348f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 349f20786ffSPeter Zijlstra .procname = "lock_stat", 350f20786ffSPeter Zijlstra .data = &lock_stat, 351f20786ffSPeter Zijlstra .maxlen = sizeof(int), 352f20786ffSPeter Zijlstra .mode = 0644, 353f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 354f20786ffSPeter Zijlstra }, 355f20786ffSPeter Zijlstra #endif 35677e54a1fSIngo Molnar { 3571da177e4SLinus Torvalds .ctl_name = KERN_PANIC, 3581da177e4SLinus Torvalds .procname = "panic", 3591da177e4SLinus Torvalds .data = &panic_timeout, 3601da177e4SLinus Torvalds .maxlen = sizeof(int), 3611da177e4SLinus Torvalds .mode = 0644, 3621da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3631da177e4SLinus Torvalds }, 3641da177e4SLinus Torvalds { 3651da177e4SLinus Torvalds .ctl_name = KERN_CORE_USES_PID, 3661da177e4SLinus Torvalds .procname = "core_uses_pid", 3671da177e4SLinus Torvalds .data = &core_uses_pid, 3681da177e4SLinus Torvalds .maxlen = sizeof(int), 3691da177e4SLinus Torvalds .mode = 0644, 3701da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3711da177e4SLinus Torvalds }, 3721da177e4SLinus Torvalds { 3731da177e4SLinus Torvalds .ctl_name = KERN_CORE_PATTERN, 3741da177e4SLinus Torvalds .procname = "core_pattern", 3751da177e4SLinus Torvalds .data = core_pattern, 37671ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 3771da177e4SLinus Torvalds .mode = 0644, 3781da177e4SLinus Torvalds .proc_handler = &proc_dostring, 3791da177e4SLinus Torvalds .strategy = &sysctl_string, 3801da177e4SLinus Torvalds }, 38134f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 3821da177e4SLinus Torvalds { 3831da177e4SLinus Torvalds .procname = "tainted", 3841da177e4SLinus Torvalds .data = &tainted, 3851da177e4SLinus Torvalds .maxlen = sizeof(int), 38634f5a398STheodore Ts'o .mode = 0644, 38734f5a398STheodore Ts'o .proc_handler = &proc_dointvec_taint, 3881da177e4SLinus Torvalds }, 38934f5a398STheodore Ts'o #endif 3909745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 3919745512cSArjan van de Ven { 3929745512cSArjan van de Ven .procname = "latencytop", 3939745512cSArjan van de Ven .data = &latencytop_enabled, 3949745512cSArjan van de Ven .maxlen = sizeof(int), 3959745512cSArjan van de Ven .mode = 0644, 3969745512cSArjan van de Ven .proc_handler = &proc_dointvec, 3979745512cSArjan van de Ven }, 3989745512cSArjan van de Ven #endif 3991da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4001da177e4SLinus Torvalds { 4011da177e4SLinus Torvalds .ctl_name = KERN_REALROOTDEV, 4021da177e4SLinus Torvalds .procname = "real-root-dev", 4031da177e4SLinus Torvalds .data = &real_root_dev, 4041da177e4SLinus Torvalds .maxlen = sizeof(int), 4051da177e4SLinus Torvalds .mode = 0644, 4061da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4071da177e4SLinus Torvalds }, 4081da177e4SLinus Torvalds #endif 40945807a1dSIngo Molnar { 41045807a1dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 41145807a1dSIngo Molnar .procname = "print-fatal-signals", 41245807a1dSIngo Molnar .data = &print_fatal_signals, 41345807a1dSIngo Molnar .maxlen = sizeof(int), 41445807a1dSIngo Molnar .mode = 0644, 41545807a1dSIngo Molnar .proc_handler = &proc_dointvec, 41645807a1dSIngo Molnar }, 4171da177e4SLinus Torvalds #ifdef __sparc__ 4181da177e4SLinus Torvalds { 4191da177e4SLinus Torvalds .ctl_name = KERN_SPARC_REBOOT, 4201da177e4SLinus Torvalds .procname = "reboot-cmd", 4211da177e4SLinus Torvalds .data = reboot_command, 4221da177e4SLinus Torvalds .maxlen = 256, 4231da177e4SLinus Torvalds .mode = 0644, 4241da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4251da177e4SLinus Torvalds .strategy = &sysctl_string, 4261da177e4SLinus Torvalds }, 4271da177e4SLinus Torvalds { 4281da177e4SLinus Torvalds .ctl_name = KERN_SPARC_STOP_A, 4291da177e4SLinus Torvalds .procname = "stop-a", 4301da177e4SLinus Torvalds .data = &stop_a_enabled, 4311da177e4SLinus Torvalds .maxlen = sizeof (int), 4321da177e4SLinus Torvalds .mode = 0644, 4331da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4341da177e4SLinus Torvalds }, 4351da177e4SLinus Torvalds { 4361da177e4SLinus Torvalds .ctl_name = KERN_SPARC_SCONS_PWROFF, 4371da177e4SLinus Torvalds .procname = "scons-poweroff", 4381da177e4SLinus Torvalds .data = &scons_pwroff, 4391da177e4SLinus Torvalds .maxlen = sizeof (int), 4401da177e4SLinus Torvalds .mode = 0644, 4411da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4421da177e4SLinus Torvalds }, 4431da177e4SLinus Torvalds #endif 4441da177e4SLinus Torvalds #ifdef __hppa__ 4451da177e4SLinus Torvalds { 4461da177e4SLinus Torvalds .ctl_name = KERN_HPPA_PWRSW, 4471da177e4SLinus Torvalds .procname = "soft-power", 4481da177e4SLinus Torvalds .data = &pwrsw_enabled, 4491da177e4SLinus Torvalds .maxlen = sizeof (int), 4501da177e4SLinus Torvalds .mode = 0644, 4511da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4521da177e4SLinus Torvalds }, 4531da177e4SLinus Torvalds { 4541da177e4SLinus Torvalds .ctl_name = KERN_HPPA_UNALIGNED, 4551da177e4SLinus Torvalds .procname = "unaligned-trap", 4561da177e4SLinus Torvalds .data = &unaligned_enabled, 4571da177e4SLinus Torvalds .maxlen = sizeof (int), 4581da177e4SLinus Torvalds .mode = 0644, 4591da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4601da177e4SLinus Torvalds }, 4611da177e4SLinus Torvalds #endif 4621da177e4SLinus Torvalds { 4631da177e4SLinus Torvalds .ctl_name = KERN_CTLALTDEL, 4641da177e4SLinus Torvalds .procname = "ctrl-alt-del", 4651da177e4SLinus Torvalds .data = &C_A_D, 4661da177e4SLinus Torvalds .maxlen = sizeof(int), 4671da177e4SLinus Torvalds .mode = 0644, 4681da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4691da177e4SLinus Torvalds }, 470b0fc494fSSteven Rostedt #ifdef CONFIG_FTRACE 471b0fc494fSSteven Rostedt { 472b0fc494fSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 473b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 474b0fc494fSSteven Rostedt .data = &ftrace_enabled, 475b0fc494fSSteven Rostedt .maxlen = sizeof(int), 476b0fc494fSSteven Rostedt .mode = 0644, 477b0fc494fSSteven Rostedt .proc_handler = &ftrace_enable_sysctl, 478b0fc494fSSteven Rostedt }, 479b0fc494fSSteven Rostedt #endif 480a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 4811da177e4SLinus Torvalds { 4821da177e4SLinus Torvalds .ctl_name = KERN_MODPROBE, 4831da177e4SLinus Torvalds .procname = "modprobe", 4841da177e4SLinus Torvalds .data = &modprobe_path, 4851da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 4861da177e4SLinus Torvalds .mode = 0644, 4871da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4881da177e4SLinus Torvalds .strategy = &sysctl_string, 4891da177e4SLinus Torvalds }, 4901da177e4SLinus Torvalds #endif 49157ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 4921da177e4SLinus Torvalds { 4931da177e4SLinus Torvalds .ctl_name = KERN_HOTPLUG, 4941da177e4SLinus Torvalds .procname = "hotplug", 495312c004dSKay Sievers .data = &uevent_helper, 496312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 4971da177e4SLinus Torvalds .mode = 0644, 4981da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4991da177e4SLinus Torvalds .strategy = &sysctl_string, 5001da177e4SLinus Torvalds }, 5011da177e4SLinus Torvalds #endif 5021da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5031da177e4SLinus Torvalds { 5041da177e4SLinus Torvalds .ctl_name = KERN_SG_BIG_BUFF, 5051da177e4SLinus Torvalds .procname = "sg-big-buff", 5061da177e4SLinus Torvalds .data = &sg_big_buff, 5071da177e4SLinus Torvalds .maxlen = sizeof (int), 5081da177e4SLinus Torvalds .mode = 0444, 5091da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5101da177e4SLinus Torvalds }, 5111da177e4SLinus Torvalds #endif 5121da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5131da177e4SLinus Torvalds { 5141da177e4SLinus Torvalds .ctl_name = KERN_ACCT, 5151da177e4SLinus Torvalds .procname = "acct", 5161da177e4SLinus Torvalds .data = &acct_parm, 5171da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5181da177e4SLinus Torvalds .mode = 0644, 5191da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5201da177e4SLinus Torvalds }, 5211da177e4SLinus Torvalds #endif 5221da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5231da177e4SLinus Torvalds { 5241da177e4SLinus Torvalds .ctl_name = KERN_SYSRQ, 5251da177e4SLinus Torvalds .procname = "sysrq", 5265d6f647fSIngo Molnar .data = &__sysrq_enabled, 5271da177e4SLinus Torvalds .maxlen = sizeof (int), 5281da177e4SLinus Torvalds .mode = 0644, 5291da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5301da177e4SLinus Torvalds }, 5311da177e4SLinus Torvalds #endif 532d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5331da177e4SLinus Torvalds { 5341da177e4SLinus Torvalds .procname = "cad_pid", 5359ec52099SCedric Le Goater .data = NULL, 5361da177e4SLinus Torvalds .maxlen = sizeof (int), 5371da177e4SLinus Torvalds .mode = 0600, 5389ec52099SCedric Le Goater .proc_handler = &proc_do_cad_pid, 5391da177e4SLinus Torvalds }, 540d6f8ff73SRandy Dunlap #endif 5411da177e4SLinus Torvalds { 5421da177e4SLinus Torvalds .ctl_name = KERN_MAX_THREADS, 5431da177e4SLinus Torvalds .procname = "threads-max", 5441da177e4SLinus Torvalds .data = &max_threads, 5451da177e4SLinus Torvalds .maxlen = sizeof(int), 5461da177e4SLinus Torvalds .mode = 0644, 5471da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5481da177e4SLinus Torvalds }, 5491da177e4SLinus Torvalds { 5501da177e4SLinus Torvalds .ctl_name = KERN_RANDOM, 5511da177e4SLinus Torvalds .procname = "random", 5521da177e4SLinus Torvalds .mode = 0555, 5531da177e4SLinus Torvalds .child = random_table, 5541da177e4SLinus Torvalds }, 5551da177e4SLinus Torvalds { 5561da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWUID, 5571da177e4SLinus Torvalds .procname = "overflowuid", 5581da177e4SLinus Torvalds .data = &overflowuid, 5591da177e4SLinus Torvalds .maxlen = sizeof(int), 5601da177e4SLinus Torvalds .mode = 0644, 5611da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 5621da177e4SLinus Torvalds .strategy = &sysctl_intvec, 5631da177e4SLinus Torvalds .extra1 = &minolduid, 5641da177e4SLinus Torvalds .extra2 = &maxolduid, 5651da177e4SLinus Torvalds }, 5661da177e4SLinus Torvalds { 5671da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWGID, 5681da177e4SLinus Torvalds .procname = "overflowgid", 5691da177e4SLinus Torvalds .data = &overflowgid, 5701da177e4SLinus Torvalds .maxlen = sizeof(int), 5711da177e4SLinus Torvalds .mode = 0644, 5721da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 5731da177e4SLinus Torvalds .strategy = &sysctl_intvec, 5741da177e4SLinus Torvalds .extra1 = &minolduid, 5751da177e4SLinus Torvalds .extra2 = &maxolduid, 5761da177e4SLinus Torvalds }, 577347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 5781da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 5791da177e4SLinus Torvalds { 5801da177e4SLinus Torvalds .ctl_name = KERN_IEEE_EMULATION_WARNINGS, 5811da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 5821da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 5831da177e4SLinus Torvalds .maxlen = sizeof(int), 5841da177e4SLinus Torvalds .mode = 0644, 5851da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5861da177e4SLinus Torvalds }, 5871da177e4SLinus Torvalds #endif 5881da177e4SLinus Torvalds { 5891da177e4SLinus Torvalds .ctl_name = KERN_S390_USER_DEBUG_LOGGING, 5901da177e4SLinus Torvalds .procname = "userprocess_debug", 5911da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 5921da177e4SLinus Torvalds .maxlen = sizeof(int), 5931da177e4SLinus Torvalds .mode = 0644, 5941da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5951da177e4SLinus Torvalds }, 5961da177e4SLinus Torvalds #endif 5971da177e4SLinus Torvalds { 5981da177e4SLinus Torvalds .ctl_name = KERN_PIDMAX, 5991da177e4SLinus Torvalds .procname = "pid_max", 6001da177e4SLinus Torvalds .data = &pid_max, 6011da177e4SLinus Torvalds .maxlen = sizeof (int), 6021da177e4SLinus Torvalds .mode = 0644, 6031da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6041da177e4SLinus Torvalds .strategy = sysctl_intvec, 6051da177e4SLinus Torvalds .extra1 = &pid_max_min, 6061da177e4SLinus Torvalds .extra2 = &pid_max_max, 6071da177e4SLinus Torvalds }, 6081da177e4SLinus Torvalds { 6091da177e4SLinus Torvalds .ctl_name = KERN_PANIC_ON_OOPS, 6101da177e4SLinus Torvalds .procname = "panic_on_oops", 6111da177e4SLinus Torvalds .data = &panic_on_oops, 6121da177e4SLinus Torvalds .maxlen = sizeof(int), 6131da177e4SLinus Torvalds .mode = 0644, 6141da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6151da177e4SLinus Torvalds }, 6167ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6177ef3d2fdSJoe Perches { 6187ef3d2fdSJoe Perches .ctl_name = KERN_PRINTK, 6197ef3d2fdSJoe Perches .procname = "printk", 6207ef3d2fdSJoe Perches .data = &console_loglevel, 6217ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6227ef3d2fdSJoe Perches .mode = 0644, 6237ef3d2fdSJoe Perches .proc_handler = &proc_dointvec, 6247ef3d2fdSJoe Perches }, 6251da177e4SLinus Torvalds { 6261da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT, 6271da177e4SLinus Torvalds .procname = "printk_ratelimit", 628717115e1SDave Young .data = &printk_ratelimit_state.interval, 6291da177e4SLinus Torvalds .maxlen = sizeof(int), 6301da177e4SLinus Torvalds .mode = 0644, 6311da177e4SLinus Torvalds .proc_handler = &proc_dointvec_jiffies, 6321da177e4SLinus Torvalds .strategy = &sysctl_jiffies, 6331da177e4SLinus Torvalds }, 6341da177e4SLinus Torvalds { 6351da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT_BURST, 6361da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 637717115e1SDave Young .data = &printk_ratelimit_state.burst, 6381da177e4SLinus Torvalds .maxlen = sizeof(int), 6391da177e4SLinus Torvalds .mode = 0644, 6401da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6411da177e4SLinus Torvalds }, 6427ef3d2fdSJoe Perches #endif 6431da177e4SLinus Torvalds { 6441da177e4SLinus Torvalds .ctl_name = KERN_NGROUPS_MAX, 6451da177e4SLinus Torvalds .procname = "ngroups_max", 6461da177e4SLinus Torvalds .data = &ngroups_max, 6471da177e4SLinus Torvalds .maxlen = sizeof (int), 6481da177e4SLinus Torvalds .mode = 0444, 6491da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6501da177e4SLinus Torvalds }, 6511da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 6521da177e4SLinus Torvalds { 6531da177e4SLinus Torvalds .ctl_name = KERN_UNKNOWN_NMI_PANIC, 6541da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 6551da177e4SLinus Torvalds .data = &unknown_nmi_panic, 6561da177e4SLinus Torvalds .maxlen = sizeof (int), 6571da177e4SLinus Torvalds .mode = 0644, 6582fbe7b25SDon Zickus .proc_handler = &proc_dointvec, 6591da177e4SLinus Torvalds }, 660407984f1SDon Zickus { 661407984f1SDon Zickus .procname = "nmi_watchdog", 662407984f1SDon Zickus .data = &nmi_watchdog_enabled, 663407984f1SDon Zickus .maxlen = sizeof (int), 664407984f1SDon Zickus .mode = 0644, 665407984f1SDon Zickus .proc_handler = &proc_nmi_enabled, 6661da177e4SLinus Torvalds }, 6671da177e4SLinus Torvalds #endif 6681da177e4SLinus Torvalds #if defined(CONFIG_X86) 6691da177e4SLinus Torvalds { 6708da5addaSDon Zickus .ctl_name = KERN_PANIC_ON_NMI, 6718da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 6728da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 6738da5addaSDon Zickus .maxlen = sizeof(int), 6748da5addaSDon Zickus .mode = 0644, 6758da5addaSDon Zickus .proc_handler = &proc_dointvec, 6768da5addaSDon Zickus }, 6778da5addaSDon Zickus { 6781da177e4SLinus Torvalds .ctl_name = KERN_BOOTLOADER_TYPE, 6791da177e4SLinus Torvalds .procname = "bootloader_type", 6801da177e4SLinus Torvalds .data = &bootloader_type, 6811da177e4SLinus Torvalds .maxlen = sizeof (int), 6821da177e4SLinus Torvalds .mode = 0444, 6831da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6841da177e4SLinus Torvalds }, 6850741f4d2SChuck Ebbert { 6860741f4d2SChuck Ebbert .ctl_name = CTL_UNNUMBERED, 6870741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 6880741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 6890741f4d2SChuck Ebbert .maxlen = sizeof(int), 6900741f4d2SChuck Ebbert .mode = 0644, 6910741f4d2SChuck Ebbert .proc_handler = &proc_dointvec, 6920741f4d2SChuck Ebbert }, 6936e7c4025SIngo Molnar { 6946e7c4025SIngo Molnar .ctl_name = CTL_UNNUMBERED, 6956e7c4025SIngo Molnar .procname = "io_delay_type", 6966e7c4025SIngo Molnar .data = &io_delay_type, 6976e7c4025SIngo Molnar .maxlen = sizeof(int), 6986e7c4025SIngo Molnar .mode = 0644, 6996e7c4025SIngo Molnar .proc_handler = &proc_dointvec, 7006e7c4025SIngo Molnar }, 7011da177e4SLinus Torvalds #endif 7027a9166e3SLuke Yang #if defined(CONFIG_MMU) 7031da177e4SLinus Torvalds { 7041da177e4SLinus Torvalds .ctl_name = KERN_RANDOMIZE, 7051da177e4SLinus Torvalds .procname = "randomize_va_space", 7061da177e4SLinus Torvalds .data = &randomize_va_space, 7071da177e4SLinus Torvalds .maxlen = sizeof(int), 7081da177e4SLinus Torvalds .mode = 0644, 7091da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7101da177e4SLinus Torvalds }, 7117a9166e3SLuke Yang #endif 7120152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 713951f22d5SMartin Schwidefsky { 714951f22d5SMartin Schwidefsky .ctl_name = KERN_SPIN_RETRY, 715951f22d5SMartin Schwidefsky .procname = "spin_retry", 716951f22d5SMartin Schwidefsky .data = &spin_retry, 717951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 718951f22d5SMartin Schwidefsky .mode = 0644, 719951f22d5SMartin Schwidefsky .proc_handler = &proc_dointvec, 720951f22d5SMartin Schwidefsky }, 721951f22d5SMartin Schwidefsky #endif 722673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 723c255d844SPavel Machek { 724c255d844SPavel Machek .procname = "acpi_video_flags", 72577afcf78SPavel Machek .data = &acpi_realmode_flags, 726c255d844SPavel Machek .maxlen = sizeof (unsigned long), 727c255d844SPavel Machek .mode = 0644, 7287f99f06fSStefan Seyfried .proc_handler = &proc_doulongvec_minmax, 729c255d844SPavel Machek }, 730c255d844SPavel Machek #endif 731d2b176edSJes Sorensen #ifdef CONFIG_IA64 732d2b176edSJes Sorensen { 733d2b176edSJes Sorensen .ctl_name = KERN_IA64_UNALIGNED, 734d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 735d2b176edSJes Sorensen .data = &no_unaligned_warning, 736d2b176edSJes Sorensen .maxlen = sizeof (int), 737d2b176edSJes Sorensen .mode = 0644, 738d2b176edSJes Sorensen .proc_handler = &proc_dointvec, 739d2b176edSJes Sorensen }, 740d2b176edSJes Sorensen #endif 741c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 742c4f3b63fSRavikiran G Thirumalai { 743c4f3b63fSRavikiran G Thirumalai .ctl_name = CTL_UNNUMBERED, 7449c44bc03SIngo Molnar .procname = "softlockup_panic", 7459c44bc03SIngo Molnar .data = &softlockup_panic, 7469c44bc03SIngo Molnar .maxlen = sizeof(int), 7479c44bc03SIngo Molnar .mode = 0644, 7484dca10a9SHiroshi Shimamoto .proc_handler = &proc_dointvec_minmax, 7499c44bc03SIngo Molnar .strategy = &sysctl_intvec, 7509c44bc03SIngo Molnar .extra1 = &zero, 7519c44bc03SIngo Molnar .extra2 = &one, 7529c44bc03SIngo Molnar }, 7539c44bc03SIngo Molnar { 7549c44bc03SIngo Molnar .ctl_name = CTL_UNNUMBERED, 755c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 756c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 7579383d967SDimitri Sivanich .maxlen = sizeof(int), 758c4f3b63fSRavikiran G Thirumalai .mode = 0644, 7599383d967SDimitri Sivanich .proc_handler = &proc_dointvec_minmax, 760c4f3b63fSRavikiran G Thirumalai .strategy = &sysctl_intvec, 7619383d967SDimitri Sivanich .extra1 = &neg_one, 762c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 763c4f3b63fSRavikiran G Thirumalai }, 76482a1fcb9SIngo Molnar { 76582a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 76682a1fcb9SIngo Molnar .procname = "hung_task_check_count", 76782a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 76890739081SIngo Molnar .maxlen = sizeof(unsigned long), 76982a1fcb9SIngo Molnar .mode = 0644, 77090739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 77182a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 77282a1fcb9SIngo Molnar }, 77382a1fcb9SIngo Molnar { 77482a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 77582a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 77682a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 77790739081SIngo Molnar .maxlen = sizeof(unsigned long), 77882a1fcb9SIngo Molnar .mode = 0644, 77990739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 78082a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 78182a1fcb9SIngo Molnar }, 78282a1fcb9SIngo Molnar { 78382a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 78482a1fcb9SIngo Molnar .procname = "hung_task_warnings", 78582a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 78690739081SIngo Molnar .maxlen = sizeof(unsigned long), 78782a1fcb9SIngo Molnar .mode = 0644, 78890739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 78982a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 79082a1fcb9SIngo Molnar }, 791c4f3b63fSRavikiran G Thirumalai #endif 792bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 793bebfa101SAndi Kleen { 794bebfa101SAndi Kleen .ctl_name = KERN_COMPAT_LOG, 795bebfa101SAndi Kleen .procname = "compat-log", 796bebfa101SAndi Kleen .data = &compat_log, 797bebfa101SAndi Kleen .maxlen = sizeof (int), 798bebfa101SAndi Kleen .mode = 0644, 799bebfa101SAndi Kleen .proc_handler = &proc_dointvec, 800bebfa101SAndi Kleen }, 801bebfa101SAndi Kleen #endif 80223f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 80323f78d4aSIngo Molnar { 80423f78d4aSIngo Molnar .ctl_name = KERN_MAX_LOCK_DEPTH, 80523f78d4aSIngo Molnar .procname = "max_lock_depth", 80623f78d4aSIngo Molnar .data = &max_lock_depth, 80723f78d4aSIngo Molnar .maxlen = sizeof(int), 80823f78d4aSIngo Molnar .mode = 0644, 80923f78d4aSIngo Molnar .proc_handler = &proc_dointvec, 81023f78d4aSIngo Molnar }, 81123f78d4aSIngo Molnar #endif 8125096add8SKees Cook #ifdef CONFIG_PROC_FS 8135096add8SKees Cook { 8145096add8SKees Cook .ctl_name = CTL_UNNUMBERED, 8155096add8SKees Cook .procname = "maps_protect", 8165096add8SKees Cook .data = &maps_protect, 8175096add8SKees Cook .maxlen = sizeof(int), 8185096add8SKees Cook .mode = 0644, 8195096add8SKees Cook .proc_handler = &proc_dointvec, 8205096add8SKees Cook }, 8215096add8SKees Cook #endif 82210a0a8d4SJeremy Fitzhardinge { 82310a0a8d4SJeremy Fitzhardinge .ctl_name = CTL_UNNUMBERED, 82410a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 82510a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 82610a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 82710a0a8d4SJeremy Fitzhardinge .mode = 0644, 82810a0a8d4SJeremy Fitzhardinge .proc_handler = &proc_dostring, 82910a0a8d4SJeremy Fitzhardinge .strategy = &sysctl_string, 83010a0a8d4SJeremy Fitzhardinge }, 8310b77f5bfSDavid Howells #ifdef CONFIG_KEYS 8320b77f5bfSDavid Howells { 8330b77f5bfSDavid Howells .ctl_name = CTL_UNNUMBERED, 8340b77f5bfSDavid Howells .procname = "keys", 8350b77f5bfSDavid Howells .mode = 0555, 8360b77f5bfSDavid Howells .child = key_sysctls, 8370b77f5bfSDavid Howells }, 8380b77f5bfSDavid Howells #endif 83931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 84031a72bceSPaul E. McKenney { 84131a72bceSPaul E. McKenney .ctl_name = CTL_UNNUMBERED, 84231a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 84331a72bceSPaul E. McKenney .data = &rcutorture_runnable, 84431a72bceSPaul E. McKenney .maxlen = sizeof(int), 84531a72bceSPaul E. McKenney .mode = 0644, 84631a72bceSPaul E. McKenney .proc_handler = &proc_dointvec, 84731a72bceSPaul E. McKenney }, 84831a72bceSPaul E. McKenney #endif 849ed2c12f3SAndrew Morton /* 850ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 851ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 852ed2c12f3SAndrew Morton */ 8531da177e4SLinus Torvalds { .ctl_name = 0 } 8541da177e4SLinus Torvalds }; 8551da177e4SLinus Torvalds 856d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 8571da177e4SLinus Torvalds { 8581da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_MEMORY, 8591da177e4SLinus Torvalds .procname = "overcommit_memory", 8601da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 8611da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 8621da177e4SLinus Torvalds .mode = 0644, 8631da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8641da177e4SLinus Torvalds }, 8651da177e4SLinus Torvalds { 866fadd8fbdSKAMEZAWA Hiroyuki .ctl_name = VM_PANIC_ON_OOM, 867fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 868fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 869fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 870fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 871fadd8fbdSKAMEZAWA Hiroyuki .proc_handler = &proc_dointvec, 872fadd8fbdSKAMEZAWA Hiroyuki }, 873fadd8fbdSKAMEZAWA Hiroyuki { 874fe071d7eSDavid Rientjes .ctl_name = CTL_UNNUMBERED, 875fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 876fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 877fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 878fe071d7eSDavid Rientjes .mode = 0644, 879fe071d7eSDavid Rientjes .proc_handler = &proc_dointvec, 880fe071d7eSDavid Rientjes }, 881fe071d7eSDavid Rientjes { 882fef1bdd6SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 883fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 884fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 885fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 886fef1bdd6SDavid Rientjes .mode = 0644, 887fef1bdd6SDavid Rientjes .proc_handler = &proc_dointvec, 888fef1bdd6SDavid Rientjes }, 889fef1bdd6SDavid Rientjes { 8901da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_RATIO, 8911da177e4SLinus Torvalds .procname = "overcommit_ratio", 8921da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 8931da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 8941da177e4SLinus Torvalds .mode = 0644, 8951da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8961da177e4SLinus Torvalds }, 8971da177e4SLinus Torvalds { 8981da177e4SLinus Torvalds .ctl_name = VM_PAGE_CLUSTER, 8991da177e4SLinus Torvalds .procname = "page-cluster", 9001da177e4SLinus Torvalds .data = &page_cluster, 9011da177e4SLinus Torvalds .maxlen = sizeof(int), 9021da177e4SLinus Torvalds .mode = 0644, 9031da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9041da177e4SLinus Torvalds }, 9051da177e4SLinus Torvalds { 9061da177e4SLinus Torvalds .ctl_name = VM_DIRTY_BACKGROUND, 9071da177e4SLinus Torvalds .procname = "dirty_background_ratio", 9081da177e4SLinus Torvalds .data = &dirty_background_ratio, 9091da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 9101da177e4SLinus Torvalds .mode = 0644, 9111da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 9121da177e4SLinus Torvalds .strategy = &sysctl_intvec, 9131da177e4SLinus Torvalds .extra1 = &zero, 9141da177e4SLinus Torvalds .extra2 = &one_hundred, 9151da177e4SLinus Torvalds }, 9161da177e4SLinus Torvalds { 9171da177e4SLinus Torvalds .ctl_name = VM_DIRTY_RATIO, 9181da177e4SLinus Torvalds .procname = "dirty_ratio", 9191da177e4SLinus Torvalds .data = &vm_dirty_ratio, 9201da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 9211da177e4SLinus Torvalds .mode = 0644, 92204fbfdc1SPeter Zijlstra .proc_handler = &dirty_ratio_handler, 9231da177e4SLinus Torvalds .strategy = &sysctl_intvec, 9241da177e4SLinus Torvalds .extra1 = &zero, 9251da177e4SLinus Torvalds .extra2 = &one_hundred, 9261da177e4SLinus Torvalds }, 9271da177e4SLinus Torvalds { 9281da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 929f6ef9438SBart Samwel .data = &dirty_writeback_interval, 930f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 9311da177e4SLinus Torvalds .mode = 0644, 9321da177e4SLinus Torvalds .proc_handler = &dirty_writeback_centisecs_handler, 9331da177e4SLinus Torvalds }, 9341da177e4SLinus Torvalds { 9351da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 936f6ef9438SBart Samwel .data = &dirty_expire_interval, 937f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 9381da177e4SLinus Torvalds .mode = 0644, 939f6ef9438SBart Samwel .proc_handler = &proc_dointvec_userhz_jiffies, 9401da177e4SLinus Torvalds }, 9411da177e4SLinus Torvalds { 9421da177e4SLinus Torvalds .ctl_name = VM_NR_PDFLUSH_THREADS, 9431da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 9441da177e4SLinus Torvalds .data = &nr_pdflush_threads, 9451da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 9461da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 9471da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9481da177e4SLinus Torvalds }, 9491da177e4SLinus Torvalds { 9501da177e4SLinus Torvalds .ctl_name = VM_SWAPPINESS, 9511da177e4SLinus Torvalds .procname = "swappiness", 9521da177e4SLinus Torvalds .data = &vm_swappiness, 9531da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 9541da177e4SLinus Torvalds .mode = 0644, 9551da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 9561da177e4SLinus Torvalds .strategy = &sysctl_intvec, 9571da177e4SLinus Torvalds .extra1 = &zero, 9581da177e4SLinus Torvalds .extra2 = &one_hundred, 9591da177e4SLinus Torvalds }, 9601da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 9611da177e4SLinus Torvalds { 9621da177e4SLinus Torvalds .procname = "nr_hugepages", 963e5ff2159SAndi Kleen .data = NULL, 9641da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 9651da177e4SLinus Torvalds .mode = 0644, 9661da177e4SLinus Torvalds .proc_handler = &hugetlb_sysctl_handler, 9671da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 9681da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 9691da177e4SLinus Torvalds }, 9701da177e4SLinus Torvalds { 9711da177e4SLinus Torvalds .ctl_name = VM_HUGETLB_GROUP, 9721da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 9731da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 9741da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 9751da177e4SLinus Torvalds .mode = 0644, 9761da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9771da177e4SLinus Torvalds }, 978396faf03SMel Gorman { 979396faf03SMel Gorman .ctl_name = CTL_UNNUMBERED, 980396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 981396faf03SMel Gorman .data = &hugepages_treat_as_movable, 982396faf03SMel Gorman .maxlen = sizeof(int), 983396faf03SMel Gorman .mode = 0644, 984396faf03SMel Gorman .proc_handler = &hugetlb_treat_movable_handler, 985396faf03SMel Gorman }, 98654f9f80dSAdam Litke { 98754f9f80dSAdam Litke .ctl_name = CTL_UNNUMBERED, 988d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 989e5ff2159SAndi Kleen .data = NULL, 990e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 991d1c3fb1fSNishanth Aravamudan .mode = 0644, 992a3d0c6aaSNishanth Aravamudan .proc_handler = &hugetlb_overcommit_handler, 993e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 994e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 995d1c3fb1fSNishanth Aravamudan }, 9961da177e4SLinus Torvalds #endif 9971da177e4SLinus Torvalds { 9981da177e4SLinus Torvalds .ctl_name = VM_LOWMEM_RESERVE_RATIO, 9991da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 10001da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 10011da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 10021da177e4SLinus Torvalds .mode = 0644, 10031da177e4SLinus Torvalds .proc_handler = &lowmem_reserve_ratio_sysctl_handler, 10041da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10051da177e4SLinus Torvalds }, 10061da177e4SLinus Torvalds { 10079d0243bcSAndrew Morton .ctl_name = VM_DROP_PAGECACHE, 10089d0243bcSAndrew Morton .procname = "drop_caches", 10099d0243bcSAndrew Morton .data = &sysctl_drop_caches, 10109d0243bcSAndrew Morton .maxlen = sizeof(int), 10119d0243bcSAndrew Morton .mode = 0644, 10129d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 10139d0243bcSAndrew Morton .strategy = &sysctl_intvec, 10149d0243bcSAndrew Morton }, 10159d0243bcSAndrew Morton { 10161da177e4SLinus Torvalds .ctl_name = VM_MIN_FREE_KBYTES, 10171da177e4SLinus Torvalds .procname = "min_free_kbytes", 10181da177e4SLinus Torvalds .data = &min_free_kbytes, 10191da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 10201da177e4SLinus Torvalds .mode = 0644, 10211da177e4SLinus Torvalds .proc_handler = &min_free_kbytes_sysctl_handler, 10221da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10231da177e4SLinus Torvalds .extra1 = &zero, 10241da177e4SLinus Torvalds }, 10258ad4b1fbSRohit Seth { 10268ad4b1fbSRohit Seth .ctl_name = VM_PERCPU_PAGELIST_FRACTION, 10278ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 10288ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 10298ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 10308ad4b1fbSRohit Seth .mode = 0644, 10318ad4b1fbSRohit Seth .proc_handler = &percpu_pagelist_fraction_sysctl_handler, 10328ad4b1fbSRohit Seth .strategy = &sysctl_intvec, 10338ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 10348ad4b1fbSRohit Seth }, 10351da177e4SLinus Torvalds #ifdef CONFIG_MMU 10361da177e4SLinus Torvalds { 10371da177e4SLinus Torvalds .ctl_name = VM_MAX_MAP_COUNT, 10381da177e4SLinus Torvalds .procname = "max_map_count", 10391da177e4SLinus Torvalds .data = &sysctl_max_map_count, 10401da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 10411da177e4SLinus Torvalds .mode = 0644, 10421da177e4SLinus Torvalds .proc_handler = &proc_dointvec 10431da177e4SLinus Torvalds }, 10441da177e4SLinus Torvalds #endif 10451da177e4SLinus Torvalds { 10461da177e4SLinus Torvalds .ctl_name = VM_LAPTOP_MODE, 10471da177e4SLinus Torvalds .procname = "laptop_mode", 10481da177e4SLinus Torvalds .data = &laptop_mode, 10491da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 10501da177e4SLinus Torvalds .mode = 0644, 1051ed5b43f1SBart Samwel .proc_handler = &proc_dointvec_jiffies, 1052ed5b43f1SBart Samwel .strategy = &sysctl_jiffies, 10531da177e4SLinus Torvalds }, 10541da177e4SLinus Torvalds { 10551da177e4SLinus Torvalds .ctl_name = VM_BLOCK_DUMP, 10561da177e4SLinus Torvalds .procname = "block_dump", 10571da177e4SLinus Torvalds .data = &block_dump, 10581da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 10591da177e4SLinus Torvalds .mode = 0644, 10601da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10611da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10621da177e4SLinus Torvalds .extra1 = &zero, 10631da177e4SLinus Torvalds }, 10641da177e4SLinus Torvalds { 10651da177e4SLinus Torvalds .ctl_name = VM_VFS_CACHE_PRESSURE, 10661da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 10671da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 10681da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 10691da177e4SLinus Torvalds .mode = 0644, 10701da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10711da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10721da177e4SLinus Torvalds .extra1 = &zero, 10731da177e4SLinus Torvalds }, 10741da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 10751da177e4SLinus Torvalds { 10761da177e4SLinus Torvalds .ctl_name = VM_LEGACY_VA_LAYOUT, 10771da177e4SLinus Torvalds .procname = "legacy_va_layout", 10781da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 10791da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 10801da177e4SLinus Torvalds .mode = 0644, 10811da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10821da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10831da177e4SLinus Torvalds .extra1 = &zero, 10841da177e4SLinus Torvalds }, 10851da177e4SLinus Torvalds #endif 10861743660bSChristoph Lameter #ifdef CONFIG_NUMA 10871743660bSChristoph Lameter { 10881743660bSChristoph Lameter .ctl_name = VM_ZONE_RECLAIM_MODE, 10891743660bSChristoph Lameter .procname = "zone_reclaim_mode", 10901743660bSChristoph Lameter .data = &zone_reclaim_mode, 10911743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 10921743660bSChristoph Lameter .mode = 0644, 10931743660bSChristoph Lameter .proc_handler = &proc_dointvec, 1094c84db23cSChristoph Lameter .strategy = &sysctl_intvec, 1095c84db23cSChristoph Lameter .extra1 = &zero, 10961743660bSChristoph Lameter }, 10979614634fSChristoph Lameter { 10989614634fSChristoph Lameter .ctl_name = VM_MIN_UNMAPPED, 10999614634fSChristoph Lameter .procname = "min_unmapped_ratio", 11009614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 11019614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 11029614634fSChristoph Lameter .mode = 0644, 11039614634fSChristoph Lameter .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler, 11049614634fSChristoph Lameter .strategy = &sysctl_intvec, 11059614634fSChristoph Lameter .extra1 = &zero, 11069614634fSChristoph Lameter .extra2 = &one_hundred, 11079614634fSChristoph Lameter }, 11080ff38490SChristoph Lameter { 11090ff38490SChristoph Lameter .ctl_name = VM_MIN_SLAB, 11100ff38490SChristoph Lameter .procname = "min_slab_ratio", 11110ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 11120ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 11130ff38490SChristoph Lameter .mode = 0644, 11140ff38490SChristoph Lameter .proc_handler = &sysctl_min_slab_ratio_sysctl_handler, 11150ff38490SChristoph Lameter .strategy = &sysctl_intvec, 11160ff38490SChristoph Lameter .extra1 = &zero, 11170ff38490SChristoph Lameter .extra2 = &one_hundred, 11180ff38490SChristoph Lameter }, 11191743660bSChristoph Lameter #endif 112077461ab3SChristoph Lameter #ifdef CONFIG_SMP 112177461ab3SChristoph Lameter { 112277461ab3SChristoph Lameter .ctl_name = CTL_UNNUMBERED, 112377461ab3SChristoph Lameter .procname = "stat_interval", 112477461ab3SChristoph Lameter .data = &sysctl_stat_interval, 112577461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 112677461ab3SChristoph Lameter .mode = 0644, 112777461ab3SChristoph Lameter .proc_handler = &proc_dointvec_jiffies, 112877461ab3SChristoph Lameter .strategy = &sysctl_jiffies, 112977461ab3SChristoph Lameter }, 113077461ab3SChristoph Lameter #endif 1131ed032189SEric Paris #ifdef CONFIG_SECURITY 1132ed032189SEric Paris { 1133ed032189SEric Paris .ctl_name = CTL_UNNUMBERED, 1134ed032189SEric Paris .procname = "mmap_min_addr", 1135ed032189SEric Paris .data = &mmap_min_addr, 1136ed032189SEric Paris .maxlen = sizeof(unsigned long), 1137ed032189SEric Paris .mode = 0644, 1138ed032189SEric Paris .proc_handler = &proc_doulongvec_minmax, 1139ed032189SEric Paris }, 11408daec965SLee Schermerhorn #endif 1141f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1142f0c0b2b8SKAMEZAWA Hiroyuki { 1143f0c0b2b8SKAMEZAWA Hiroyuki .ctl_name = CTL_UNNUMBERED, 1144f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1145f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1146f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1147f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 1148f0c0b2b8SKAMEZAWA Hiroyuki .proc_handler = &numa_zonelist_order_handler, 1149f0c0b2b8SKAMEZAWA Hiroyuki .strategy = &sysctl_string, 1150f0c0b2b8SKAMEZAWA Hiroyuki }, 1151f0c0b2b8SKAMEZAWA Hiroyuki #endif 11522b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 11535c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1154e6e5494cSIngo Molnar { 1155e6e5494cSIngo Molnar .ctl_name = VM_VDSO_ENABLED, 1156e6e5494cSIngo Molnar .procname = "vdso_enabled", 1157e6e5494cSIngo Molnar .data = &vdso_enabled, 1158e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1159e6e5494cSIngo Molnar .mode = 0644, 1160e6e5494cSIngo Molnar .proc_handler = &proc_dointvec, 1161e6e5494cSIngo Molnar .strategy = &sysctl_intvec, 1162e6e5494cSIngo Molnar .extra1 = &zero, 1163e6e5494cSIngo Molnar }, 1164e6e5494cSIngo Molnar #endif 1165195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1166195cf453SBron Gondwana { 1167195cf453SBron Gondwana .ctl_name = CTL_UNNUMBERED, 1168195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1169195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1170195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1171195cf453SBron Gondwana .mode = 0644, 1172195cf453SBron Gondwana .proc_handler = &proc_dointvec_minmax, 1173195cf453SBron Gondwana .strategy = &sysctl_intvec, 1174195cf453SBron Gondwana .extra1 = &zero, 1175195cf453SBron Gondwana .extra2 = &one, 1176195cf453SBron Gondwana }, 1177195cf453SBron Gondwana #endif 11782be7fe07SAndrew Morton /* 11792be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 11802be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 11812be7fe07SAndrew Morton */ 11821da177e4SLinus Torvalds { .ctl_name = 0 } 11831da177e4SLinus Torvalds }; 11841da177e4SLinus Torvalds 11852abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1186d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 11872abc26fcSEric W. Biederman { .ctl_name = 0 } 11882abc26fcSEric W. Biederman }; 11892abc26fcSEric W. Biederman #endif 11902abc26fcSEric W. Biederman 1191d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 11921da177e4SLinus Torvalds { 11931da177e4SLinus Torvalds .ctl_name = FS_NRINODE, 11941da177e4SLinus Torvalds .procname = "inode-nr", 11951da177e4SLinus Torvalds .data = &inodes_stat, 11961da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 11971da177e4SLinus Torvalds .mode = 0444, 11981da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11991da177e4SLinus Torvalds }, 12001da177e4SLinus Torvalds { 12011da177e4SLinus Torvalds .ctl_name = FS_STATINODE, 12021da177e4SLinus Torvalds .procname = "inode-state", 12031da177e4SLinus Torvalds .data = &inodes_stat, 12041da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 12051da177e4SLinus Torvalds .mode = 0444, 12061da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12071da177e4SLinus Torvalds }, 12081da177e4SLinus Torvalds { 12091da177e4SLinus Torvalds .procname = "file-nr", 12101da177e4SLinus Torvalds .data = &files_stat, 12111da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 12121da177e4SLinus Torvalds .mode = 0444, 1213529bf6beSDipankar Sarma .proc_handler = &proc_nr_files, 12141da177e4SLinus Torvalds }, 12151da177e4SLinus Torvalds { 12161da177e4SLinus Torvalds .ctl_name = FS_MAXFILE, 12171da177e4SLinus Torvalds .procname = "file-max", 12181da177e4SLinus Torvalds .data = &files_stat.max_files, 12191da177e4SLinus Torvalds .maxlen = sizeof(int), 12201da177e4SLinus Torvalds .mode = 0644, 12211da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12221da177e4SLinus Torvalds }, 12231da177e4SLinus Torvalds { 12249cfe015aSEric Dumazet .ctl_name = CTL_UNNUMBERED, 12259cfe015aSEric Dumazet .procname = "nr_open", 12269cfe015aSEric Dumazet .data = &sysctl_nr_open, 12279cfe015aSEric Dumazet .maxlen = sizeof(int), 12289cfe015aSEric Dumazet .mode = 0644, 1229eceea0b3SAl Viro .proc_handler = &proc_dointvec_minmax, 1230eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1231eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 12329cfe015aSEric Dumazet }, 12339cfe015aSEric Dumazet { 12341da177e4SLinus Torvalds .ctl_name = FS_DENTRY, 12351da177e4SLinus Torvalds .procname = "dentry-state", 12361da177e4SLinus Torvalds .data = &dentry_stat, 12371da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 12381da177e4SLinus Torvalds .mode = 0444, 12391da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12401da177e4SLinus Torvalds }, 12411da177e4SLinus Torvalds { 12421da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWUID, 12431da177e4SLinus Torvalds .procname = "overflowuid", 12441da177e4SLinus Torvalds .data = &fs_overflowuid, 12451da177e4SLinus Torvalds .maxlen = sizeof(int), 12461da177e4SLinus Torvalds .mode = 0644, 12471da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 12481da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12491da177e4SLinus Torvalds .extra1 = &minolduid, 12501da177e4SLinus Torvalds .extra2 = &maxolduid, 12511da177e4SLinus Torvalds }, 12521da177e4SLinus Torvalds { 12531da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWGID, 12541da177e4SLinus Torvalds .procname = "overflowgid", 12551da177e4SLinus Torvalds .data = &fs_overflowgid, 12561da177e4SLinus Torvalds .maxlen = sizeof(int), 12571da177e4SLinus Torvalds .mode = 0644, 12581da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 12591da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12601da177e4SLinus Torvalds .extra1 = &minolduid, 12611da177e4SLinus Torvalds .extra2 = &maxolduid, 12621da177e4SLinus Torvalds }, 12631da177e4SLinus Torvalds { 12641da177e4SLinus Torvalds .ctl_name = FS_LEASES, 12651da177e4SLinus Torvalds .procname = "leases-enable", 12661da177e4SLinus Torvalds .data = &leases_enable, 12671da177e4SLinus Torvalds .maxlen = sizeof(int), 12681da177e4SLinus Torvalds .mode = 0644, 12691da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12701da177e4SLinus Torvalds }, 12711da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 12721da177e4SLinus Torvalds { 12731da177e4SLinus Torvalds .ctl_name = FS_DIR_NOTIFY, 12741da177e4SLinus Torvalds .procname = "dir-notify-enable", 12751da177e4SLinus Torvalds .data = &dir_notify_enable, 12761da177e4SLinus Torvalds .maxlen = sizeof(int), 12771da177e4SLinus Torvalds .mode = 0644, 12781da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12791da177e4SLinus Torvalds }, 12801da177e4SLinus Torvalds #endif 12811da177e4SLinus Torvalds #ifdef CONFIG_MMU 12821da177e4SLinus Torvalds { 12831da177e4SLinus Torvalds .ctl_name = FS_LEASE_TIME, 12841da177e4SLinus Torvalds .procname = "lease-break-time", 12851da177e4SLinus Torvalds .data = &lease_break_time, 12861da177e4SLinus Torvalds .maxlen = sizeof(int), 12871da177e4SLinus Torvalds .mode = 0644, 128876fdbb25SKawai, Hidehiro .proc_handler = &proc_dointvec_minmax, 128976fdbb25SKawai, Hidehiro .strategy = &sysctl_intvec, 129076fdbb25SKawai, Hidehiro .extra1 = &zero, 129176fdbb25SKawai, Hidehiro .extra2 = &two, 12921da177e4SLinus Torvalds }, 12931da177e4SLinus Torvalds { 12941da177e4SLinus Torvalds .procname = "aio-nr", 12951da177e4SLinus Torvalds .data = &aio_nr, 12961da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 12971da177e4SLinus Torvalds .mode = 0444, 1298d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 12991da177e4SLinus Torvalds }, 13001da177e4SLinus Torvalds { 13011da177e4SLinus Torvalds .procname = "aio-max-nr", 13021da177e4SLinus Torvalds .data = &aio_max_nr, 13031da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 13041da177e4SLinus Torvalds .mode = 0644, 1305d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 13061da177e4SLinus Torvalds }, 13072d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 13080399cb08SRobert Love { 13090399cb08SRobert Love .ctl_name = FS_INOTIFY, 13100399cb08SRobert Love .procname = "inotify", 13110399cb08SRobert Love .mode = 0555, 13120399cb08SRobert Love .child = inotify_table, 13130399cb08SRobert Love }, 13140399cb08SRobert Love #endif 13151da177e4SLinus Torvalds #endif 1316d6e71144SAlan Cox { 1317d6e71144SAlan Cox .ctl_name = KERN_SETUID_DUMPABLE, 1318d6e71144SAlan Cox .procname = "suid_dumpable", 1319d6e71144SAlan Cox .data = &suid_dumpable, 1320d6e71144SAlan Cox .maxlen = sizeof(int), 1321d6e71144SAlan Cox .mode = 0644, 1322d6e71144SAlan Cox .proc_handler = &proc_dointvec, 1323d6e71144SAlan Cox }, 13242abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 13252abc26fcSEric W. Biederman { 13262abc26fcSEric W. Biederman .ctl_name = CTL_UNNUMBERED, 13272abc26fcSEric W. Biederman .procname = "binfmt_misc", 13282abc26fcSEric W. Biederman .mode = 0555, 13292abc26fcSEric W. Biederman .child = binfmt_misc_table, 13302abc26fcSEric W. Biederman }, 13312abc26fcSEric W. Biederman #endif 13322be7fe07SAndrew Morton /* 13332be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 13342be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 13352be7fe07SAndrew Morton */ 13361da177e4SLinus Torvalds { .ctl_name = 0 } 13371da177e4SLinus Torvalds }; 13381da177e4SLinus Torvalds 1339d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1340d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC) 1341abd4f750SMasoud Asgharifard Sharbiani { 1342abd4f750SMasoud Asgharifard Sharbiani .ctl_name = CTL_UNNUMBERED, 1343abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1344abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1345abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1346abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1347abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1348abd4f750SMasoud Asgharifard Sharbiani }, 1349abd4f750SMasoud Asgharifard Sharbiani #endif 13501da177e4SLinus Torvalds { .ctl_name = 0 } 13511da177e4SLinus Torvalds }; 13521da177e4SLinus Torvalds 1353d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 13541da177e4SLinus Torvalds { .ctl_name = 0 } 13551da177e4SLinus Torvalds }; 13561da177e4SLinus Torvalds 1357330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1358330d57fbSAl Viro 1359330d57fbSAl Viro /* called under sysctl_lock */ 1360330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1361330d57fbSAl Viro { 1362330d57fbSAl Viro if (unlikely(p->unregistering)) 1363330d57fbSAl Viro return 0; 1364330d57fbSAl Viro p->used++; 1365330d57fbSAl Viro return 1; 1366330d57fbSAl Viro } 1367330d57fbSAl Viro 1368330d57fbSAl Viro /* called under sysctl_lock */ 1369330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1370330d57fbSAl Viro { 1371330d57fbSAl Viro if (!--p->used) 1372330d57fbSAl Viro if (unlikely(p->unregistering)) 1373330d57fbSAl Viro complete(p->unregistering); 1374330d57fbSAl Viro } 1375330d57fbSAl Viro 1376330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1377330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1378330d57fbSAl Viro { 1379330d57fbSAl Viro /* 1380330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1381330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1382330d57fbSAl Viro */ 1383330d57fbSAl Viro if (unlikely(p->used)) { 1384330d57fbSAl Viro struct completion wait; 1385330d57fbSAl Viro init_completion(&wait); 1386330d57fbSAl Viro p->unregistering = &wait; 1387330d57fbSAl Viro spin_unlock(&sysctl_lock); 1388330d57fbSAl Viro wait_for_completion(&wait); 1389330d57fbSAl Viro spin_lock(&sysctl_lock); 1390*f7e6ced4SAl Viro } else { 1391*f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1392*f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1393330d57fbSAl Viro } 1394330d57fbSAl Viro /* 1395330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1396330d57fbSAl Viro * list in do_sysctl() relies on that. 1397330d57fbSAl Viro */ 1398330d57fbSAl Viro list_del_init(&p->ctl_entry); 1399330d57fbSAl Viro } 1400330d57fbSAl Viro 1401*f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1402*f7e6ced4SAl Viro { 1403*f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1404*f7e6ced4SAl Viro head->count++; 1405*f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1406*f7e6ced4SAl Viro } 1407*f7e6ced4SAl Viro 1408*f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1409*f7e6ced4SAl Viro { 1410*f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1411*f7e6ced4SAl Viro if (!--head->count) 1412*f7e6ced4SAl Viro kfree(head); 1413*f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1414*f7e6ced4SAl Viro } 1415*f7e6ced4SAl Viro 1416*f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1417*f7e6ced4SAl Viro { 1418*f7e6ced4SAl Viro if (!head) 1419*f7e6ced4SAl Viro BUG(); 1420*f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1421*f7e6ced4SAl Viro if (!use_table(head)) 1422*f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1423*f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1424*f7e6ced4SAl Viro return head; 1425*f7e6ced4SAl Viro } 1426*f7e6ced4SAl Viro 1427805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1428805b5d5eSEric W. Biederman { 1429805b5d5eSEric W. Biederman if (!head) 1430805b5d5eSEric W. Biederman return; 1431805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1432805b5d5eSEric W. Biederman unuse_table(head); 1433805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1434805b5d5eSEric W. Biederman } 1435805b5d5eSEric W. Biederman 143673455092SAl Viro static struct ctl_table_set * 143773455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 143873455092SAl Viro { 143973455092SAl Viro struct ctl_table_set *set = &root->default_set; 144073455092SAl Viro if (root->lookup) 144173455092SAl Viro set = root->lookup(root, namespaces); 144273455092SAl Viro return set; 144373455092SAl Viro } 144473455092SAl Viro 1445e51b6ba0SEric W. Biederman static struct list_head * 1446e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1447805b5d5eSEric W. Biederman { 144873455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 144973455092SAl Viro return &set->list; 1450e51b6ba0SEric W. Biederman } 1451e51b6ba0SEric W. Biederman 1452e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1453e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1454e51b6ba0SEric W. Biederman { 1455e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1456e51b6ba0SEric W. Biederman struct list_head *header_list; 1457805b5d5eSEric W. Biederman struct ctl_table_header *head; 1458805b5d5eSEric W. Biederman struct list_head *tmp; 1459e51b6ba0SEric W. Biederman 1460805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1461805b5d5eSEric W. Biederman if (prev) { 1462e51b6ba0SEric W. Biederman head = prev; 1463805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1464805b5d5eSEric W. Biederman unuse_table(prev); 1465805b5d5eSEric W. Biederman goto next; 1466805b5d5eSEric W. Biederman } 1467805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1468805b5d5eSEric W. Biederman for (;;) { 1469805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1470805b5d5eSEric W. Biederman 1471805b5d5eSEric W. Biederman if (!use_table(head)) 1472805b5d5eSEric W. Biederman goto next; 1473805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1474805b5d5eSEric W. Biederman return head; 1475805b5d5eSEric W. Biederman next: 1476e51b6ba0SEric W. Biederman root = head->root; 1477805b5d5eSEric W. Biederman tmp = tmp->next; 1478e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1479e51b6ba0SEric W. Biederman if (tmp != header_list) 1480e51b6ba0SEric W. Biederman continue; 1481e51b6ba0SEric W. Biederman 1482e51b6ba0SEric W. Biederman do { 1483e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1484e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1485e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1486e51b6ba0SEric W. Biederman goto out; 1487e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1488e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1489e51b6ba0SEric W. Biederman tmp = header_list->next; 1490805b5d5eSEric W. Biederman } 1491e51b6ba0SEric W. Biederman out: 1492805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1493805b5d5eSEric W. Biederman return NULL; 1494805b5d5eSEric W. Biederman } 1495805b5d5eSEric W. Biederman 1496e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1497e51b6ba0SEric W. Biederman { 1498e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1499e51b6ba0SEric W. Biederman } 1500e51b6ba0SEric W. Biederman 1501e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1502e51b6ba0SEric W. Biederman { 1503e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1504e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1505e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1506e51b6ba0SEric W. Biederman } 1507e51b6ba0SEric W. Biederman 1508b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 15092c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */ 1510d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root, 1511d7321cd6SPavel Emelyanov struct ctl_table *table, 15122c4c7155SPavel Emelyanov int __user *name, int nlen, 15132c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 15142c4c7155SPavel Emelyanov void __user *newval, size_t newlen) 15152c4c7155SPavel Emelyanov { 15162c4c7155SPavel Emelyanov int op = 0, rc; 15172c4c7155SPavel Emelyanov 15182c4c7155SPavel Emelyanov if (oldval) 15192c4c7155SPavel Emelyanov op |= 004; 15202c4c7155SPavel Emelyanov if (newval) 15212c4c7155SPavel Emelyanov op |= 002; 1522d7321cd6SPavel Emelyanov if (sysctl_perm(root, table, op)) 15232c4c7155SPavel Emelyanov return -EPERM; 15242c4c7155SPavel Emelyanov 15252c4c7155SPavel Emelyanov if (table->strategy) { 15262c4c7155SPavel Emelyanov rc = table->strategy(table, name, nlen, oldval, oldlenp, 15272c4c7155SPavel Emelyanov newval, newlen); 15282c4c7155SPavel Emelyanov if (rc < 0) 15292c4c7155SPavel Emelyanov return rc; 15302c4c7155SPavel Emelyanov if (rc > 0) 15312c4c7155SPavel Emelyanov return 0; 15322c4c7155SPavel Emelyanov } 15332c4c7155SPavel Emelyanov 15342c4c7155SPavel Emelyanov /* If there is no strategy routine, or if the strategy returns 15352c4c7155SPavel Emelyanov * zero, proceed with automatic r/w */ 15362c4c7155SPavel Emelyanov if (table->data && table->maxlen) { 15372c4c7155SPavel Emelyanov rc = sysctl_data(table, name, nlen, oldval, oldlenp, 15382c4c7155SPavel Emelyanov newval, newlen); 15392c4c7155SPavel Emelyanov if (rc < 0) 15402c4c7155SPavel Emelyanov return rc; 15412c4c7155SPavel Emelyanov } 15422c4c7155SPavel Emelyanov return 0; 15432c4c7155SPavel Emelyanov } 15442c4c7155SPavel Emelyanov 15452c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen, 15462c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 15472c4c7155SPavel Emelyanov void __user *newval, size_t newlen, 1548d7321cd6SPavel Emelyanov struct ctl_table_root *root, 15492c4c7155SPavel Emelyanov struct ctl_table *table) 15502c4c7155SPavel Emelyanov { 15512c4c7155SPavel Emelyanov int n; 15522c4c7155SPavel Emelyanov repeat: 15532c4c7155SPavel Emelyanov if (!nlen) 15542c4c7155SPavel Emelyanov return -ENOTDIR; 15552c4c7155SPavel Emelyanov if (get_user(n, name)) 15562c4c7155SPavel Emelyanov return -EFAULT; 15572c4c7155SPavel Emelyanov for ( ; table->ctl_name || table->procname; table++) { 15582c4c7155SPavel Emelyanov if (!table->ctl_name) 15592c4c7155SPavel Emelyanov continue; 15602c4c7155SPavel Emelyanov if (n == table->ctl_name) { 15612c4c7155SPavel Emelyanov int error; 15622c4c7155SPavel Emelyanov if (table->child) { 1563d7321cd6SPavel Emelyanov if (sysctl_perm(root, table, 001)) 15642c4c7155SPavel Emelyanov return -EPERM; 15652c4c7155SPavel Emelyanov name++; 15662c4c7155SPavel Emelyanov nlen--; 15672c4c7155SPavel Emelyanov table = table->child; 15682c4c7155SPavel Emelyanov goto repeat; 15692c4c7155SPavel Emelyanov } 1570d7321cd6SPavel Emelyanov error = do_sysctl_strategy(root, table, name, nlen, 15712c4c7155SPavel Emelyanov oldval, oldlenp, 15722c4c7155SPavel Emelyanov newval, newlen); 15732c4c7155SPavel Emelyanov return error; 15742c4c7155SPavel Emelyanov } 15752c4c7155SPavel Emelyanov } 15762c4c7155SPavel Emelyanov return -ENOTDIR; 15772c4c7155SPavel Emelyanov } 15782c4c7155SPavel Emelyanov 15791da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 15801da177e4SLinus Torvalds void __user *newval, size_t newlen) 15811da177e4SLinus Torvalds { 1582805b5d5eSEric W. Biederman struct ctl_table_header *head; 1583330d57fbSAl Viro int error = -ENOTDIR; 15841da177e4SLinus Torvalds 15851da177e4SLinus Torvalds if (nlen <= 0 || nlen >= CTL_MAXNAME) 15861da177e4SLinus Torvalds return -ENOTDIR; 15871da177e4SLinus Torvalds if (oldval) { 15881da177e4SLinus Torvalds int old_len; 15891da177e4SLinus Torvalds if (!oldlenp || get_user(old_len, oldlenp)) 15901da177e4SLinus Torvalds return -EFAULT; 15911da177e4SLinus Torvalds } 1592330d57fbSAl Viro 1593805b5d5eSEric W. Biederman for (head = sysctl_head_next(NULL); head; 1594805b5d5eSEric W. Biederman head = sysctl_head_next(head)) { 1595330d57fbSAl Viro error = parse_table(name, nlen, oldval, oldlenp, 1596d7321cd6SPavel Emelyanov newval, newlen, 1597d7321cd6SPavel Emelyanov head->root, head->ctl_table); 1598805b5d5eSEric W. Biederman if (error != -ENOTDIR) { 1599805b5d5eSEric W. Biederman sysctl_head_finish(head); 1600330d57fbSAl Viro break; 1601805b5d5eSEric W. Biederman } 1602805b5d5eSEric W. Biederman } 16031da177e4SLinus Torvalds return error; 16041da177e4SLinus Torvalds } 16051da177e4SLinus Torvalds 16061da177e4SLinus Torvalds asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 16071da177e4SLinus Torvalds { 16081da177e4SLinus Torvalds struct __sysctl_args tmp; 16091da177e4SLinus Torvalds int error; 16101da177e4SLinus Torvalds 16111da177e4SLinus Torvalds if (copy_from_user(&tmp, args, sizeof(tmp))) 16121da177e4SLinus Torvalds return -EFAULT; 16131da177e4SLinus Torvalds 16147058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 16157058cb02SEric W. Biederman if (error) 16167058cb02SEric W. Biederman goto out; 16177058cb02SEric W. Biederman 16181da177e4SLinus Torvalds lock_kernel(); 16191da177e4SLinus Torvalds error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, 16201da177e4SLinus Torvalds tmp.newval, tmp.newlen); 16211da177e4SLinus Torvalds unlock_kernel(); 16227058cb02SEric W. Biederman out: 16231da177e4SLinus Torvalds return error; 16241da177e4SLinus Torvalds } 1625b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 16261da177e4SLinus Torvalds 16271da177e4SLinus Torvalds /* 16281ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 16291da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 16301da177e4SLinus Torvalds */ 16311da177e4SLinus Torvalds 16321da177e4SLinus Torvalds static int test_perm(int mode, int op) 16331da177e4SLinus Torvalds { 16341da177e4SLinus Torvalds if (!current->euid) 16351da177e4SLinus Torvalds mode >>= 6; 16361da177e4SLinus Torvalds else if (in_egroup_p(0)) 16371da177e4SLinus Torvalds mode >>= 3; 16381da177e4SLinus Torvalds if ((mode & op & 0007) == op) 16391da177e4SLinus Torvalds return 0; 16401da177e4SLinus Torvalds return -EACCES; 16411da177e4SLinus Torvalds } 16421da177e4SLinus Torvalds 1643d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 16441da177e4SLinus Torvalds { 16451da177e4SLinus Torvalds int error; 1646d7321cd6SPavel Emelyanov int mode; 1647d7321cd6SPavel Emelyanov 16481da177e4SLinus Torvalds error = security_sysctl(table, op); 16491da177e4SLinus Torvalds if (error) 16501da177e4SLinus Torvalds return error; 1651d7321cd6SPavel Emelyanov 1652d7321cd6SPavel Emelyanov if (root->permissions) 1653d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1654d7321cd6SPavel Emelyanov else 1655d7321cd6SPavel Emelyanov mode = table->mode; 1656d7321cd6SPavel Emelyanov 1657d7321cd6SPavel Emelyanov return test_perm(mode, op); 16581da177e4SLinus Torvalds } 16591da177e4SLinus Torvalds 1660d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1661d912b0ccSEric W. Biederman { 1662d912b0ccSEric W. Biederman for (; table->ctl_name || table->procname; table++) { 1663d912b0ccSEric W. Biederman table->parent = parent; 1664d912b0ccSEric W. Biederman if (table->child) 1665d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1666d912b0ccSEric W. Biederman } 1667d912b0ccSEric W. Biederman } 1668d912b0ccSEric W. Biederman 1669d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1670d912b0ccSEric W. Biederman { 1671d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 167288f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 167388f458e4SHolger Schurig { 167488f458e4SHolger Schurig int err; 1675e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 167688f458e4SHolger Schurig } 167788f458e4SHolger Schurig #endif 1678d912b0ccSEric W. Biederman return 0; 1679d912b0ccSEric W. Biederman } 1680d912b0ccSEric W. Biederman 1681d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1682d912b0ccSEric W. Biederman 16831da177e4SLinus Torvalds /** 1684e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1685e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1686e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 168729e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 16881da177e4SLinus Torvalds * @table: the top-level table structure 16891da177e4SLinus Torvalds * 16901da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 169129e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 16921da177e4SLinus Torvalds * 1693d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 16941da177e4SLinus Torvalds * 16951da177e4SLinus Torvalds * ctl_name - This is the numeric sysctl value used by sysctl(2). The number 16961da177e4SLinus Torvalds * must be unique within that level of sysctl 16971da177e4SLinus Torvalds * 16981da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 16991da177e4SLinus Torvalds * enter a sysctl file 17001da177e4SLinus Torvalds * 17011da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 17021da177e4SLinus Torvalds * 17031da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 17041da177e4SLinus Torvalds * 17051da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 17061da177e4SLinus Torvalds * 17071da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 17081da177e4SLinus Torvalds * %NULL. 17091da177e4SLinus Torvalds * 17101da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 17111da177e4SLinus Torvalds * 17121da177e4SLinus Torvalds * strategy - the strategy routine (described below) 17131da177e4SLinus Torvalds * 17141da177e4SLinus Torvalds * de - for internal use by the sysctl routines 17151da177e4SLinus Torvalds * 17161da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 17171da177e4SLinus Torvalds * 17181da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 17191da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 17201da177e4SLinus Torvalds * 17211da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 17221da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 17231da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 17241da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 17251da177e4SLinus Torvalds * 17261da177e4SLinus Torvalds * More sophisticated management can be enabled by the provision of a 17271da177e4SLinus Torvalds * strategy routine with the table entry. This will be called before 17281da177e4SLinus Torvalds * any automatic read or write of the data is performed. 17291da177e4SLinus Torvalds * 17301da177e4SLinus Torvalds * The strategy routine may return 17311da177e4SLinus Torvalds * 17321da177e4SLinus Torvalds * < 0 - Error occurred (error is passed to user process) 17331da177e4SLinus Torvalds * 17341da177e4SLinus Torvalds * 0 - OK - proceed with automatic read or write. 17351da177e4SLinus Torvalds * 17361da177e4SLinus Torvalds * > 0 - OK - read or write has been done by the strategy routine, so 17371da177e4SLinus Torvalds * return immediately. 17381da177e4SLinus Torvalds * 17391da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 17401da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 17411da177e4SLinus Torvalds * directory handler). Several default handlers are available to 17421da177e4SLinus Torvalds * cover common cases - 17431da177e4SLinus Torvalds * 17441da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 17451da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 17461da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 17471da177e4SLinus Torvalds * 17481da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 17491da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 17501da177e4SLinus Torvalds * 17511da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 17521da177e4SLinus Torvalds * to the table header on success. 17531da177e4SLinus Torvalds */ 1754e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1755e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1756e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1757e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 17581da177e4SLinus Torvalds { 175929e796fdSEric W. Biederman struct ctl_table_header *header; 176029e796fdSEric W. Biederman struct ctl_table *new, **prevp; 176129e796fdSEric W. Biederman unsigned int n, npath; 176229e796fdSEric W. Biederman 176329e796fdSEric W. Biederman /* Count the path components */ 176429e796fdSEric W. Biederman for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath) 176529e796fdSEric W. Biederman ; 176629e796fdSEric W. Biederman 176729e796fdSEric W. Biederman /* 176829e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 176929e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 177029e796fdSEric W. Biederman * for this, the second will be the sentinel (ctl_name == 0). 177129e796fdSEric W. Biederman * 177229e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 177329e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 177429e796fdSEric W. Biederman */ 177529e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 177629e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 177729e796fdSEric W. Biederman if (!header) 17781da177e4SLinus Torvalds return NULL; 177929e796fdSEric W. Biederman 178029e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 178129e796fdSEric W. Biederman 178229e796fdSEric W. Biederman /* Now connect the dots */ 178329e796fdSEric W. Biederman prevp = &header->ctl_table; 178429e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 178529e796fdSEric W. Biederman /* Copy the procname */ 178629e796fdSEric W. Biederman new->procname = path->procname; 178729e796fdSEric W. Biederman new->ctl_name = path->ctl_name; 178829e796fdSEric W. Biederman new->mode = 0555; 178929e796fdSEric W. Biederman 179029e796fdSEric W. Biederman *prevp = new; 179129e796fdSEric W. Biederman prevp = &new->child; 179229e796fdSEric W. Biederman 179329e796fdSEric W. Biederman new += 2; 179429e796fdSEric W. Biederman } 179529e796fdSEric W. Biederman *prevp = table; 179623eb06deSEric W. Biederman header->ctl_table_arg = table; 179729e796fdSEric W. Biederman 179829e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 179929e796fdSEric W. Biederman header->used = 0; 180029e796fdSEric W. Biederman header->unregistering = NULL; 1801e51b6ba0SEric W. Biederman header->root = root; 180229e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1803*f7e6ced4SAl Viro header->count = 1; 180488f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1805e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 180629e796fdSEric W. Biederman kfree(header); 1807fc6cd25bSEric W. Biederman return NULL; 1808fc6cd25bSEric W. Biederman } 180988f458e4SHolger Schurig #endif 1810330d57fbSAl Viro spin_lock(&sysctl_lock); 181173455092SAl Viro header->set = lookup_header_set(root, namespaces); 181273455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1813330d57fbSAl Viro spin_unlock(&sysctl_lock); 181429e796fdSEric W. Biederman 181529e796fdSEric W. Biederman return header; 181629e796fdSEric W. Biederman } 181729e796fdSEric W. Biederman 181829e796fdSEric W. Biederman /** 1819e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1820e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1821e51b6ba0SEric W. Biederman * @table: the top-level table structure 1822e51b6ba0SEric W. Biederman * 1823e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1824e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1825e51b6ba0SEric W. Biederman * 1826e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1827e51b6ba0SEric W. Biederman */ 1828e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1829e51b6ba0SEric W. Biederman struct ctl_table *table) 1830e51b6ba0SEric W. Biederman { 1831e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1832e51b6ba0SEric W. Biederman path, table); 1833e51b6ba0SEric W. Biederman } 1834e51b6ba0SEric W. Biederman 1835e51b6ba0SEric W. Biederman /** 183629e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 183729e796fdSEric W. Biederman * @table: the top-level table structure 183829e796fdSEric W. Biederman * 183929e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 184029e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 184129e796fdSEric W. Biederman * 184229e796fdSEric W. Biederman * See register_sysctl_paths for more details. 184329e796fdSEric W. Biederman */ 184429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 184529e796fdSEric W. Biederman { 184629e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 184729e796fdSEric W. Biederman 184829e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 18491da177e4SLinus Torvalds } 18501da177e4SLinus Torvalds 18511da177e4SLinus Torvalds /** 18521da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 18531da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 18541da177e4SLinus Torvalds * 18551da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 18561da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 18571da177e4SLinus Torvalds */ 18581da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 18591da177e4SLinus Torvalds { 1860330d57fbSAl Viro might_sleep(); 1861f1dad166SPavel Emelyanov 1862f1dad166SPavel Emelyanov if (header == NULL) 1863f1dad166SPavel Emelyanov return; 1864f1dad166SPavel Emelyanov 1865330d57fbSAl Viro spin_lock(&sysctl_lock); 1866330d57fbSAl Viro start_unregistering(header); 1867*f7e6ced4SAl Viro if (!--header->count) 18681da177e4SLinus Torvalds kfree(header); 1869*f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 18701da177e4SLinus Torvalds } 18711da177e4SLinus Torvalds 187273455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 187373455092SAl Viro struct ctl_table_set *parent, 187473455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 187573455092SAl Viro { 187673455092SAl Viro INIT_LIST_HEAD(&p->list); 187773455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 187873455092SAl Viro p->is_seen = is_seen; 187973455092SAl Viro } 188073455092SAl Viro 1881b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 1882d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1883b89a8171SEric W. Biederman { 1884b89a8171SEric W. Biederman return NULL; 1885b89a8171SEric W. Biederman } 1886b89a8171SEric W. Biederman 188729e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 188829e796fdSEric W. Biederman struct ctl_table *table) 188929e796fdSEric W. Biederman { 189029e796fdSEric W. Biederman return NULL; 189129e796fdSEric W. Biederman } 189229e796fdSEric W. Biederman 1893b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 1894b89a8171SEric W. Biederman { 1895b89a8171SEric W. Biederman } 1896b89a8171SEric W. Biederman 189773455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 189873455092SAl Viro struct ctl_table_set *parent, 189973455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 190073455092SAl Viro { 190173455092SAl Viro } 190273455092SAl Viro 1903*f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1904*f7e6ced4SAl Viro { 1905*f7e6ced4SAl Viro } 1906*f7e6ced4SAl Viro 1907b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1908b89a8171SEric W. Biederman 19091da177e4SLinus Torvalds /* 19101da177e4SLinus Torvalds * /proc/sys support 19111da177e4SLinus Torvalds */ 19121da177e4SLinus Torvalds 1913b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 19141da177e4SLinus Torvalds 1915b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 1916b1ba4dddSAdrian Bunk struct file *filp, void __user *buffer, 1917b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1918f5dd3d6fSSam Vilain { 1919f5dd3d6fSSam Vilain size_t len; 1920f5dd3d6fSSam Vilain char __user *p; 1921f5dd3d6fSSam Vilain char c; 1922f5dd3d6fSSam Vilain 19238d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1924f5dd3d6fSSam Vilain *lenp = 0; 1925f5dd3d6fSSam Vilain return 0; 1926f5dd3d6fSSam Vilain } 1927f5dd3d6fSSam Vilain 1928f5dd3d6fSSam Vilain if (write) { 1929f5dd3d6fSSam Vilain len = 0; 1930f5dd3d6fSSam Vilain p = buffer; 1931f5dd3d6fSSam Vilain while (len < *lenp) { 1932f5dd3d6fSSam Vilain if (get_user(c, p++)) 1933f5dd3d6fSSam Vilain return -EFAULT; 1934f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1935f5dd3d6fSSam Vilain break; 1936f5dd3d6fSSam Vilain len++; 1937f5dd3d6fSSam Vilain } 1938f5dd3d6fSSam Vilain if (len >= maxlen) 1939f5dd3d6fSSam Vilain len = maxlen-1; 1940f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1941f5dd3d6fSSam Vilain return -EFAULT; 1942f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 1943f5dd3d6fSSam Vilain *ppos += *lenp; 1944f5dd3d6fSSam Vilain } else { 1945f5dd3d6fSSam Vilain len = strlen(data); 1946f5dd3d6fSSam Vilain if (len > maxlen) 1947f5dd3d6fSSam Vilain len = maxlen; 19488d060877SOleg Nesterov 19498d060877SOleg Nesterov if (*ppos > len) { 19508d060877SOleg Nesterov *lenp = 0; 19518d060877SOleg Nesterov return 0; 19528d060877SOleg Nesterov } 19538d060877SOleg Nesterov 19548d060877SOleg Nesterov data += *ppos; 19558d060877SOleg Nesterov len -= *ppos; 19568d060877SOleg Nesterov 1957f5dd3d6fSSam Vilain if (len > *lenp) 1958f5dd3d6fSSam Vilain len = *lenp; 1959f5dd3d6fSSam Vilain if (len) 1960f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 1961f5dd3d6fSSam Vilain return -EFAULT; 1962f5dd3d6fSSam Vilain if (len < *lenp) { 1963f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 1964f5dd3d6fSSam Vilain return -EFAULT; 1965f5dd3d6fSSam Vilain len++; 1966f5dd3d6fSSam Vilain } 1967f5dd3d6fSSam Vilain *lenp = len; 1968f5dd3d6fSSam Vilain *ppos += len; 1969f5dd3d6fSSam Vilain } 1970f5dd3d6fSSam Vilain return 0; 1971f5dd3d6fSSam Vilain } 1972f5dd3d6fSSam Vilain 19731da177e4SLinus Torvalds /** 19741da177e4SLinus Torvalds * proc_dostring - read a string sysctl 19751da177e4SLinus Torvalds * @table: the sysctl table 19761da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 19771da177e4SLinus Torvalds * @filp: the file structure 19781da177e4SLinus Torvalds * @buffer: the user buffer 19791da177e4SLinus Torvalds * @lenp: the size of the user buffer 19801da177e4SLinus Torvalds * @ppos: file position 19811da177e4SLinus Torvalds * 19821da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 19831da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 19841da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 19851da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 19861da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 19871da177e4SLinus Torvalds * not large enough. 19881da177e4SLinus Torvalds * 19891da177e4SLinus Torvalds * Returns 0 on success. 19901da177e4SLinus Torvalds */ 1991d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp, 19921da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 19931da177e4SLinus Torvalds { 1994f5dd3d6fSSam Vilain return _proc_do_string(table->data, table->maxlen, write, filp, 1995f5dd3d6fSSam Vilain buffer, lenp, ppos); 19961da177e4SLinus Torvalds } 19971da177e4SLinus Torvalds 19981da177e4SLinus Torvalds 19991da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 20001da177e4SLinus Torvalds int *valp, 20011da177e4SLinus Torvalds int write, void *data) 20021da177e4SLinus Torvalds { 20031da177e4SLinus Torvalds if (write) { 20041da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 20051da177e4SLinus Torvalds } else { 20061da177e4SLinus Torvalds int val = *valp; 20071da177e4SLinus Torvalds if (val < 0) { 20081da177e4SLinus Torvalds *negp = -1; 20091da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 20101da177e4SLinus Torvalds } else { 20111da177e4SLinus Torvalds *negp = 0; 20121da177e4SLinus Torvalds *lvalp = (unsigned long)val; 20131da177e4SLinus Torvalds } 20141da177e4SLinus Torvalds } 20151da177e4SLinus Torvalds return 0; 20161da177e4SLinus Torvalds } 20171da177e4SLinus Torvalds 2018d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 2019fcfbd547SKirill Korotaev int write, struct file *filp, void __user *buffer, 2020fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 20211da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 20221da177e4SLinus Torvalds int write, void *data), 20231da177e4SLinus Torvalds void *data) 20241da177e4SLinus Torvalds { 20251da177e4SLinus Torvalds #define TMPBUFLEN 21 20261da177e4SLinus Torvalds int *i, vleft, first=1, neg, val; 20271da177e4SLinus Torvalds unsigned long lval; 20281da177e4SLinus Torvalds size_t left, len; 20291da177e4SLinus Torvalds 20301da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 20311da177e4SLinus Torvalds char __user *s = buffer; 20321da177e4SLinus Torvalds 2033fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 20341da177e4SLinus Torvalds (*ppos && !write)) { 20351da177e4SLinus Torvalds *lenp = 0; 20361da177e4SLinus Torvalds return 0; 20371da177e4SLinus Torvalds } 20381da177e4SLinus Torvalds 2039fcfbd547SKirill Korotaev i = (int *) tbl_data; 20401da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 20411da177e4SLinus Torvalds left = *lenp; 20421da177e4SLinus Torvalds 20431da177e4SLinus Torvalds if (!conv) 20441da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 20451da177e4SLinus Torvalds 20461da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 20471da177e4SLinus Torvalds if (write) { 20481da177e4SLinus Torvalds while (left) { 20491da177e4SLinus Torvalds char c; 20501da177e4SLinus Torvalds if (get_user(c, s)) 20511da177e4SLinus Torvalds return -EFAULT; 20521da177e4SLinus Torvalds if (!isspace(c)) 20531da177e4SLinus Torvalds break; 20541da177e4SLinus Torvalds left--; 20551da177e4SLinus Torvalds s++; 20561da177e4SLinus Torvalds } 20571da177e4SLinus Torvalds if (!left) 20581da177e4SLinus Torvalds break; 20591da177e4SLinus Torvalds neg = 0; 20601da177e4SLinus Torvalds len = left; 20611da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 20621da177e4SLinus Torvalds len = sizeof(buf) - 1; 20631da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 20641da177e4SLinus Torvalds return -EFAULT; 20651da177e4SLinus Torvalds buf[len] = 0; 20661da177e4SLinus Torvalds p = buf; 20671da177e4SLinus Torvalds if (*p == '-' && left > 1) { 20681da177e4SLinus Torvalds neg = 1; 2069bd9b0bacSBP, Praveen p++; 20701da177e4SLinus Torvalds } 20711da177e4SLinus Torvalds if (*p < '0' || *p > '9') 20721da177e4SLinus Torvalds break; 20731da177e4SLinus Torvalds 20741da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 20751da177e4SLinus Torvalds 20761da177e4SLinus Torvalds len = p-buf; 20771da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 20781da177e4SLinus Torvalds break; 20791da177e4SLinus Torvalds if (neg) 20801da177e4SLinus Torvalds val = -val; 20811da177e4SLinus Torvalds s += len; 20821da177e4SLinus Torvalds left -= len; 20831da177e4SLinus Torvalds 20841da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 20851da177e4SLinus Torvalds break; 20861da177e4SLinus Torvalds } else { 20871da177e4SLinus Torvalds p = buf; 20881da177e4SLinus Torvalds if (!first) 20891da177e4SLinus Torvalds *p++ = '\t'; 20901da177e4SLinus Torvalds 20911da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 20921da177e4SLinus Torvalds break; 20931da177e4SLinus Torvalds 20941da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 20951da177e4SLinus Torvalds len = strlen(buf); 20961da177e4SLinus Torvalds if (len > left) 20971da177e4SLinus Torvalds len = left; 20981da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 20991da177e4SLinus Torvalds return -EFAULT; 21001da177e4SLinus Torvalds left -= len; 21011da177e4SLinus Torvalds s += len; 21021da177e4SLinus Torvalds } 21031da177e4SLinus Torvalds } 21041da177e4SLinus Torvalds 21051da177e4SLinus Torvalds if (!write && !first && left) { 21061da177e4SLinus Torvalds if(put_user('\n', s)) 21071da177e4SLinus Torvalds return -EFAULT; 21081da177e4SLinus Torvalds left--, s++; 21091da177e4SLinus Torvalds } 21101da177e4SLinus Torvalds if (write) { 21111da177e4SLinus Torvalds while (left) { 21121da177e4SLinus Torvalds char c; 21131da177e4SLinus Torvalds if (get_user(c, s++)) 21141da177e4SLinus Torvalds return -EFAULT; 21151da177e4SLinus Torvalds if (!isspace(c)) 21161da177e4SLinus Torvalds break; 21171da177e4SLinus Torvalds left--; 21181da177e4SLinus Torvalds } 21191da177e4SLinus Torvalds } 21201da177e4SLinus Torvalds if (write && first) 21211da177e4SLinus Torvalds return -EINVAL; 21221da177e4SLinus Torvalds *lenp -= left; 21231da177e4SLinus Torvalds *ppos += *lenp; 21241da177e4SLinus Torvalds return 0; 21251da177e4SLinus Torvalds #undef TMPBUFLEN 21261da177e4SLinus Torvalds } 21271da177e4SLinus Torvalds 2128d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp, 2129fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2130fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2131fcfbd547SKirill Korotaev int write, void *data), 2132fcfbd547SKirill Korotaev void *data) 2133fcfbd547SKirill Korotaev { 2134fcfbd547SKirill Korotaev return __do_proc_dointvec(table->data, table, write, filp, 2135fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2136fcfbd547SKirill Korotaev } 2137fcfbd547SKirill Korotaev 21381da177e4SLinus Torvalds /** 21391da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 21401da177e4SLinus Torvalds * @table: the sysctl table 21411da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21421da177e4SLinus Torvalds * @filp: the file structure 21431da177e4SLinus Torvalds * @buffer: the user buffer 21441da177e4SLinus Torvalds * @lenp: the size of the user buffer 21451da177e4SLinus Torvalds * @ppos: file position 21461da177e4SLinus Torvalds * 21471da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 21481da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 21491da177e4SLinus Torvalds * 21501da177e4SLinus Torvalds * Returns 0 on success. 21511da177e4SLinus Torvalds */ 2152d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp, 21531da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21541da177e4SLinus Torvalds { 21551da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 21561da177e4SLinus Torvalds NULL,NULL); 21571da177e4SLinus Torvalds } 21581da177e4SLinus Torvalds 21591da177e4SLinus Torvalds #define OP_SET 0 21601da177e4SLinus Torvalds #define OP_AND 1 216134f5a398STheodore Ts'o #define OP_OR 2 21621da177e4SLinus Torvalds 21631da177e4SLinus Torvalds static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp, 21641da177e4SLinus Torvalds int *valp, 21651da177e4SLinus Torvalds int write, void *data) 21661da177e4SLinus Torvalds { 21671da177e4SLinus Torvalds int op = *(int *)data; 21681da177e4SLinus Torvalds if (write) { 21691da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 21701da177e4SLinus Torvalds switch(op) { 21711da177e4SLinus Torvalds case OP_SET: *valp = val; break; 21721da177e4SLinus Torvalds case OP_AND: *valp &= val; break; 217334f5a398STheodore Ts'o case OP_OR: *valp |= val; break; 21741da177e4SLinus Torvalds } 21751da177e4SLinus Torvalds } else { 21761da177e4SLinus Torvalds int val = *valp; 21771da177e4SLinus Torvalds if (val < 0) { 21781da177e4SLinus Torvalds *negp = -1; 21791da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 21801da177e4SLinus Torvalds } else { 21811da177e4SLinus Torvalds *negp = 0; 21821da177e4SLinus Torvalds *lvalp = (unsigned long)val; 21831da177e4SLinus Torvalds } 21841da177e4SLinus Torvalds } 21851da177e4SLinus Torvalds return 0; 21861da177e4SLinus Torvalds } 21871da177e4SLinus Torvalds 218834f5a398STheodore Ts'o /* 218934f5a398STheodore Ts'o * Taint values can only be increased 219034f5a398STheodore Ts'o */ 2191d8217f07SEric W. Biederman static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, 219234f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 219334f5a398STheodore Ts'o { 219434f5a398STheodore Ts'o int op; 219534f5a398STheodore Ts'o 219691fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 219734f5a398STheodore Ts'o return -EPERM; 219834f5a398STheodore Ts'o 219934f5a398STheodore Ts'o op = OP_OR; 220034f5a398STheodore Ts'o return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 220134f5a398STheodore Ts'o do_proc_dointvec_bset_conv,&op); 220234f5a398STheodore Ts'o } 220334f5a398STheodore Ts'o 22041da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 22051da177e4SLinus Torvalds int *min; 22061da177e4SLinus Torvalds int *max; 22071da177e4SLinus Torvalds }; 22081da177e4SLinus Torvalds 22091da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 22101da177e4SLinus Torvalds int *valp, 22111da177e4SLinus Torvalds int write, void *data) 22121da177e4SLinus Torvalds { 22131da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 22141da177e4SLinus Torvalds if (write) { 22151da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 22161da177e4SLinus Torvalds if ((param->min && *param->min > val) || 22171da177e4SLinus Torvalds (param->max && *param->max < val)) 22181da177e4SLinus Torvalds return -EINVAL; 22191da177e4SLinus Torvalds *valp = val; 22201da177e4SLinus Torvalds } else { 22211da177e4SLinus Torvalds int val = *valp; 22221da177e4SLinus Torvalds if (val < 0) { 22231da177e4SLinus Torvalds *negp = -1; 22241da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22251da177e4SLinus Torvalds } else { 22261da177e4SLinus Torvalds *negp = 0; 22271da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22281da177e4SLinus Torvalds } 22291da177e4SLinus Torvalds } 22301da177e4SLinus Torvalds return 0; 22311da177e4SLinus Torvalds } 22321da177e4SLinus Torvalds 22331da177e4SLinus Torvalds /** 22341da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 22351da177e4SLinus Torvalds * @table: the sysctl table 22361da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22371da177e4SLinus Torvalds * @filp: the file structure 22381da177e4SLinus Torvalds * @buffer: the user buffer 22391da177e4SLinus Torvalds * @lenp: the size of the user buffer 22401da177e4SLinus Torvalds * @ppos: file position 22411da177e4SLinus Torvalds * 22421da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22431da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22441da177e4SLinus Torvalds * 22451da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 22461da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 22471da177e4SLinus Torvalds * 22481da177e4SLinus Torvalds * Returns 0 on success. 22491da177e4SLinus Torvalds */ 2250d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, 22511da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22521da177e4SLinus Torvalds { 22531da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 22541da177e4SLinus Torvalds .min = (int *) table->extra1, 22551da177e4SLinus Torvalds .max = (int *) table->extra2, 22561da177e4SLinus Torvalds }; 22571da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 22581da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 22591da177e4SLinus Torvalds } 22601da177e4SLinus Torvalds 2261d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 22621da177e4SLinus Torvalds struct file *filp, 22631da177e4SLinus Torvalds void __user *buffer, 22641da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 22651da177e4SLinus Torvalds unsigned long convmul, 22661da177e4SLinus Torvalds unsigned long convdiv) 22671da177e4SLinus Torvalds { 22681da177e4SLinus Torvalds #define TMPBUFLEN 21 22691da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 22701da177e4SLinus Torvalds int vleft, first=1, neg; 22711da177e4SLinus Torvalds size_t len, left; 22721da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 22731da177e4SLinus Torvalds char __user *s = buffer; 22741da177e4SLinus Torvalds 2275fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 22761da177e4SLinus Torvalds (*ppos && !write)) { 22771da177e4SLinus Torvalds *lenp = 0; 22781da177e4SLinus Torvalds return 0; 22791da177e4SLinus Torvalds } 22801da177e4SLinus Torvalds 2281fcfbd547SKirill Korotaev i = (unsigned long *) data; 22821da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 22831da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 22841da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 22851da177e4SLinus Torvalds left = *lenp; 22861da177e4SLinus Torvalds 22871da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 22881da177e4SLinus Torvalds if (write) { 22891da177e4SLinus Torvalds while (left) { 22901da177e4SLinus Torvalds char c; 22911da177e4SLinus Torvalds if (get_user(c, s)) 22921da177e4SLinus Torvalds return -EFAULT; 22931da177e4SLinus Torvalds if (!isspace(c)) 22941da177e4SLinus Torvalds break; 22951da177e4SLinus Torvalds left--; 22961da177e4SLinus Torvalds s++; 22971da177e4SLinus Torvalds } 22981da177e4SLinus Torvalds if (!left) 22991da177e4SLinus Torvalds break; 23001da177e4SLinus Torvalds neg = 0; 23011da177e4SLinus Torvalds len = left; 23021da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 23031da177e4SLinus Torvalds len = TMPBUFLEN-1; 23041da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 23051da177e4SLinus Torvalds return -EFAULT; 23061da177e4SLinus Torvalds buf[len] = 0; 23071da177e4SLinus Torvalds p = buf; 23081da177e4SLinus Torvalds if (*p == '-' && left > 1) { 23091da177e4SLinus Torvalds neg = 1; 2310bd9b0bacSBP, Praveen p++; 23111da177e4SLinus Torvalds } 23121da177e4SLinus Torvalds if (*p < '0' || *p > '9') 23131da177e4SLinus Torvalds break; 23141da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 23151da177e4SLinus Torvalds len = p-buf; 23161da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 23171da177e4SLinus Torvalds break; 23181da177e4SLinus Torvalds if (neg) 23191da177e4SLinus Torvalds val = -val; 23201da177e4SLinus Torvalds s += len; 23211da177e4SLinus Torvalds left -= len; 23221da177e4SLinus Torvalds 23231da177e4SLinus Torvalds if(neg) 23241da177e4SLinus Torvalds continue; 23251da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 23261da177e4SLinus Torvalds continue; 23271da177e4SLinus Torvalds *i = val; 23281da177e4SLinus Torvalds } else { 23291da177e4SLinus Torvalds p = buf; 23301da177e4SLinus Torvalds if (!first) 23311da177e4SLinus Torvalds *p++ = '\t'; 23321da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 23331da177e4SLinus Torvalds len = strlen(buf); 23341da177e4SLinus Torvalds if (len > left) 23351da177e4SLinus Torvalds len = left; 23361da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 23371da177e4SLinus Torvalds return -EFAULT; 23381da177e4SLinus Torvalds left -= len; 23391da177e4SLinus Torvalds s += len; 23401da177e4SLinus Torvalds } 23411da177e4SLinus Torvalds } 23421da177e4SLinus Torvalds 23431da177e4SLinus Torvalds if (!write && !first && left) { 23441da177e4SLinus Torvalds if(put_user('\n', s)) 23451da177e4SLinus Torvalds return -EFAULT; 23461da177e4SLinus Torvalds left--, s++; 23471da177e4SLinus Torvalds } 23481da177e4SLinus Torvalds if (write) { 23491da177e4SLinus Torvalds while (left) { 23501da177e4SLinus Torvalds char c; 23511da177e4SLinus Torvalds if (get_user(c, s++)) 23521da177e4SLinus Torvalds return -EFAULT; 23531da177e4SLinus Torvalds if (!isspace(c)) 23541da177e4SLinus Torvalds break; 23551da177e4SLinus Torvalds left--; 23561da177e4SLinus Torvalds } 23571da177e4SLinus Torvalds } 23581da177e4SLinus Torvalds if (write && first) 23591da177e4SLinus Torvalds return -EINVAL; 23601da177e4SLinus Torvalds *lenp -= left; 23611da177e4SLinus Torvalds *ppos += *lenp; 23621da177e4SLinus Torvalds return 0; 23631da177e4SLinus Torvalds #undef TMPBUFLEN 23641da177e4SLinus Torvalds } 23651da177e4SLinus Torvalds 2366d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2367fcfbd547SKirill Korotaev struct file *filp, 2368fcfbd547SKirill Korotaev void __user *buffer, 2369fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2370fcfbd547SKirill Korotaev unsigned long convmul, 2371fcfbd547SKirill Korotaev unsigned long convdiv) 2372fcfbd547SKirill Korotaev { 2373fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 2374fcfbd547SKirill Korotaev filp, buffer, lenp, ppos, convmul, convdiv); 2375fcfbd547SKirill Korotaev } 2376fcfbd547SKirill Korotaev 23771da177e4SLinus Torvalds /** 23781da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 23791da177e4SLinus Torvalds * @table: the sysctl table 23801da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23811da177e4SLinus Torvalds * @filp: the file structure 23821da177e4SLinus Torvalds * @buffer: the user buffer 23831da177e4SLinus Torvalds * @lenp: the size of the user buffer 23841da177e4SLinus Torvalds * @ppos: file position 23851da177e4SLinus Torvalds * 23861da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 23871da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23881da177e4SLinus Torvalds * 23891da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 23901da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 23911da177e4SLinus Torvalds * 23921da177e4SLinus Torvalds * Returns 0 on success. 23931da177e4SLinus Torvalds */ 2394d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, 23951da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23961da177e4SLinus Torvalds { 23971da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l); 23981da177e4SLinus Torvalds } 23991da177e4SLinus Torvalds 24001da177e4SLinus Torvalds /** 24011da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 24021da177e4SLinus Torvalds * @table: the sysctl table 24031da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24041da177e4SLinus Torvalds * @filp: the file structure 24051da177e4SLinus Torvalds * @buffer: the user buffer 24061da177e4SLinus Torvalds * @lenp: the size of the user buffer 24071da177e4SLinus Torvalds * @ppos: file position 24081da177e4SLinus Torvalds * 24091da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24101da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 24111da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 24121da177e4SLinus Torvalds * 24131da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24141da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24151da177e4SLinus Torvalds * 24161da177e4SLinus Torvalds * Returns 0 on success. 24171da177e4SLinus Torvalds */ 2418d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 24191da177e4SLinus Torvalds struct file *filp, 24201da177e4SLinus Torvalds void __user *buffer, 24211da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 24221da177e4SLinus Torvalds { 24231da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, 24241da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 24251da177e4SLinus Torvalds } 24261da177e4SLinus Torvalds 24271da177e4SLinus Torvalds 24281da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 24291da177e4SLinus Torvalds int *valp, 24301da177e4SLinus Torvalds int write, void *data) 24311da177e4SLinus Torvalds { 24321da177e4SLinus Torvalds if (write) { 2433cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2434cba9f33dSBart Samwel return 1; 24351da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 24361da177e4SLinus Torvalds } else { 24371da177e4SLinus Torvalds int val = *valp; 24381da177e4SLinus Torvalds unsigned long lval; 24391da177e4SLinus Torvalds if (val < 0) { 24401da177e4SLinus Torvalds *negp = -1; 24411da177e4SLinus Torvalds lval = (unsigned long)-val; 24421da177e4SLinus Torvalds } else { 24431da177e4SLinus Torvalds *negp = 0; 24441da177e4SLinus Torvalds lval = (unsigned long)val; 24451da177e4SLinus Torvalds } 24461da177e4SLinus Torvalds *lvalp = lval / HZ; 24471da177e4SLinus Torvalds } 24481da177e4SLinus Torvalds return 0; 24491da177e4SLinus Torvalds } 24501da177e4SLinus Torvalds 24511da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 24521da177e4SLinus Torvalds int *valp, 24531da177e4SLinus Torvalds int write, void *data) 24541da177e4SLinus Torvalds { 24551da177e4SLinus Torvalds if (write) { 2456cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2457cba9f33dSBart Samwel return 1; 24581da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 24591da177e4SLinus Torvalds } else { 24601da177e4SLinus Torvalds int val = *valp; 24611da177e4SLinus Torvalds unsigned long lval; 24621da177e4SLinus Torvalds if (val < 0) { 24631da177e4SLinus Torvalds *negp = -1; 24641da177e4SLinus Torvalds lval = (unsigned long)-val; 24651da177e4SLinus Torvalds } else { 24661da177e4SLinus Torvalds *negp = 0; 24671da177e4SLinus Torvalds lval = (unsigned long)val; 24681da177e4SLinus Torvalds } 24691da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 24701da177e4SLinus Torvalds } 24711da177e4SLinus Torvalds return 0; 24721da177e4SLinus Torvalds } 24731da177e4SLinus Torvalds 24741da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 24751da177e4SLinus Torvalds int *valp, 24761da177e4SLinus Torvalds int write, void *data) 24771da177e4SLinus Torvalds { 24781da177e4SLinus Torvalds if (write) { 24791da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 24801da177e4SLinus Torvalds } else { 24811da177e4SLinus Torvalds int val = *valp; 24821da177e4SLinus Torvalds unsigned long lval; 24831da177e4SLinus Torvalds if (val < 0) { 24841da177e4SLinus Torvalds *negp = -1; 24851da177e4SLinus Torvalds lval = (unsigned long)-val; 24861da177e4SLinus Torvalds } else { 24871da177e4SLinus Torvalds *negp = 0; 24881da177e4SLinus Torvalds lval = (unsigned long)val; 24891da177e4SLinus Torvalds } 24901da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 24911da177e4SLinus Torvalds } 24921da177e4SLinus Torvalds return 0; 24931da177e4SLinus Torvalds } 24941da177e4SLinus Torvalds 24951da177e4SLinus Torvalds /** 24961da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 24971da177e4SLinus Torvalds * @table: the sysctl table 24981da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24991da177e4SLinus Torvalds * @filp: the file structure 25001da177e4SLinus Torvalds * @buffer: the user buffer 25011da177e4SLinus Torvalds * @lenp: the size of the user buffer 25021da177e4SLinus Torvalds * @ppos: file position 25031da177e4SLinus Torvalds * 25041da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25051da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25061da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 25071da177e4SLinus Torvalds * jiffies. 25081da177e4SLinus Torvalds * 25091da177e4SLinus Torvalds * Returns 0 on success. 25101da177e4SLinus Torvalds */ 2511d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, 25121da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25131da177e4SLinus Torvalds { 25141da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 25151da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 25161da177e4SLinus Torvalds } 25171da177e4SLinus Torvalds 25181da177e4SLinus Torvalds /** 25191da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 25201da177e4SLinus Torvalds * @table: the sysctl table 25211da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25221da177e4SLinus Torvalds * @filp: the file structure 25231da177e4SLinus Torvalds * @buffer: the user buffer 25241da177e4SLinus Torvalds * @lenp: the size of the user buffer 25251e5d5331SRandy Dunlap * @ppos: pointer to the file position 25261da177e4SLinus Torvalds * 25271da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25281da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25291da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 25301da177e4SLinus Torvalds * are converted into jiffies. 25311da177e4SLinus Torvalds * 25321da177e4SLinus Torvalds * Returns 0 on success. 25331da177e4SLinus Torvalds */ 2534d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, 25351da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25361da177e4SLinus Torvalds { 25371da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 25381da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 25391da177e4SLinus Torvalds } 25401da177e4SLinus Torvalds 25411da177e4SLinus Torvalds /** 25421da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 25431da177e4SLinus Torvalds * @table: the sysctl table 25441da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25451da177e4SLinus Torvalds * @filp: the file structure 25461da177e4SLinus Torvalds * @buffer: the user buffer 25471da177e4SLinus Torvalds * @lenp: the size of the user buffer 254867be2dd1SMartin Waitz * @ppos: file position 254967be2dd1SMartin Waitz * @ppos: the current position in the file 25501da177e4SLinus Torvalds * 25511da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25521da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25531da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 25541da177e4SLinus Torvalds * are converted into jiffies. 25551da177e4SLinus Torvalds * 25561da177e4SLinus Torvalds * Returns 0 on success. 25571da177e4SLinus Torvalds */ 2558d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, 25591da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25601da177e4SLinus Torvalds { 25611da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 25621da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 25631da177e4SLinus Torvalds } 25641da177e4SLinus Torvalds 2565d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 25669ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 25679ec52099SCedric Le Goater { 25689ec52099SCedric Le Goater struct pid *new_pid; 25699ec52099SCedric Le Goater pid_t tmp; 25709ec52099SCedric Le Goater int r; 25719ec52099SCedric Le Goater 25726c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 25739ec52099SCedric Le Goater 25749ec52099SCedric Le Goater r = __do_proc_dointvec(&tmp, table, write, filp, buffer, 25759ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 25769ec52099SCedric Le Goater if (r || !write) 25779ec52099SCedric Le Goater return r; 25789ec52099SCedric Le Goater 25799ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 25809ec52099SCedric Le Goater if (!new_pid) 25819ec52099SCedric Le Goater return -ESRCH; 25829ec52099SCedric Le Goater 25839ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 25849ec52099SCedric Le Goater return 0; 25859ec52099SCedric Le Goater } 25869ec52099SCedric Le Goater 25871da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 25881da177e4SLinus Torvalds 2589d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp, 25901da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25911da177e4SLinus Torvalds { 25921da177e4SLinus Torvalds return -ENOSYS; 25931da177e4SLinus Torvalds } 25941da177e4SLinus Torvalds 2595d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp, 25961da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25971da177e4SLinus Torvalds { 25981da177e4SLinus Torvalds return -ENOSYS; 25991da177e4SLinus Torvalds } 26001da177e4SLinus Torvalds 2601d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, 26021da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26031da177e4SLinus Torvalds { 26041da177e4SLinus Torvalds return -ENOSYS; 26051da177e4SLinus Torvalds } 26061da177e4SLinus Torvalds 2607d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, 26081da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26091da177e4SLinus Torvalds { 26101da177e4SLinus Torvalds return -ENOSYS; 26111da177e4SLinus Torvalds } 26121da177e4SLinus Torvalds 2613d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, 26141da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26151da177e4SLinus Torvalds { 26161da177e4SLinus Torvalds return -ENOSYS; 26171da177e4SLinus Torvalds } 26181da177e4SLinus Torvalds 2619d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, 26201da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26211da177e4SLinus Torvalds { 26221da177e4SLinus Torvalds return -ENOSYS; 26231da177e4SLinus Torvalds } 26241da177e4SLinus Torvalds 2625d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, 26261da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26271da177e4SLinus Torvalds { 26281da177e4SLinus Torvalds return -ENOSYS; 26291da177e4SLinus Torvalds } 26301da177e4SLinus Torvalds 2631d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26321da177e4SLinus Torvalds struct file *filp, 26331da177e4SLinus Torvalds void __user *buffer, 26341da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26351da177e4SLinus Torvalds { 26361da177e4SLinus Torvalds return -ENOSYS; 26371da177e4SLinus Torvalds } 26381da177e4SLinus Torvalds 26391da177e4SLinus Torvalds 26401da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 26411da177e4SLinus Torvalds 26421da177e4SLinus Torvalds 2643b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 26441da177e4SLinus Torvalds /* 26451da177e4SLinus Torvalds * General sysctl support routines 26461da177e4SLinus Torvalds */ 26471da177e4SLinus Torvalds 264849a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */ 264949a0c458SEric W. Biederman int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 265049a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 265149a0c458SEric W. Biederman void __user *newval, size_t newlen) 265249a0c458SEric W. Biederman { 265349a0c458SEric W. Biederman size_t len; 265449a0c458SEric W. Biederman 265549a0c458SEric W. Biederman /* Get out of I don't have a variable */ 265649a0c458SEric W. Biederman if (!table->data || !table->maxlen) 265749a0c458SEric W. Biederman return -ENOTDIR; 265849a0c458SEric W. Biederman 265949a0c458SEric W. Biederman if (oldval && oldlenp) { 266049a0c458SEric W. Biederman if (get_user(len, oldlenp)) 266149a0c458SEric W. Biederman return -EFAULT; 266249a0c458SEric W. Biederman if (len) { 266349a0c458SEric W. Biederman if (len > table->maxlen) 266449a0c458SEric W. Biederman len = table->maxlen; 266549a0c458SEric W. Biederman if (copy_to_user(oldval, table->data, len)) 266649a0c458SEric W. Biederman return -EFAULT; 266749a0c458SEric W. Biederman if (put_user(len, oldlenp)) 266849a0c458SEric W. Biederman return -EFAULT; 266949a0c458SEric W. Biederman } 267049a0c458SEric W. Biederman } 267149a0c458SEric W. Biederman 267249a0c458SEric W. Biederman if (newval && newlen) { 267349a0c458SEric W. Biederman if (newlen > table->maxlen) 267449a0c458SEric W. Biederman newlen = table->maxlen; 267549a0c458SEric W. Biederman 267649a0c458SEric W. Biederman if (copy_from_user(table->data, newval, newlen)) 267749a0c458SEric W. Biederman return -EFAULT; 267849a0c458SEric W. Biederman } 267949a0c458SEric W. Biederman return 1; 268049a0c458SEric W. Biederman } 268149a0c458SEric W. Biederman 26821da177e4SLinus Torvalds /* The generic string strategy routine: */ 2683d8217f07SEric W. Biederman int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 26841da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 26851f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 26861da177e4SLinus Torvalds { 26871da177e4SLinus Torvalds if (!table->data || !table->maxlen) 26881da177e4SLinus Torvalds return -ENOTDIR; 26891da177e4SLinus Torvalds 26901da177e4SLinus Torvalds if (oldval && oldlenp) { 2691de9e007dSLinus Torvalds size_t bufsize; 2692de9e007dSLinus Torvalds if (get_user(bufsize, oldlenp)) 26931da177e4SLinus Torvalds return -EFAULT; 2694de9e007dSLinus Torvalds if (bufsize) { 2695de9e007dSLinus Torvalds size_t len = strlen(table->data), copied; 2696de9e007dSLinus Torvalds 2697de9e007dSLinus Torvalds /* This shouldn't trigger for a well-formed sysctl */ 2698de9e007dSLinus Torvalds if (len > table->maxlen) 26991da177e4SLinus Torvalds len = table->maxlen; 2700de9e007dSLinus Torvalds 2701de9e007dSLinus Torvalds /* Copy up to a max of bufsize-1 bytes of the string */ 2702de9e007dSLinus Torvalds copied = (len >= bufsize) ? bufsize - 1 : len; 2703de9e007dSLinus Torvalds 2704de9e007dSLinus Torvalds if (copy_to_user(oldval, table->data, copied) || 2705de9e007dSLinus Torvalds put_user(0, (char __user *)(oldval + copied))) 27061da177e4SLinus Torvalds return -EFAULT; 27071da177e4SLinus Torvalds if (put_user(len, oldlenp)) 27081da177e4SLinus Torvalds return -EFAULT; 27091da177e4SLinus Torvalds } 27101da177e4SLinus Torvalds } 27111da177e4SLinus Torvalds if (newval && newlen) { 2712de9e007dSLinus Torvalds size_t len = newlen; 27131da177e4SLinus Torvalds if (len > table->maxlen) 27141da177e4SLinus Torvalds len = table->maxlen; 27151da177e4SLinus Torvalds if(copy_from_user(table->data, newval, len)) 27161da177e4SLinus Torvalds return -EFAULT; 27171da177e4SLinus Torvalds if (len == table->maxlen) 27181da177e4SLinus Torvalds len--; 27191da177e4SLinus Torvalds ((char *) table->data)[len] = 0; 27201da177e4SLinus Torvalds } 272182c9df82SYi Yang return 1; 27221da177e4SLinus Torvalds } 27231da177e4SLinus Torvalds 27241da177e4SLinus Torvalds /* 27251da177e4SLinus Torvalds * This function makes sure that all of the integers in the vector 27261da177e4SLinus Torvalds * are between the minimum and maximum values given in the arrays 27271da177e4SLinus Torvalds * table->extra1 and table->extra2, respectively. 27281da177e4SLinus Torvalds */ 2729d8217f07SEric W. Biederman int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 27301da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 27311f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 27321da177e4SLinus Torvalds { 27331da177e4SLinus Torvalds 27341da177e4SLinus Torvalds if (newval && newlen) { 27351da177e4SLinus Torvalds int __user *vec = (int __user *) newval; 27361da177e4SLinus Torvalds int *min = (int *) table->extra1; 27371da177e4SLinus Torvalds int *max = (int *) table->extra2; 27381da177e4SLinus Torvalds size_t length; 27391da177e4SLinus Torvalds int i; 27401da177e4SLinus Torvalds 27411da177e4SLinus Torvalds if (newlen % sizeof(int) != 0) 27421da177e4SLinus Torvalds return -EINVAL; 27431da177e4SLinus Torvalds 27441da177e4SLinus Torvalds if (!table->extra1 && !table->extra2) 27451da177e4SLinus Torvalds return 0; 27461da177e4SLinus Torvalds 27471da177e4SLinus Torvalds if (newlen > table->maxlen) 27481da177e4SLinus Torvalds newlen = table->maxlen; 27491da177e4SLinus Torvalds length = newlen / sizeof(int); 27501da177e4SLinus Torvalds 27511da177e4SLinus Torvalds for (i = 0; i < length; i++) { 27521da177e4SLinus Torvalds int value; 27531da177e4SLinus Torvalds if (get_user(value, vec + i)) 27541da177e4SLinus Torvalds return -EFAULT; 27551da177e4SLinus Torvalds if (min && value < min[i]) 27561da177e4SLinus Torvalds return -EINVAL; 27571da177e4SLinus Torvalds if (max && value > max[i]) 27581da177e4SLinus Torvalds return -EINVAL; 27591da177e4SLinus Torvalds } 27601da177e4SLinus Torvalds } 27611da177e4SLinus Torvalds return 0; 27621da177e4SLinus Torvalds } 27631da177e4SLinus Torvalds 27641da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 2765d8217f07SEric W. Biederman int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 27661da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 27671f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 27681da177e4SLinus Torvalds { 27693ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 27701da177e4SLinus Torvalds size_t olen; 27713ee75ac3SAlexey Dobriyan 27721da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 27731da177e4SLinus Torvalds return -EFAULT; 27743ee75ac3SAlexey Dobriyan if (olen) { 27753ee75ac3SAlexey Dobriyan int val; 27763ee75ac3SAlexey Dobriyan 27773ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 27781da177e4SLinus Torvalds return -EINVAL; 27793ee75ac3SAlexey Dobriyan 27803ee75ac3SAlexey Dobriyan val = *(int *)(table->data) / HZ; 27813ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 27821da177e4SLinus Torvalds return -EFAULT; 27833ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 27843ee75ac3SAlexey Dobriyan return -EFAULT; 27853ee75ac3SAlexey Dobriyan } 27861da177e4SLinus Torvalds } 27871da177e4SLinus Torvalds if (newval && newlen) { 27881da177e4SLinus Torvalds int new; 27891da177e4SLinus Torvalds if (newlen != sizeof(int)) 27901da177e4SLinus Torvalds return -EINVAL; 27911da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 27921da177e4SLinus Torvalds return -EFAULT; 27931da177e4SLinus Torvalds *(int *)(table->data) = new*HZ; 27941da177e4SLinus Torvalds } 27951da177e4SLinus Torvalds return 1; 27961da177e4SLinus Torvalds } 27971da177e4SLinus Torvalds 27981da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 2799d8217f07SEric W. Biederman int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 28001da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 28011f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 28021da177e4SLinus Torvalds { 28033ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 28041da177e4SLinus Torvalds size_t olen; 28053ee75ac3SAlexey Dobriyan 28061da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 28071da177e4SLinus Torvalds return -EFAULT; 28083ee75ac3SAlexey Dobriyan if (olen) { 28093ee75ac3SAlexey Dobriyan int val; 28103ee75ac3SAlexey Dobriyan 28113ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 28121da177e4SLinus Torvalds return -EINVAL; 28133ee75ac3SAlexey Dobriyan 28143ee75ac3SAlexey Dobriyan val = jiffies_to_msecs(*(int *)(table->data)); 28153ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 28161da177e4SLinus Torvalds return -EFAULT; 28173ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 28183ee75ac3SAlexey Dobriyan return -EFAULT; 28193ee75ac3SAlexey Dobriyan } 28201da177e4SLinus Torvalds } 28211da177e4SLinus Torvalds if (newval && newlen) { 28221da177e4SLinus Torvalds int new; 28231da177e4SLinus Torvalds if (newlen != sizeof(int)) 28241da177e4SLinus Torvalds return -EINVAL; 28251da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 28261da177e4SLinus Torvalds return -EFAULT; 28271da177e4SLinus Torvalds *(int *)(table->data) = msecs_to_jiffies(new); 28281da177e4SLinus Torvalds } 28291da177e4SLinus Torvalds return 1; 28301da177e4SLinus Torvalds } 28311da177e4SLinus Torvalds 2832c4b8b769SEric W. Biederman 2833c4b8b769SEric W. Biederman 2834b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */ 28351da177e4SLinus Torvalds 28361da177e4SLinus Torvalds 28371da177e4SLinus Torvalds asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 28381da177e4SLinus Torvalds { 28390e009be8SEric W. Biederman struct __sysctl_args tmp; 28407058cb02SEric W. Biederman int error; 28410e009be8SEric W. Biederman 28420e009be8SEric W. Biederman if (copy_from_user(&tmp, args, sizeof(tmp))) 28430e009be8SEric W. Biederman return -EFAULT; 28440e009be8SEric W. Biederman 28457058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 2846b89a8171SEric W. Biederman 28477058cb02SEric W. Biederman /* If no error reading the parameters then just -ENOSYS ... */ 28487058cb02SEric W. Biederman if (!error) 28497058cb02SEric W. Biederman error = -ENOSYS; 28507058cb02SEric W. Biederman 28517058cb02SEric W. Biederman return error; 28521da177e4SLinus Torvalds } 28531da177e4SLinus Torvalds 285449a0c458SEric W. Biederman int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 285549a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 285649a0c458SEric W. Biederman void __user *newval, size_t newlen) 285749a0c458SEric W. Biederman { 285849a0c458SEric W. Biederman return -ENOSYS; 285949a0c458SEric W. Biederman } 286049a0c458SEric W. Biederman 2861d8217f07SEric W. Biederman int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 28621da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 28631f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 28641da177e4SLinus Torvalds { 28651da177e4SLinus Torvalds return -ENOSYS; 28661da177e4SLinus Torvalds } 28671da177e4SLinus Torvalds 2868d8217f07SEric W. Biederman int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 28691da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 28701f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 28711da177e4SLinus Torvalds { 28721da177e4SLinus Torvalds return -ENOSYS; 28731da177e4SLinus Torvalds } 28741da177e4SLinus Torvalds 2875d8217f07SEric W. Biederman int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 28761da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 28771f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 28781da177e4SLinus Torvalds { 28791da177e4SLinus Torvalds return -ENOSYS; 28801da177e4SLinus Torvalds } 28811da177e4SLinus Torvalds 2882d8217f07SEric W. Biederman int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 28831da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 28841f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 28851da177e4SLinus Torvalds { 28861da177e4SLinus Torvalds return -ENOSYS; 28871da177e4SLinus Torvalds } 28881da177e4SLinus Torvalds 2889b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 28901da177e4SLinus Torvalds 28917058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args) 28927058cb02SEric W. Biederman { 28937058cb02SEric W. Biederman static int msg_count; 28947058cb02SEric W. Biederman int name[CTL_MAXNAME]; 28957058cb02SEric W. Biederman int i; 28967058cb02SEric W. Biederman 28976fc48af8STetsuo Handa /* Check args->nlen. */ 28986fc48af8STetsuo Handa if (args->nlen < 0 || args->nlen > CTL_MAXNAME) 28996fc48af8STetsuo Handa return -ENOTDIR; 29006fc48af8STetsuo Handa 29017058cb02SEric W. Biederman /* Read in the sysctl name for better debug message logging */ 29027058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 29037058cb02SEric W. Biederman if (get_user(name[i], args->name + i)) 29047058cb02SEric W. Biederman return -EFAULT; 29057058cb02SEric W. Biederman 29067058cb02SEric W. Biederman /* Ignore accesses to kernel.version */ 29077058cb02SEric W. Biederman if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION)) 29087058cb02SEric W. Biederman return 0; 29097058cb02SEric W. Biederman 29107058cb02SEric W. Biederman if (msg_count < 5) { 29117058cb02SEric W. Biederman msg_count++; 29127058cb02SEric W. Biederman printk(KERN_INFO 29137058cb02SEric W. Biederman "warning: process `%s' used the deprecated sysctl " 29147058cb02SEric W. Biederman "system call with ", current->comm); 29157058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 29167058cb02SEric W. Biederman printk("%d.", name[i]); 29177058cb02SEric W. Biederman printk("\n"); 29187058cb02SEric W. Biederman } 29197058cb02SEric W. Biederman return 0; 29207058cb02SEric W. Biederman } 29217058cb02SEric W. Biederman 29221da177e4SLinus Torvalds /* 29231da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 29241da177e4SLinus Torvalds * exception granted :-) 29251da177e4SLinus Torvalds */ 29261da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 29271da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 29281da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 29291da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 29301da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 29311da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 29321da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 29331da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 29341da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 293529e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 29361da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec); 29371da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies); 29381da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies); 29391da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string); 294049a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data); 29411da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2942