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> 5112e22c5eSDavid Howells #include <linux/slow-work.h> 521da177e4SLinus Torvalds 531da177e4SLinus Torvalds #include <asm/uaccess.h> 541da177e4SLinus Torvalds #include <asm/processor.h> 551da177e4SLinus Torvalds 5629cbc78bSAndi Kleen #ifdef CONFIG_X86 5729cbc78bSAndi Kleen #include <asm/nmi.h> 580741f4d2SChuck Ebbert #include <asm/stacktrace.h> 596e7c4025SIngo Molnar #include <asm/io.h> 6029cbc78bSAndi Kleen #endif 6129cbc78bSAndi Kleen 627058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args); 637058cb02SEric W. Biederman 641da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds /* External variables not in a header file. */ 671da177e4SLinus Torvalds extern int C_A_D; 6845807a1dSIngo Molnar extern int print_fatal_signals; 691da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 701da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 71fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom; 72fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task; 73fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks; 741da177e4SLinus Torvalds extern int max_threads; 751da177e4SLinus Torvalds extern int core_uses_pid; 76d6e71144SAlan Cox extern int suid_dumpable; 771da177e4SLinus Torvalds extern char core_pattern[]; 781da177e4SLinus Torvalds extern int pid_max; 791da177e4SLinus Torvalds extern int min_free_kbytes; 801da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 819d0243bcSAndrew Morton extern int sysctl_drop_caches; 828ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 83bebfa101SAndi Kleen extern int compat_log; 849745512cSArjan van de Ven extern int latencytop_enabled; 85eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 86dd8632a1SPaul Mundt #ifndef CONFIG_MMU 87dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 88dd8632a1SPaul Mundt #endif 8931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 9031a72bceSPaul E. McKenney extern int rcutorture_runnable; 9131a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 921da177e4SLinus Torvalds 93c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 94195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 95c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 969383d967SDimitri Sivanich static int neg_one = -1; 97c4f3b63fSRavikiran G Thirumalai #endif 98c4f3b63fSRavikiran G Thirumalai 99c4f3b63fSRavikiran G Thirumalai static int zero; 100cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 101cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 102fc3501d4SSven Wegener static unsigned long one_ul = 1; 103c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 104fafd688eSPeter W Morreale static int one_thousand = 1000; 105c4f3b63fSRavikiran G Thirumalai 106*9e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 107*9e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 108*9e4a5bdaSAndrea Righi 1091da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1101da177e4SLinus Torvalds static int maxolduid = 65535; 1111da177e4SLinus Torvalds static int minolduid; 1128ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1131da177e4SLinus Torvalds 1141da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1151da177e4SLinus Torvalds 116a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 1171da177e4SLinus Torvalds extern char modprobe_path[]; 1181da177e4SLinus Torvalds #endif 1191da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 1201da177e4SLinus Torvalds extern int sg_big_buff; 1211da177e4SLinus Torvalds #endif 1221da177e4SLinus Torvalds 12372c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 12417f04fbbSDavid S. Miller #include <asm/system.h> 1251da177e4SLinus Torvalds #endif 1261da177e4SLinus Torvalds 1270871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1280871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1290871420fSDavid S. Miller #endif 1300871420fSDavid S. Miller 1311da177e4SLinus Torvalds #ifdef __hppa__ 1321da177e4SLinus Torvalds extern int pwrsw_enabled; 1331da177e4SLinus Torvalds extern int unaligned_enabled; 1341da177e4SLinus Torvalds #endif 1351da177e4SLinus Torvalds 136347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1371da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1381da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1391da177e4SLinus Torvalds #endif 1401da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 141951f22d5SMartin Schwidefsky extern int spin_retry; 1421da177e4SLinus Torvalds #endif 1431da177e4SLinus Torvalds 1441da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1451da177e4SLinus Torvalds extern int acct_parm[]; 1461da177e4SLinus Torvalds #endif 1471da177e4SLinus Torvalds 148d2b176edSJes Sorensen #ifdef CONFIG_IA64 149d2b176edSJes Sorensen extern int no_unaligned_warning; 15088fc241fSDoug Chapman extern int unaligned_dump_stack; 151d2b176edSJes Sorensen #endif 152d2b176edSJes Sorensen 15323f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 15423f78d4aSIngo Molnar extern int max_lock_depth; 15523f78d4aSIngo Molnar #endif 15623f78d4aSIngo Molnar 157d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 158d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 1599ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 16025ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp, 16134f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 162d6f8ff73SRandy Dunlap #endif 1639ec52099SCedric Le Goater 164d8217f07SEric W. Biederman static struct ctl_table root_table[]; 165e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 166e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 167b380b0d4SAl Viro .count = 1, 168e51b6ba0SEric W. Biederman .ctl_table = root_table, 16973455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 170e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 17173455092SAl Viro .set = &sysctl_table_root.default_set, 172e51b6ba0SEric W. Biederman }; 173e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 174e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 17573455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 176e51b6ba0SEric W. Biederman }; 1771da177e4SLinus Torvalds 178d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 179d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 180d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 181d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 182d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 183d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1842d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 185d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1860399cb08SRobert Love #endif 1877ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 1887ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 1897ef9964eSDavide Libenzi #endif 1901da177e4SLinus Torvalds 1911da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 1921da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1931da177e4SLinus Torvalds #endif 1941da177e4SLinus Torvalds 195f20786ffSPeter Zijlstra extern int prove_locking; 196f20786ffSPeter Zijlstra extern int lock_stat; 1979bc9a6bdSEric W. Biederman 1981da177e4SLinus Torvalds /* The default sysctl tables: */ 1991da177e4SLinus Torvalds 200d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2011da177e4SLinus Torvalds { 2021da177e4SLinus Torvalds .ctl_name = CTL_KERN, 2031da177e4SLinus Torvalds .procname = "kernel", 2041da177e4SLinus Torvalds .mode = 0555, 2051da177e4SLinus Torvalds .child = kern_table, 2061da177e4SLinus Torvalds }, 2071da177e4SLinus Torvalds { 2081da177e4SLinus Torvalds .ctl_name = CTL_VM, 2091da177e4SLinus Torvalds .procname = "vm", 2101da177e4SLinus Torvalds .mode = 0555, 2111da177e4SLinus Torvalds .child = vm_table, 2121da177e4SLinus Torvalds }, 2131da177e4SLinus Torvalds { 2141da177e4SLinus Torvalds .ctl_name = CTL_FS, 2151da177e4SLinus Torvalds .procname = "fs", 2161da177e4SLinus Torvalds .mode = 0555, 2171da177e4SLinus Torvalds .child = fs_table, 2181da177e4SLinus Torvalds }, 2191da177e4SLinus Torvalds { 2201da177e4SLinus Torvalds .ctl_name = CTL_DEBUG, 2211da177e4SLinus Torvalds .procname = "debug", 2221da177e4SLinus Torvalds .mode = 0555, 2231da177e4SLinus Torvalds .child = debug_table, 2241da177e4SLinus Torvalds }, 2251da177e4SLinus Torvalds { 2261da177e4SLinus Torvalds .ctl_name = CTL_DEV, 2271da177e4SLinus Torvalds .procname = "dev", 2281da177e4SLinus Torvalds .mode = 0555, 2291da177e4SLinus Torvalds .child = dev_table, 2301da177e4SLinus Torvalds }, 2312be7fe07SAndrew Morton /* 2322be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2332be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2342be7fe07SAndrew Morton */ 2351da177e4SLinus Torvalds { .ctl_name = 0 } 2361da177e4SLinus Torvalds }; 2371da177e4SLinus Torvalds 23877e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 23973c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 24073c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 24173c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 24273c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 24377e54a1fSIngo Molnar #endif 24477e54a1fSIngo Molnar 245d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 24677e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 24777e54a1fSIngo Molnar { 24877e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 249b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 250b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 25177e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 25277e54a1fSIngo Molnar .mode = 0644, 253b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 254b2be5e96SPeter Zijlstra .strategy = &sysctl_intvec, 255b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 256b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 25777e54a1fSIngo Molnar }, 25877e54a1fSIngo Molnar { 25977e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 26021805085SPeter Zijlstra .procname = "sched_latency_ns", 26121805085SPeter Zijlstra .data = &sysctl_sched_latency, 26221805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 26321805085SPeter Zijlstra .mode = 0644, 264b2be5e96SPeter Zijlstra .proc_handler = &sched_nr_latency_handler, 26521805085SPeter Zijlstra .strategy = &sysctl_intvec, 26621805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 26721805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 26821805085SPeter Zijlstra }, 26921805085SPeter Zijlstra { 27021805085SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 27177e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 27277e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 27377e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 27477e54a1fSIngo Molnar .mode = 0644, 27577e54a1fSIngo Molnar .proc_handler = &proc_dointvec_minmax, 27677e54a1fSIngo Molnar .strategy = &sysctl_intvec, 27777e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 27877e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 27977e54a1fSIngo Molnar }, 28077e54a1fSIngo Molnar { 28177e54a1fSIngo Molnar .ctl_name = CTL_UNNUMBERED, 2822398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 2832398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 2842398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 2852398f2c6SPeter Zijlstra .mode = 0644, 2862398f2c6SPeter Zijlstra .proc_handler = &proc_dointvec, 2872398f2c6SPeter Zijlstra }, 2882398f2c6SPeter Zijlstra { 2892398f2c6SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 290ffda12a1SPeter Zijlstra .procname = "sched_shares_thresh", 291ffda12a1SPeter Zijlstra .data = &sysctl_sched_shares_thresh, 292ffda12a1SPeter Zijlstra .maxlen = sizeof(unsigned int), 293ffda12a1SPeter Zijlstra .mode = 0644, 294ffda12a1SPeter Zijlstra .proc_handler = &proc_dointvec_minmax, 295ffda12a1SPeter Zijlstra .strategy = &sysctl_intvec, 296ffda12a1SPeter Zijlstra .extra1 = &zero, 297ffda12a1SPeter Zijlstra }, 298ffda12a1SPeter Zijlstra { 299ffda12a1SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 30077e54a1fSIngo Molnar .procname = "sched_child_runs_first", 30177e54a1fSIngo Molnar .data = &sysctl_sched_child_runs_first, 30277e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 30377e54a1fSIngo Molnar .mode = 0644, 30477e54a1fSIngo Molnar .proc_handler = &proc_dointvec, 30577e54a1fSIngo Molnar }, 3061fc84aaaSPeter Zijlstra { 3071fc84aaaSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3081fc84aaaSPeter Zijlstra .procname = "sched_features", 3091fc84aaaSPeter Zijlstra .data = &sysctl_sched_features, 3101fc84aaaSPeter Zijlstra .maxlen = sizeof(unsigned int), 3111fc84aaaSPeter Zijlstra .mode = 0644, 3121fc84aaaSPeter Zijlstra .proc_handler = &proc_dointvec, 3131fc84aaaSPeter Zijlstra }, 314da84d961SIngo Molnar { 315da84d961SIngo Molnar .ctl_name = CTL_UNNUMBERED, 316da84d961SIngo Molnar .procname = "sched_migration_cost", 317da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 318da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 319da84d961SIngo Molnar .mode = 0644, 320da84d961SIngo Molnar .proc_handler = &proc_dointvec, 321da84d961SIngo Molnar }, 322b82d9fddSPeter Zijlstra { 323b82d9fddSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 324b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 325b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 326b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 327fa85ae24SPeter Zijlstra .mode = 0644, 328fa85ae24SPeter Zijlstra .proc_handler = &proc_dointvec, 329fa85ae24SPeter Zijlstra }, 3301fc84aaaSPeter Zijlstra #endif 3311799e35dSIngo Molnar { 3321799e35dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 3339f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3349f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3359f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3369f0c1e56SPeter Zijlstra .mode = 0644, 337d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3389f0c1e56SPeter Zijlstra }, 3399f0c1e56SPeter Zijlstra { 3409f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3419f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3429f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3439f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3449f0c1e56SPeter Zijlstra .mode = 0644, 345d0b27fa7SPeter Zijlstra .proc_handler = &sched_rt_handler, 3469f0c1e56SPeter Zijlstra }, 3479f0c1e56SPeter Zijlstra { 3489f0c1e56SPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 3491799e35dSIngo Molnar .procname = "sched_compat_yield", 3501799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3511799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3521799e35dSIngo Molnar .mode = 0644, 3531799e35dSIngo Molnar .proc_handler = &proc_dointvec, 3541799e35dSIngo Molnar }, 355f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 356f20786ffSPeter Zijlstra { 357f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 358f20786ffSPeter Zijlstra .procname = "prove_locking", 359f20786ffSPeter Zijlstra .data = &prove_locking, 360f20786ffSPeter Zijlstra .maxlen = sizeof(int), 361f20786ffSPeter Zijlstra .mode = 0644, 362f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 363f20786ffSPeter Zijlstra }, 364f20786ffSPeter Zijlstra #endif 365f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 366f20786ffSPeter Zijlstra { 367f20786ffSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 368f20786ffSPeter Zijlstra .procname = "lock_stat", 369f20786ffSPeter Zijlstra .data = &lock_stat, 370f20786ffSPeter Zijlstra .maxlen = sizeof(int), 371f20786ffSPeter Zijlstra .mode = 0644, 372f20786ffSPeter Zijlstra .proc_handler = &proc_dointvec, 373f20786ffSPeter Zijlstra }, 374f20786ffSPeter Zijlstra #endif 37577e54a1fSIngo Molnar { 3761da177e4SLinus Torvalds .ctl_name = KERN_PANIC, 3771da177e4SLinus Torvalds .procname = "panic", 3781da177e4SLinus Torvalds .data = &panic_timeout, 3791da177e4SLinus Torvalds .maxlen = sizeof(int), 3801da177e4SLinus Torvalds .mode = 0644, 3811da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3821da177e4SLinus Torvalds }, 3831da177e4SLinus Torvalds { 3841da177e4SLinus Torvalds .ctl_name = KERN_CORE_USES_PID, 3851da177e4SLinus Torvalds .procname = "core_uses_pid", 3861da177e4SLinus Torvalds .data = &core_uses_pid, 3871da177e4SLinus Torvalds .maxlen = sizeof(int), 3881da177e4SLinus Torvalds .mode = 0644, 3891da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3901da177e4SLinus Torvalds }, 3911da177e4SLinus Torvalds { 3921da177e4SLinus Torvalds .ctl_name = KERN_CORE_PATTERN, 3931da177e4SLinus Torvalds .procname = "core_pattern", 3941da177e4SLinus Torvalds .data = core_pattern, 39571ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 3961da177e4SLinus Torvalds .mode = 0644, 3971da177e4SLinus Torvalds .proc_handler = &proc_dostring, 3981da177e4SLinus Torvalds .strategy = &sysctl_string, 3991da177e4SLinus Torvalds }, 40034f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4011da177e4SLinus Torvalds { 4021da177e4SLinus Torvalds .procname = "tainted", 40325ddbb18SAndi Kleen .maxlen = sizeof(long), 40434f5a398STheodore Ts'o .mode = 0644, 40525ddbb18SAndi Kleen .proc_handler = &proc_taint, 4061da177e4SLinus Torvalds }, 40734f5a398STheodore Ts'o #endif 4089745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4099745512cSArjan van de Ven { 4109745512cSArjan van de Ven .procname = "latencytop", 4119745512cSArjan van de Ven .data = &latencytop_enabled, 4129745512cSArjan van de Ven .maxlen = sizeof(int), 4139745512cSArjan van de Ven .mode = 0644, 4149745512cSArjan van de Ven .proc_handler = &proc_dointvec, 4159745512cSArjan van de Ven }, 4169745512cSArjan van de Ven #endif 4171da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4181da177e4SLinus Torvalds { 4191da177e4SLinus Torvalds .ctl_name = KERN_REALROOTDEV, 4201da177e4SLinus Torvalds .procname = "real-root-dev", 4211da177e4SLinus Torvalds .data = &real_root_dev, 4221da177e4SLinus Torvalds .maxlen = sizeof(int), 4231da177e4SLinus Torvalds .mode = 0644, 4241da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4251da177e4SLinus Torvalds }, 4261da177e4SLinus Torvalds #endif 42745807a1dSIngo Molnar { 42845807a1dSIngo Molnar .ctl_name = CTL_UNNUMBERED, 42945807a1dSIngo Molnar .procname = "print-fatal-signals", 43045807a1dSIngo Molnar .data = &print_fatal_signals, 43145807a1dSIngo Molnar .maxlen = sizeof(int), 43245807a1dSIngo Molnar .mode = 0644, 43345807a1dSIngo Molnar .proc_handler = &proc_dointvec, 43445807a1dSIngo Molnar }, 43572c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4361da177e4SLinus Torvalds { 4371da177e4SLinus Torvalds .ctl_name = KERN_SPARC_REBOOT, 4381da177e4SLinus Torvalds .procname = "reboot-cmd", 4391da177e4SLinus Torvalds .data = reboot_command, 4401da177e4SLinus Torvalds .maxlen = 256, 4411da177e4SLinus Torvalds .mode = 0644, 4421da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4431da177e4SLinus Torvalds .strategy = &sysctl_string, 4441da177e4SLinus Torvalds }, 4451da177e4SLinus Torvalds { 4461da177e4SLinus Torvalds .ctl_name = KERN_SPARC_STOP_A, 4471da177e4SLinus Torvalds .procname = "stop-a", 4481da177e4SLinus Torvalds .data = &stop_a_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_SPARC_SCONS_PWROFF, 4551da177e4SLinus Torvalds .procname = "scons-poweroff", 4561da177e4SLinus Torvalds .data = &scons_pwroff, 4571da177e4SLinus Torvalds .maxlen = sizeof (int), 4581da177e4SLinus Torvalds .mode = 0644, 4591da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4601da177e4SLinus Torvalds }, 4611da177e4SLinus Torvalds #endif 4620871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4630871420fSDavid S. Miller { 4640871420fSDavid S. Miller .ctl_name = CTL_UNNUMBERED, 4650871420fSDavid S. Miller .procname = "tsb-ratio", 4660871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4670871420fSDavid S. Miller .maxlen = sizeof (int), 4680871420fSDavid S. Miller .mode = 0644, 4690871420fSDavid S. Miller .proc_handler = &proc_dointvec, 4700871420fSDavid S. Miller }, 4710871420fSDavid S. Miller #endif 4721da177e4SLinus Torvalds #ifdef __hppa__ 4731da177e4SLinus Torvalds { 4741da177e4SLinus Torvalds .ctl_name = KERN_HPPA_PWRSW, 4751da177e4SLinus Torvalds .procname = "soft-power", 4761da177e4SLinus Torvalds .data = &pwrsw_enabled, 4771da177e4SLinus Torvalds .maxlen = sizeof (int), 4781da177e4SLinus Torvalds .mode = 0644, 4791da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4801da177e4SLinus Torvalds }, 4811da177e4SLinus Torvalds { 4821da177e4SLinus Torvalds .ctl_name = KERN_HPPA_UNALIGNED, 4831da177e4SLinus Torvalds .procname = "unaligned-trap", 4841da177e4SLinus Torvalds .data = &unaligned_enabled, 4851da177e4SLinus Torvalds .maxlen = sizeof (int), 4861da177e4SLinus Torvalds .mode = 0644, 4871da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4881da177e4SLinus Torvalds }, 4891da177e4SLinus Torvalds #endif 4901da177e4SLinus Torvalds { 4911da177e4SLinus Torvalds .ctl_name = KERN_CTLALTDEL, 4921da177e4SLinus Torvalds .procname = "ctrl-alt-del", 4931da177e4SLinus Torvalds .data = &C_A_D, 4941da177e4SLinus Torvalds .maxlen = sizeof(int), 4951da177e4SLinus Torvalds .mode = 0644, 4961da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4971da177e4SLinus Torvalds }, 498606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 499b0fc494fSSteven Rostedt { 500b0fc494fSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 501b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 502b0fc494fSSteven Rostedt .data = &ftrace_enabled, 503b0fc494fSSteven Rostedt .maxlen = sizeof(int), 504b0fc494fSSteven Rostedt .mode = 0644, 505b0fc494fSSteven Rostedt .proc_handler = &ftrace_enable_sysctl, 506b0fc494fSSteven Rostedt }, 507b0fc494fSSteven Rostedt #endif 508f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 509f38f1d2aSSteven Rostedt { 510f38f1d2aSSteven Rostedt .ctl_name = CTL_UNNUMBERED, 511f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 512f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 513f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 514f38f1d2aSSteven Rostedt .mode = 0644, 515f38f1d2aSSteven Rostedt .proc_handler = &stack_trace_sysctl, 516f38f1d2aSSteven Rostedt }, 517f38f1d2aSSteven Rostedt #endif 518944ac425SSteven Rostedt #ifdef CONFIG_TRACING 519944ac425SSteven Rostedt { 520944ac425SSteven Rostedt .ctl_name = CTL_UNNUMBERED, 5213299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 522944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 523944ac425SSteven Rostedt .maxlen = sizeof(int), 524944ac425SSteven Rostedt .mode = 0644, 525944ac425SSteven Rostedt .proc_handler = &proc_dointvec, 526944ac425SSteven Rostedt }, 527944ac425SSteven Rostedt #endif 528a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5291da177e4SLinus Torvalds { 5301da177e4SLinus Torvalds .ctl_name = KERN_MODPROBE, 5311da177e4SLinus Torvalds .procname = "modprobe", 5321da177e4SLinus Torvalds .data = &modprobe_path, 5331da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5341da177e4SLinus Torvalds .mode = 0644, 5351da177e4SLinus Torvalds .proc_handler = &proc_dostring, 5361da177e4SLinus Torvalds .strategy = &sysctl_string, 5371da177e4SLinus Torvalds }, 5381da177e4SLinus Torvalds #endif 53957ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 5401da177e4SLinus Torvalds { 5411da177e4SLinus Torvalds .ctl_name = KERN_HOTPLUG, 5421da177e4SLinus Torvalds .procname = "hotplug", 543312c004dSKay Sievers .data = &uevent_helper, 544312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5451da177e4SLinus Torvalds .mode = 0644, 5461da177e4SLinus Torvalds .proc_handler = &proc_dostring, 5471da177e4SLinus Torvalds .strategy = &sysctl_string, 5481da177e4SLinus Torvalds }, 5491da177e4SLinus Torvalds #endif 5501da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5511da177e4SLinus Torvalds { 5521da177e4SLinus Torvalds .ctl_name = KERN_SG_BIG_BUFF, 5531da177e4SLinus Torvalds .procname = "sg-big-buff", 5541da177e4SLinus Torvalds .data = &sg_big_buff, 5551da177e4SLinus Torvalds .maxlen = sizeof (int), 5561da177e4SLinus Torvalds .mode = 0444, 5571da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5581da177e4SLinus Torvalds }, 5591da177e4SLinus Torvalds #endif 5601da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5611da177e4SLinus Torvalds { 5621da177e4SLinus Torvalds .ctl_name = KERN_ACCT, 5631da177e4SLinus Torvalds .procname = "acct", 5641da177e4SLinus Torvalds .data = &acct_parm, 5651da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5661da177e4SLinus Torvalds .mode = 0644, 5671da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5681da177e4SLinus Torvalds }, 5691da177e4SLinus Torvalds #endif 5701da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5711da177e4SLinus Torvalds { 5721da177e4SLinus Torvalds .ctl_name = KERN_SYSRQ, 5731da177e4SLinus Torvalds .procname = "sysrq", 5745d6f647fSIngo Molnar .data = &__sysrq_enabled, 5751da177e4SLinus Torvalds .maxlen = sizeof (int), 5761da177e4SLinus Torvalds .mode = 0644, 5771da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5781da177e4SLinus Torvalds }, 5791da177e4SLinus Torvalds #endif 580d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5811da177e4SLinus Torvalds { 5821da177e4SLinus Torvalds .procname = "cad_pid", 5839ec52099SCedric Le Goater .data = NULL, 5841da177e4SLinus Torvalds .maxlen = sizeof (int), 5851da177e4SLinus Torvalds .mode = 0600, 5869ec52099SCedric Le Goater .proc_handler = &proc_do_cad_pid, 5871da177e4SLinus Torvalds }, 588d6f8ff73SRandy Dunlap #endif 5891da177e4SLinus Torvalds { 5901da177e4SLinus Torvalds .ctl_name = KERN_MAX_THREADS, 5911da177e4SLinus Torvalds .procname = "threads-max", 5921da177e4SLinus Torvalds .data = &max_threads, 5931da177e4SLinus Torvalds .maxlen = sizeof(int), 5941da177e4SLinus Torvalds .mode = 0644, 5951da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5961da177e4SLinus Torvalds }, 5971da177e4SLinus Torvalds { 5981da177e4SLinus Torvalds .ctl_name = KERN_RANDOM, 5991da177e4SLinus Torvalds .procname = "random", 6001da177e4SLinus Torvalds .mode = 0555, 6011da177e4SLinus Torvalds .child = random_table, 6021da177e4SLinus Torvalds }, 6031da177e4SLinus Torvalds { 6041da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWUID, 6051da177e4SLinus Torvalds .procname = "overflowuid", 6061da177e4SLinus Torvalds .data = &overflowuid, 6071da177e4SLinus Torvalds .maxlen = sizeof(int), 6081da177e4SLinus Torvalds .mode = 0644, 6091da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6101da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6111da177e4SLinus Torvalds .extra1 = &minolduid, 6121da177e4SLinus Torvalds .extra2 = &maxolduid, 6131da177e4SLinus Torvalds }, 6141da177e4SLinus Torvalds { 6151da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWGID, 6161da177e4SLinus Torvalds .procname = "overflowgid", 6171da177e4SLinus Torvalds .data = &overflowgid, 6181da177e4SLinus Torvalds .maxlen = sizeof(int), 6191da177e4SLinus Torvalds .mode = 0644, 6201da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6211da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6221da177e4SLinus Torvalds .extra1 = &minolduid, 6231da177e4SLinus Torvalds .extra2 = &maxolduid, 6241da177e4SLinus Torvalds }, 625347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6261da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6271da177e4SLinus Torvalds { 6281da177e4SLinus Torvalds .ctl_name = KERN_IEEE_EMULATION_WARNINGS, 6291da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6301da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6311da177e4SLinus Torvalds .maxlen = sizeof(int), 6321da177e4SLinus Torvalds .mode = 0644, 6331da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6341da177e4SLinus Torvalds }, 6351da177e4SLinus Torvalds #endif 6361da177e4SLinus Torvalds { 6371da177e4SLinus Torvalds .ctl_name = KERN_S390_USER_DEBUG_LOGGING, 6381da177e4SLinus Torvalds .procname = "userprocess_debug", 6391da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 6401da177e4SLinus Torvalds .maxlen = sizeof(int), 6411da177e4SLinus Torvalds .mode = 0644, 6421da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6431da177e4SLinus Torvalds }, 6441da177e4SLinus Torvalds #endif 6451da177e4SLinus Torvalds { 6461da177e4SLinus Torvalds .ctl_name = KERN_PIDMAX, 6471da177e4SLinus Torvalds .procname = "pid_max", 6481da177e4SLinus Torvalds .data = &pid_max, 6491da177e4SLinus Torvalds .maxlen = sizeof (int), 6501da177e4SLinus Torvalds .mode = 0644, 6511da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6521da177e4SLinus Torvalds .strategy = sysctl_intvec, 6531da177e4SLinus Torvalds .extra1 = &pid_max_min, 6541da177e4SLinus Torvalds .extra2 = &pid_max_max, 6551da177e4SLinus Torvalds }, 6561da177e4SLinus Torvalds { 6571da177e4SLinus Torvalds .ctl_name = KERN_PANIC_ON_OOPS, 6581da177e4SLinus Torvalds .procname = "panic_on_oops", 6591da177e4SLinus Torvalds .data = &panic_on_oops, 6601da177e4SLinus Torvalds .maxlen = sizeof(int), 6611da177e4SLinus Torvalds .mode = 0644, 6621da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6631da177e4SLinus Torvalds }, 6647ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6657ef3d2fdSJoe Perches { 6667ef3d2fdSJoe Perches .ctl_name = KERN_PRINTK, 6677ef3d2fdSJoe Perches .procname = "printk", 6687ef3d2fdSJoe Perches .data = &console_loglevel, 6697ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6707ef3d2fdSJoe Perches .mode = 0644, 6717ef3d2fdSJoe Perches .proc_handler = &proc_dointvec, 6727ef3d2fdSJoe Perches }, 6731da177e4SLinus Torvalds { 6741da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT, 6751da177e4SLinus Torvalds .procname = "printk_ratelimit", 676717115e1SDave Young .data = &printk_ratelimit_state.interval, 6771da177e4SLinus Torvalds .maxlen = sizeof(int), 6781da177e4SLinus Torvalds .mode = 0644, 6791da177e4SLinus Torvalds .proc_handler = &proc_dointvec_jiffies, 6801da177e4SLinus Torvalds .strategy = &sysctl_jiffies, 6811da177e4SLinus Torvalds }, 6821da177e4SLinus Torvalds { 6831da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT_BURST, 6841da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 685717115e1SDave Young .data = &printk_ratelimit_state.burst, 6861da177e4SLinus Torvalds .maxlen = sizeof(int), 6871da177e4SLinus Torvalds .mode = 0644, 6881da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6891da177e4SLinus Torvalds }, 6907ef3d2fdSJoe Perches #endif 6911da177e4SLinus Torvalds { 6921da177e4SLinus Torvalds .ctl_name = KERN_NGROUPS_MAX, 6931da177e4SLinus Torvalds .procname = "ngroups_max", 6941da177e4SLinus Torvalds .data = &ngroups_max, 6951da177e4SLinus Torvalds .maxlen = sizeof (int), 6961da177e4SLinus Torvalds .mode = 0444, 6971da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6981da177e4SLinus Torvalds }, 6991da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7001da177e4SLinus Torvalds { 7011da177e4SLinus Torvalds .ctl_name = KERN_UNKNOWN_NMI_PANIC, 7021da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 7031da177e4SLinus Torvalds .data = &unknown_nmi_panic, 7041da177e4SLinus Torvalds .maxlen = sizeof (int), 7051da177e4SLinus Torvalds .mode = 0644, 7062fbe7b25SDon Zickus .proc_handler = &proc_dointvec, 7071da177e4SLinus Torvalds }, 708407984f1SDon Zickus { 709407984f1SDon Zickus .procname = "nmi_watchdog", 710407984f1SDon Zickus .data = &nmi_watchdog_enabled, 711407984f1SDon Zickus .maxlen = sizeof (int), 712407984f1SDon Zickus .mode = 0644, 713407984f1SDon Zickus .proc_handler = &proc_nmi_enabled, 7141da177e4SLinus Torvalds }, 7151da177e4SLinus Torvalds #endif 7161da177e4SLinus Torvalds #if defined(CONFIG_X86) 7171da177e4SLinus Torvalds { 7188da5addaSDon Zickus .ctl_name = KERN_PANIC_ON_NMI, 7198da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7208da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7218da5addaSDon Zickus .maxlen = sizeof(int), 7228da5addaSDon Zickus .mode = 0644, 7238da5addaSDon Zickus .proc_handler = &proc_dointvec, 7248da5addaSDon Zickus }, 7258da5addaSDon Zickus { 7261da177e4SLinus Torvalds .ctl_name = KERN_BOOTLOADER_TYPE, 7271da177e4SLinus Torvalds .procname = "bootloader_type", 7281da177e4SLinus Torvalds .data = &bootloader_type, 7291da177e4SLinus Torvalds .maxlen = sizeof (int), 7301da177e4SLinus Torvalds .mode = 0444, 7311da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7321da177e4SLinus Torvalds }, 7330741f4d2SChuck Ebbert { 7340741f4d2SChuck Ebbert .ctl_name = CTL_UNNUMBERED, 7350741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 7360741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 7370741f4d2SChuck Ebbert .maxlen = sizeof(int), 7380741f4d2SChuck Ebbert .mode = 0644, 7390741f4d2SChuck Ebbert .proc_handler = &proc_dointvec, 7400741f4d2SChuck Ebbert }, 7416e7c4025SIngo Molnar { 7426e7c4025SIngo Molnar .ctl_name = CTL_UNNUMBERED, 7436e7c4025SIngo Molnar .procname = "io_delay_type", 7446e7c4025SIngo Molnar .data = &io_delay_type, 7456e7c4025SIngo Molnar .maxlen = sizeof(int), 7466e7c4025SIngo Molnar .mode = 0644, 7476e7c4025SIngo Molnar .proc_handler = &proc_dointvec, 7486e7c4025SIngo Molnar }, 7491da177e4SLinus Torvalds #endif 7507a9166e3SLuke Yang #if defined(CONFIG_MMU) 7511da177e4SLinus Torvalds { 7521da177e4SLinus Torvalds .ctl_name = KERN_RANDOMIZE, 7531da177e4SLinus Torvalds .procname = "randomize_va_space", 7541da177e4SLinus Torvalds .data = &randomize_va_space, 7551da177e4SLinus Torvalds .maxlen = sizeof(int), 7561da177e4SLinus Torvalds .mode = 0644, 7571da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7581da177e4SLinus Torvalds }, 7597a9166e3SLuke Yang #endif 7600152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 761951f22d5SMartin Schwidefsky { 762951f22d5SMartin Schwidefsky .ctl_name = KERN_SPIN_RETRY, 763951f22d5SMartin Schwidefsky .procname = "spin_retry", 764951f22d5SMartin Schwidefsky .data = &spin_retry, 765951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 766951f22d5SMartin Schwidefsky .mode = 0644, 767951f22d5SMartin Schwidefsky .proc_handler = &proc_dointvec, 768951f22d5SMartin Schwidefsky }, 769951f22d5SMartin Schwidefsky #endif 770673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 771c255d844SPavel Machek { 772c255d844SPavel Machek .procname = "acpi_video_flags", 77377afcf78SPavel Machek .data = &acpi_realmode_flags, 774c255d844SPavel Machek .maxlen = sizeof (unsigned long), 775c255d844SPavel Machek .mode = 0644, 7767f99f06fSStefan Seyfried .proc_handler = &proc_doulongvec_minmax, 777c255d844SPavel Machek }, 778c255d844SPavel Machek #endif 779d2b176edSJes Sorensen #ifdef CONFIG_IA64 780d2b176edSJes Sorensen { 781d2b176edSJes Sorensen .ctl_name = KERN_IA64_UNALIGNED, 782d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 783d2b176edSJes Sorensen .data = &no_unaligned_warning, 784d2b176edSJes Sorensen .maxlen = sizeof (int), 785d2b176edSJes Sorensen .mode = 0644, 786d2b176edSJes Sorensen .proc_handler = &proc_dointvec, 787d2b176edSJes Sorensen }, 78888fc241fSDoug Chapman { 78988fc241fSDoug Chapman .ctl_name = CTL_UNNUMBERED, 79088fc241fSDoug Chapman .procname = "unaligned-dump-stack", 79188fc241fSDoug Chapman .data = &unaligned_dump_stack, 79288fc241fSDoug Chapman .maxlen = sizeof (int), 79388fc241fSDoug Chapman .mode = 0644, 79488fc241fSDoug Chapman .proc_handler = &proc_dointvec, 79588fc241fSDoug Chapman }, 796d2b176edSJes Sorensen #endif 797c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 798c4f3b63fSRavikiran G Thirumalai { 799c4f3b63fSRavikiran G Thirumalai .ctl_name = CTL_UNNUMBERED, 8009c44bc03SIngo Molnar .procname = "softlockup_panic", 8019c44bc03SIngo Molnar .data = &softlockup_panic, 8029c44bc03SIngo Molnar .maxlen = sizeof(int), 8039c44bc03SIngo Molnar .mode = 0644, 8044dca10a9SHiroshi Shimamoto .proc_handler = &proc_dointvec_minmax, 8059c44bc03SIngo Molnar .strategy = &sysctl_intvec, 8069c44bc03SIngo Molnar .extra1 = &zero, 8079c44bc03SIngo Molnar .extra2 = &one, 8089c44bc03SIngo Molnar }, 8099c44bc03SIngo Molnar { 8109c44bc03SIngo Molnar .ctl_name = CTL_UNNUMBERED, 811c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 812c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 8139383d967SDimitri Sivanich .maxlen = sizeof(int), 814c4f3b63fSRavikiran G Thirumalai .mode = 0644, 815baf48f65SMandeep Singh Baines .proc_handler = &proc_dosoftlockup_thresh, 816c4f3b63fSRavikiran G Thirumalai .strategy = &sysctl_intvec, 8179383d967SDimitri Sivanich .extra1 = &neg_one, 818c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 819c4f3b63fSRavikiran G Thirumalai }, 820e162b39aSMandeep Singh Baines #endif 821e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 822e162b39aSMandeep Singh Baines { 823e162b39aSMandeep Singh Baines .ctl_name = CTL_UNNUMBERED, 824e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 825e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 826e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 827e162b39aSMandeep Singh Baines .mode = 0644, 828e162b39aSMandeep Singh Baines .proc_handler = &proc_dointvec_minmax, 829e162b39aSMandeep Singh Baines .strategy = &sysctl_intvec, 830e162b39aSMandeep Singh Baines .extra1 = &zero, 831e162b39aSMandeep Singh Baines .extra2 = &one, 832e162b39aSMandeep Singh Baines }, 83382a1fcb9SIngo Molnar { 83482a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 83582a1fcb9SIngo Molnar .procname = "hung_task_check_count", 83682a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 83790739081SIngo Molnar .maxlen = sizeof(unsigned long), 83882a1fcb9SIngo Molnar .mode = 0644, 83990739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 84082a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 84182a1fcb9SIngo Molnar }, 84282a1fcb9SIngo Molnar { 84382a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 84482a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 84582a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 84690739081SIngo Molnar .maxlen = sizeof(unsigned long), 84782a1fcb9SIngo Molnar .mode = 0644, 848e162b39aSMandeep Singh Baines .proc_handler = &proc_dohung_task_timeout_secs, 84982a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 85082a1fcb9SIngo Molnar }, 85182a1fcb9SIngo Molnar { 85282a1fcb9SIngo Molnar .ctl_name = CTL_UNNUMBERED, 85382a1fcb9SIngo Molnar .procname = "hung_task_warnings", 85482a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 85590739081SIngo Molnar .maxlen = sizeof(unsigned long), 85682a1fcb9SIngo Molnar .mode = 0644, 85790739081SIngo Molnar .proc_handler = &proc_doulongvec_minmax, 85882a1fcb9SIngo Molnar .strategy = &sysctl_intvec, 85982a1fcb9SIngo Molnar }, 860c4f3b63fSRavikiran G Thirumalai #endif 861bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 862bebfa101SAndi Kleen { 863bebfa101SAndi Kleen .ctl_name = KERN_COMPAT_LOG, 864bebfa101SAndi Kleen .procname = "compat-log", 865bebfa101SAndi Kleen .data = &compat_log, 866bebfa101SAndi Kleen .maxlen = sizeof (int), 867bebfa101SAndi Kleen .mode = 0644, 868bebfa101SAndi Kleen .proc_handler = &proc_dointvec, 869bebfa101SAndi Kleen }, 870bebfa101SAndi Kleen #endif 87123f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 87223f78d4aSIngo Molnar { 87323f78d4aSIngo Molnar .ctl_name = KERN_MAX_LOCK_DEPTH, 87423f78d4aSIngo Molnar .procname = "max_lock_depth", 87523f78d4aSIngo Molnar .data = &max_lock_depth, 87623f78d4aSIngo Molnar .maxlen = sizeof(int), 87723f78d4aSIngo Molnar .mode = 0644, 87823f78d4aSIngo Molnar .proc_handler = &proc_dointvec, 87923f78d4aSIngo Molnar }, 88023f78d4aSIngo Molnar #endif 88110a0a8d4SJeremy Fitzhardinge { 88210a0a8d4SJeremy Fitzhardinge .ctl_name = CTL_UNNUMBERED, 88310a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 88410a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 88510a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 88610a0a8d4SJeremy Fitzhardinge .mode = 0644, 88710a0a8d4SJeremy Fitzhardinge .proc_handler = &proc_dostring, 88810a0a8d4SJeremy Fitzhardinge .strategy = &sysctl_string, 88910a0a8d4SJeremy Fitzhardinge }, 8900b77f5bfSDavid Howells #ifdef CONFIG_KEYS 8910b77f5bfSDavid Howells { 8920b77f5bfSDavid Howells .ctl_name = CTL_UNNUMBERED, 8930b77f5bfSDavid Howells .procname = "keys", 8940b77f5bfSDavid Howells .mode = 0555, 8950b77f5bfSDavid Howells .child = key_sysctls, 8960b77f5bfSDavid Howells }, 8970b77f5bfSDavid Howells #endif 89831a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 89931a72bceSPaul E. McKenney { 90031a72bceSPaul E. McKenney .ctl_name = CTL_UNNUMBERED, 90131a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 90231a72bceSPaul E. McKenney .data = &rcutorture_runnable, 90331a72bceSPaul E. McKenney .maxlen = sizeof(int), 90431a72bceSPaul E. McKenney .mode = 0644, 90531a72bceSPaul E. McKenney .proc_handler = &proc_dointvec, 90631a72bceSPaul E. McKenney }, 90731a72bceSPaul E. McKenney #endif 90812e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK 90912e22c5eSDavid Howells { 91012e22c5eSDavid Howells .ctl_name = CTL_UNNUMBERED, 91112e22c5eSDavid Howells .procname = "slow-work", 91212e22c5eSDavid Howells .mode = 0555, 91312e22c5eSDavid Howells .child = slow_work_sysctls, 91412e22c5eSDavid Howells }, 91512e22c5eSDavid Howells #endif 916ed2c12f3SAndrew Morton /* 917ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 918ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 919ed2c12f3SAndrew Morton */ 9201da177e4SLinus Torvalds { .ctl_name = 0 } 9211da177e4SLinus Torvalds }; 9221da177e4SLinus Torvalds 923d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 9241da177e4SLinus Torvalds { 9251da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_MEMORY, 9261da177e4SLinus Torvalds .procname = "overcommit_memory", 9271da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 9281da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 9291da177e4SLinus Torvalds .mode = 0644, 9301da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9311da177e4SLinus Torvalds }, 9321da177e4SLinus Torvalds { 933fadd8fbdSKAMEZAWA Hiroyuki .ctl_name = VM_PANIC_ON_OOM, 934fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 935fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 936fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 937fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 938fadd8fbdSKAMEZAWA Hiroyuki .proc_handler = &proc_dointvec, 939fadd8fbdSKAMEZAWA Hiroyuki }, 940fadd8fbdSKAMEZAWA Hiroyuki { 941fe071d7eSDavid Rientjes .ctl_name = CTL_UNNUMBERED, 942fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 943fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 944fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 945fe071d7eSDavid Rientjes .mode = 0644, 946fe071d7eSDavid Rientjes .proc_handler = &proc_dointvec, 947fe071d7eSDavid Rientjes }, 948fe071d7eSDavid Rientjes { 949fef1bdd6SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 950fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 951fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 952fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 953fef1bdd6SDavid Rientjes .mode = 0644, 954fef1bdd6SDavid Rientjes .proc_handler = &proc_dointvec, 955fef1bdd6SDavid Rientjes }, 956fef1bdd6SDavid Rientjes { 9571da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_RATIO, 9581da177e4SLinus Torvalds .procname = "overcommit_ratio", 9591da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 9601da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 9611da177e4SLinus Torvalds .mode = 0644, 9621da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9631da177e4SLinus Torvalds }, 9641da177e4SLinus Torvalds { 9651da177e4SLinus Torvalds .ctl_name = VM_PAGE_CLUSTER, 9661da177e4SLinus Torvalds .procname = "page-cluster", 9671da177e4SLinus Torvalds .data = &page_cluster, 9681da177e4SLinus Torvalds .maxlen = sizeof(int), 9691da177e4SLinus Torvalds .mode = 0644, 9701da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9711da177e4SLinus Torvalds }, 9721da177e4SLinus Torvalds { 9731da177e4SLinus Torvalds .ctl_name = VM_DIRTY_BACKGROUND, 9741da177e4SLinus Torvalds .procname = "dirty_background_ratio", 9751da177e4SLinus Torvalds .data = &dirty_background_ratio, 9761da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 9771da177e4SLinus Torvalds .mode = 0644, 9782da02997SDavid Rientjes .proc_handler = &dirty_background_ratio_handler, 9791da177e4SLinus Torvalds .strategy = &sysctl_intvec, 9801da177e4SLinus Torvalds .extra1 = &zero, 9811da177e4SLinus Torvalds .extra2 = &one_hundred, 9821da177e4SLinus Torvalds }, 9831da177e4SLinus Torvalds { 9842da02997SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 9852da02997SDavid Rientjes .procname = "dirty_background_bytes", 9862da02997SDavid Rientjes .data = &dirty_background_bytes, 9872da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 9882da02997SDavid Rientjes .mode = 0644, 9892da02997SDavid Rientjes .proc_handler = &dirty_background_bytes_handler, 9902da02997SDavid Rientjes .strategy = &sysctl_intvec, 991fc3501d4SSven Wegener .extra1 = &one_ul, 9922da02997SDavid Rientjes }, 9932da02997SDavid Rientjes { 9941da177e4SLinus Torvalds .ctl_name = VM_DIRTY_RATIO, 9951da177e4SLinus Torvalds .procname = "dirty_ratio", 9961da177e4SLinus Torvalds .data = &vm_dirty_ratio, 9971da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 9981da177e4SLinus Torvalds .mode = 0644, 99904fbfdc1SPeter Zijlstra .proc_handler = &dirty_ratio_handler, 10001da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10011da177e4SLinus Torvalds .extra1 = &zero, 10021da177e4SLinus Torvalds .extra2 = &one_hundred, 10031da177e4SLinus Torvalds }, 10041da177e4SLinus Torvalds { 10052da02997SDavid Rientjes .ctl_name = CTL_UNNUMBERED, 10062da02997SDavid Rientjes .procname = "dirty_bytes", 10072da02997SDavid Rientjes .data = &vm_dirty_bytes, 10082da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10092da02997SDavid Rientjes .mode = 0644, 10102da02997SDavid Rientjes .proc_handler = &dirty_bytes_handler, 10112da02997SDavid Rientjes .strategy = &sysctl_intvec, 1012*9e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10132da02997SDavid Rientjes }, 10142da02997SDavid Rientjes { 10151da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1016f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1017f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10181da177e4SLinus Torvalds .mode = 0644, 10191da177e4SLinus Torvalds .proc_handler = &dirty_writeback_centisecs_handler, 10201da177e4SLinus Torvalds }, 10211da177e4SLinus Torvalds { 10221da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1023f6ef9438SBart Samwel .data = &dirty_expire_interval, 1024f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10251da177e4SLinus Torvalds .mode = 0644, 1026704503d8SAlexey Dobriyan .proc_handler = &proc_dointvec, 10271da177e4SLinus Torvalds }, 10281da177e4SLinus Torvalds { 10291da177e4SLinus Torvalds .ctl_name = VM_NR_PDFLUSH_THREADS, 10301da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10311da177e4SLinus Torvalds .data = &nr_pdflush_threads, 10321da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 10331da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 10341da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10351da177e4SLinus Torvalds }, 10361da177e4SLinus Torvalds { 1037fafd688eSPeter W Morreale .ctl_name = CTL_UNNUMBERED, 1038fafd688eSPeter W Morreale .procname = "nr_pdflush_threads_min", 1039fafd688eSPeter W Morreale .data = &nr_pdflush_threads_min, 1040fafd688eSPeter W Morreale .maxlen = sizeof nr_pdflush_threads_min, 1041fafd688eSPeter W Morreale .mode = 0644 /* read-write */, 1042fafd688eSPeter W Morreale .proc_handler = &proc_dointvec_minmax, 1043fafd688eSPeter W Morreale .strategy = &sysctl_intvec, 1044fafd688eSPeter W Morreale .extra1 = &one, 1045fafd688eSPeter W Morreale .extra2 = &nr_pdflush_threads_max, 1046fafd688eSPeter W Morreale }, 1047fafd688eSPeter W Morreale { 1048fafd688eSPeter W Morreale .ctl_name = CTL_UNNUMBERED, 1049fafd688eSPeter W Morreale .procname = "nr_pdflush_threads_max", 1050fafd688eSPeter W Morreale .data = &nr_pdflush_threads_max, 1051fafd688eSPeter W Morreale .maxlen = sizeof nr_pdflush_threads_max, 1052fafd688eSPeter W Morreale .mode = 0644 /* read-write */, 1053fafd688eSPeter W Morreale .proc_handler = &proc_dointvec_minmax, 1054fafd688eSPeter W Morreale .strategy = &sysctl_intvec, 1055fafd688eSPeter W Morreale .extra1 = &nr_pdflush_threads_min, 1056fafd688eSPeter W Morreale .extra2 = &one_thousand, 1057fafd688eSPeter W Morreale }, 1058fafd688eSPeter W Morreale { 10591da177e4SLinus Torvalds .ctl_name = VM_SWAPPINESS, 10601da177e4SLinus Torvalds .procname = "swappiness", 10611da177e4SLinus Torvalds .data = &vm_swappiness, 10621da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 10631da177e4SLinus Torvalds .mode = 0644, 10641da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 10651da177e4SLinus Torvalds .strategy = &sysctl_intvec, 10661da177e4SLinus Torvalds .extra1 = &zero, 10671da177e4SLinus Torvalds .extra2 = &one_hundred, 10681da177e4SLinus Torvalds }, 10691da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 10701da177e4SLinus Torvalds { 10711da177e4SLinus Torvalds .procname = "nr_hugepages", 1072e5ff2159SAndi Kleen .data = NULL, 10731da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 10741da177e4SLinus Torvalds .mode = 0644, 10751da177e4SLinus Torvalds .proc_handler = &hugetlb_sysctl_handler, 10761da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 10771da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 10781da177e4SLinus Torvalds }, 10791da177e4SLinus Torvalds { 10801da177e4SLinus Torvalds .ctl_name = VM_HUGETLB_GROUP, 10811da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 10821da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 10831da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 10841da177e4SLinus Torvalds .mode = 0644, 10851da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 10861da177e4SLinus Torvalds }, 1087396faf03SMel Gorman { 1088396faf03SMel Gorman .ctl_name = CTL_UNNUMBERED, 1089396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1090396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1091396faf03SMel Gorman .maxlen = sizeof(int), 1092396faf03SMel Gorman .mode = 0644, 1093396faf03SMel Gorman .proc_handler = &hugetlb_treat_movable_handler, 1094396faf03SMel Gorman }, 109554f9f80dSAdam Litke { 109654f9f80dSAdam Litke .ctl_name = CTL_UNNUMBERED, 1097d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1098e5ff2159SAndi Kleen .data = NULL, 1099e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1100d1c3fb1fSNishanth Aravamudan .mode = 0644, 1101a3d0c6aaSNishanth Aravamudan .proc_handler = &hugetlb_overcommit_handler, 1102e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1103e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1104d1c3fb1fSNishanth Aravamudan }, 11051da177e4SLinus Torvalds #endif 11061da177e4SLinus Torvalds { 11071da177e4SLinus Torvalds .ctl_name = VM_LOWMEM_RESERVE_RATIO, 11081da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11091da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11101da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11111da177e4SLinus Torvalds .mode = 0644, 11121da177e4SLinus Torvalds .proc_handler = &lowmem_reserve_ratio_sysctl_handler, 11131da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11141da177e4SLinus Torvalds }, 11151da177e4SLinus Torvalds { 11169d0243bcSAndrew Morton .ctl_name = VM_DROP_PAGECACHE, 11179d0243bcSAndrew Morton .procname = "drop_caches", 11189d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11199d0243bcSAndrew Morton .maxlen = sizeof(int), 11209d0243bcSAndrew Morton .mode = 0644, 11219d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 11229d0243bcSAndrew Morton .strategy = &sysctl_intvec, 11239d0243bcSAndrew Morton }, 11249d0243bcSAndrew Morton { 11251da177e4SLinus Torvalds .ctl_name = VM_MIN_FREE_KBYTES, 11261da177e4SLinus Torvalds .procname = "min_free_kbytes", 11271da177e4SLinus Torvalds .data = &min_free_kbytes, 11281da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11291da177e4SLinus Torvalds .mode = 0644, 11301da177e4SLinus Torvalds .proc_handler = &min_free_kbytes_sysctl_handler, 11311da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11321da177e4SLinus Torvalds .extra1 = &zero, 11331da177e4SLinus Torvalds }, 11348ad4b1fbSRohit Seth { 11358ad4b1fbSRohit Seth .ctl_name = VM_PERCPU_PAGELIST_FRACTION, 11368ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 11378ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 11388ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 11398ad4b1fbSRohit Seth .mode = 0644, 11408ad4b1fbSRohit Seth .proc_handler = &percpu_pagelist_fraction_sysctl_handler, 11418ad4b1fbSRohit Seth .strategy = &sysctl_intvec, 11428ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 11438ad4b1fbSRohit Seth }, 11441da177e4SLinus Torvalds #ifdef CONFIG_MMU 11451da177e4SLinus Torvalds { 11461da177e4SLinus Torvalds .ctl_name = VM_MAX_MAP_COUNT, 11471da177e4SLinus Torvalds .procname = "max_map_count", 11481da177e4SLinus Torvalds .data = &sysctl_max_map_count, 11491da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 11501da177e4SLinus Torvalds .mode = 0644, 11511da177e4SLinus Torvalds .proc_handler = &proc_dointvec 11521da177e4SLinus Torvalds }, 1153dd8632a1SPaul Mundt #else 1154dd8632a1SPaul Mundt { 1155dd8632a1SPaul Mundt .ctl_name = CTL_UNNUMBERED, 1156dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1157dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1158dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1159dd8632a1SPaul Mundt .mode = 0644, 1160dd8632a1SPaul Mundt .proc_handler = &proc_dointvec_minmax, 1161dd8632a1SPaul Mundt .strategy = &sysctl_intvec, 1162dd8632a1SPaul Mundt .extra1 = &zero, 1163dd8632a1SPaul Mundt }, 11641da177e4SLinus Torvalds #endif 11651da177e4SLinus Torvalds { 11661da177e4SLinus Torvalds .ctl_name = VM_LAPTOP_MODE, 11671da177e4SLinus Torvalds .procname = "laptop_mode", 11681da177e4SLinus Torvalds .data = &laptop_mode, 11691da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 11701da177e4SLinus Torvalds .mode = 0644, 1171ed5b43f1SBart Samwel .proc_handler = &proc_dointvec_jiffies, 1172ed5b43f1SBart Samwel .strategy = &sysctl_jiffies, 11731da177e4SLinus Torvalds }, 11741da177e4SLinus Torvalds { 11751da177e4SLinus Torvalds .ctl_name = VM_BLOCK_DUMP, 11761da177e4SLinus Torvalds .procname = "block_dump", 11771da177e4SLinus Torvalds .data = &block_dump, 11781da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 11791da177e4SLinus Torvalds .mode = 0644, 11801da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11811da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11821da177e4SLinus Torvalds .extra1 = &zero, 11831da177e4SLinus Torvalds }, 11841da177e4SLinus Torvalds { 11851da177e4SLinus Torvalds .ctl_name = VM_VFS_CACHE_PRESSURE, 11861da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 11871da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 11881da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 11891da177e4SLinus Torvalds .mode = 0644, 11901da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 11911da177e4SLinus Torvalds .strategy = &sysctl_intvec, 11921da177e4SLinus Torvalds .extra1 = &zero, 11931da177e4SLinus Torvalds }, 11941da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 11951da177e4SLinus Torvalds { 11961da177e4SLinus Torvalds .ctl_name = VM_LEGACY_VA_LAYOUT, 11971da177e4SLinus Torvalds .procname = "legacy_va_layout", 11981da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 11991da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12001da177e4SLinus Torvalds .mode = 0644, 12011da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 12021da177e4SLinus Torvalds .strategy = &sysctl_intvec, 12031da177e4SLinus Torvalds .extra1 = &zero, 12041da177e4SLinus Torvalds }, 12051da177e4SLinus Torvalds #endif 12061743660bSChristoph Lameter #ifdef CONFIG_NUMA 12071743660bSChristoph Lameter { 12081743660bSChristoph Lameter .ctl_name = VM_ZONE_RECLAIM_MODE, 12091743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12101743660bSChristoph Lameter .data = &zone_reclaim_mode, 12111743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12121743660bSChristoph Lameter .mode = 0644, 12131743660bSChristoph Lameter .proc_handler = &proc_dointvec, 1214c84db23cSChristoph Lameter .strategy = &sysctl_intvec, 1215c84db23cSChristoph Lameter .extra1 = &zero, 12161743660bSChristoph Lameter }, 12179614634fSChristoph Lameter { 12189614634fSChristoph Lameter .ctl_name = VM_MIN_UNMAPPED, 12199614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12209614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12219614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12229614634fSChristoph Lameter .mode = 0644, 12239614634fSChristoph Lameter .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler, 12249614634fSChristoph Lameter .strategy = &sysctl_intvec, 12259614634fSChristoph Lameter .extra1 = &zero, 12269614634fSChristoph Lameter .extra2 = &one_hundred, 12279614634fSChristoph Lameter }, 12280ff38490SChristoph Lameter { 12290ff38490SChristoph Lameter .ctl_name = VM_MIN_SLAB, 12300ff38490SChristoph Lameter .procname = "min_slab_ratio", 12310ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12320ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12330ff38490SChristoph Lameter .mode = 0644, 12340ff38490SChristoph Lameter .proc_handler = &sysctl_min_slab_ratio_sysctl_handler, 12350ff38490SChristoph Lameter .strategy = &sysctl_intvec, 12360ff38490SChristoph Lameter .extra1 = &zero, 12370ff38490SChristoph Lameter .extra2 = &one_hundred, 12380ff38490SChristoph Lameter }, 12391743660bSChristoph Lameter #endif 124077461ab3SChristoph Lameter #ifdef CONFIG_SMP 124177461ab3SChristoph Lameter { 124277461ab3SChristoph Lameter .ctl_name = CTL_UNNUMBERED, 124377461ab3SChristoph Lameter .procname = "stat_interval", 124477461ab3SChristoph Lameter .data = &sysctl_stat_interval, 124577461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 124677461ab3SChristoph Lameter .mode = 0644, 124777461ab3SChristoph Lameter .proc_handler = &proc_dointvec_jiffies, 124877461ab3SChristoph Lameter .strategy = &sysctl_jiffies, 124977461ab3SChristoph Lameter }, 125077461ab3SChristoph Lameter #endif 1251ed032189SEric Paris #ifdef CONFIG_SECURITY 1252ed032189SEric Paris { 1253ed032189SEric Paris .ctl_name = CTL_UNNUMBERED, 1254ed032189SEric Paris .procname = "mmap_min_addr", 1255ed032189SEric Paris .data = &mmap_min_addr, 1256ed032189SEric Paris .maxlen = sizeof(unsigned long), 1257ed032189SEric Paris .mode = 0644, 1258ed032189SEric Paris .proc_handler = &proc_doulongvec_minmax, 1259ed032189SEric Paris }, 12608daec965SLee Schermerhorn #endif 1261f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1262f0c0b2b8SKAMEZAWA Hiroyuki { 1263f0c0b2b8SKAMEZAWA Hiroyuki .ctl_name = CTL_UNNUMBERED, 1264f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1265f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1266f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1267f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 1268f0c0b2b8SKAMEZAWA Hiroyuki .proc_handler = &numa_zonelist_order_handler, 1269f0c0b2b8SKAMEZAWA Hiroyuki .strategy = &sysctl_string, 1270f0c0b2b8SKAMEZAWA Hiroyuki }, 1271f0c0b2b8SKAMEZAWA Hiroyuki #endif 12722b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 12735c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1274e6e5494cSIngo Molnar { 1275e6e5494cSIngo Molnar .ctl_name = VM_VDSO_ENABLED, 1276e6e5494cSIngo Molnar .procname = "vdso_enabled", 1277e6e5494cSIngo Molnar .data = &vdso_enabled, 1278e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1279e6e5494cSIngo Molnar .mode = 0644, 1280e6e5494cSIngo Molnar .proc_handler = &proc_dointvec, 1281e6e5494cSIngo Molnar .strategy = &sysctl_intvec, 1282e6e5494cSIngo Molnar .extra1 = &zero, 1283e6e5494cSIngo Molnar }, 1284e6e5494cSIngo Molnar #endif 1285195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1286195cf453SBron Gondwana { 1287195cf453SBron Gondwana .ctl_name = CTL_UNNUMBERED, 1288195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1289195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1290195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1291195cf453SBron Gondwana .mode = 0644, 1292195cf453SBron Gondwana .proc_handler = &proc_dointvec_minmax, 1293195cf453SBron Gondwana .strategy = &sysctl_intvec, 1294195cf453SBron Gondwana .extra1 = &zero, 1295195cf453SBron Gondwana .extra2 = &one, 1296195cf453SBron Gondwana }, 1297195cf453SBron Gondwana #endif 12984be6f6bbSPeter Zijlstra #ifdef CONFIG_UNEVICTABLE_LRU 12994be6f6bbSPeter Zijlstra { 13004be6f6bbSPeter Zijlstra .ctl_name = CTL_UNNUMBERED, 13014be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13024be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13034be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13044be6f6bbSPeter Zijlstra .mode = 0644, 13054be6f6bbSPeter Zijlstra .proc_handler = &scan_unevictable_handler, 13064be6f6bbSPeter Zijlstra }, 13074be6f6bbSPeter Zijlstra #endif 13082be7fe07SAndrew Morton /* 13092be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 13102be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 13112be7fe07SAndrew Morton */ 13121da177e4SLinus Torvalds { .ctl_name = 0 } 13131da177e4SLinus Torvalds }; 13141da177e4SLinus Torvalds 13152abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1316d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13172abc26fcSEric W. Biederman { .ctl_name = 0 } 13182abc26fcSEric W. Biederman }; 13192abc26fcSEric W. Biederman #endif 13202abc26fcSEric W. Biederman 1321d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13221da177e4SLinus Torvalds { 13231da177e4SLinus Torvalds .ctl_name = FS_NRINODE, 13241da177e4SLinus Torvalds .procname = "inode-nr", 13251da177e4SLinus Torvalds .data = &inodes_stat, 13261da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13271da177e4SLinus Torvalds .mode = 0444, 13281da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 13291da177e4SLinus Torvalds }, 13301da177e4SLinus Torvalds { 13311da177e4SLinus Torvalds .ctl_name = FS_STATINODE, 13321da177e4SLinus Torvalds .procname = "inode-state", 13331da177e4SLinus Torvalds .data = &inodes_stat, 13341da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13351da177e4SLinus Torvalds .mode = 0444, 13361da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 13371da177e4SLinus Torvalds }, 13381da177e4SLinus Torvalds { 13391da177e4SLinus Torvalds .procname = "file-nr", 13401da177e4SLinus Torvalds .data = &files_stat, 13411da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 13421da177e4SLinus Torvalds .mode = 0444, 1343529bf6beSDipankar Sarma .proc_handler = &proc_nr_files, 13441da177e4SLinus Torvalds }, 13451da177e4SLinus Torvalds { 13461da177e4SLinus Torvalds .ctl_name = FS_MAXFILE, 13471da177e4SLinus Torvalds .procname = "file-max", 13481da177e4SLinus Torvalds .data = &files_stat.max_files, 13491da177e4SLinus Torvalds .maxlen = sizeof(int), 13501da177e4SLinus Torvalds .mode = 0644, 13511da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 13521da177e4SLinus Torvalds }, 13531da177e4SLinus Torvalds { 13549cfe015aSEric Dumazet .ctl_name = CTL_UNNUMBERED, 13559cfe015aSEric Dumazet .procname = "nr_open", 13569cfe015aSEric Dumazet .data = &sysctl_nr_open, 13579cfe015aSEric Dumazet .maxlen = sizeof(int), 13589cfe015aSEric Dumazet .mode = 0644, 1359eceea0b3SAl Viro .proc_handler = &proc_dointvec_minmax, 1360eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1361eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 13629cfe015aSEric Dumazet }, 13639cfe015aSEric Dumazet { 13641da177e4SLinus Torvalds .ctl_name = FS_DENTRY, 13651da177e4SLinus Torvalds .procname = "dentry-state", 13661da177e4SLinus Torvalds .data = &dentry_stat, 13671da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 13681da177e4SLinus Torvalds .mode = 0444, 13691da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 13701da177e4SLinus Torvalds }, 13711da177e4SLinus Torvalds { 13721da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWUID, 13731da177e4SLinus Torvalds .procname = "overflowuid", 13741da177e4SLinus Torvalds .data = &fs_overflowuid, 13751da177e4SLinus Torvalds .maxlen = sizeof(int), 13761da177e4SLinus Torvalds .mode = 0644, 13771da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 13781da177e4SLinus Torvalds .strategy = &sysctl_intvec, 13791da177e4SLinus Torvalds .extra1 = &minolduid, 13801da177e4SLinus Torvalds .extra2 = &maxolduid, 13811da177e4SLinus Torvalds }, 13821da177e4SLinus Torvalds { 13831da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWGID, 13841da177e4SLinus Torvalds .procname = "overflowgid", 13851da177e4SLinus Torvalds .data = &fs_overflowgid, 13861da177e4SLinus Torvalds .maxlen = sizeof(int), 13871da177e4SLinus Torvalds .mode = 0644, 13881da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 13891da177e4SLinus Torvalds .strategy = &sysctl_intvec, 13901da177e4SLinus Torvalds .extra1 = &minolduid, 13911da177e4SLinus Torvalds .extra2 = &maxolduid, 13921da177e4SLinus Torvalds }, 1393bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13941da177e4SLinus Torvalds { 13951da177e4SLinus Torvalds .ctl_name = FS_LEASES, 13961da177e4SLinus Torvalds .procname = "leases-enable", 13971da177e4SLinus Torvalds .data = &leases_enable, 13981da177e4SLinus Torvalds .maxlen = sizeof(int), 13991da177e4SLinus Torvalds .mode = 0644, 14001da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14011da177e4SLinus Torvalds }, 1402bfcd17a6SThomas Petazzoni #endif 14031da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14041da177e4SLinus Torvalds { 14051da177e4SLinus Torvalds .ctl_name = FS_DIR_NOTIFY, 14061da177e4SLinus Torvalds .procname = "dir-notify-enable", 14071da177e4SLinus Torvalds .data = &dir_notify_enable, 14081da177e4SLinus Torvalds .maxlen = sizeof(int), 14091da177e4SLinus Torvalds .mode = 0644, 14101da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 14111da177e4SLinus Torvalds }, 14121da177e4SLinus Torvalds #endif 14131da177e4SLinus Torvalds #ifdef CONFIG_MMU 1414bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14151da177e4SLinus Torvalds { 14161da177e4SLinus Torvalds .ctl_name = FS_LEASE_TIME, 14171da177e4SLinus Torvalds .procname = "lease-break-time", 14181da177e4SLinus Torvalds .data = &lease_break_time, 14191da177e4SLinus Torvalds .maxlen = sizeof(int), 14201da177e4SLinus Torvalds .mode = 0644, 14218e654fbaSMatthew Wilcox .proc_handler = &proc_dointvec, 14221da177e4SLinus Torvalds }, 1423bfcd17a6SThomas Petazzoni #endif 1424ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14251da177e4SLinus Torvalds { 14261da177e4SLinus Torvalds .procname = "aio-nr", 14271da177e4SLinus Torvalds .data = &aio_nr, 14281da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14291da177e4SLinus Torvalds .mode = 0444, 1430d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 14311da177e4SLinus Torvalds }, 14321da177e4SLinus Torvalds { 14331da177e4SLinus Torvalds .procname = "aio-max-nr", 14341da177e4SLinus Torvalds .data = &aio_max_nr, 14351da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14361da177e4SLinus Torvalds .mode = 0644, 1437d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 14381da177e4SLinus Torvalds }, 1439ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14402d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14410399cb08SRobert Love { 14420399cb08SRobert Love .ctl_name = FS_INOTIFY, 14430399cb08SRobert Love .procname = "inotify", 14440399cb08SRobert Love .mode = 0555, 14450399cb08SRobert Love .child = inotify_table, 14460399cb08SRobert Love }, 14470399cb08SRobert Love #endif 14487ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14497ef9964eSDavide Libenzi { 14507ef9964eSDavide Libenzi .procname = "epoll", 14517ef9964eSDavide Libenzi .mode = 0555, 14527ef9964eSDavide Libenzi .child = epoll_table, 14537ef9964eSDavide Libenzi }, 14547ef9964eSDavide Libenzi #endif 14551da177e4SLinus Torvalds #endif 1456d6e71144SAlan Cox { 1457d6e71144SAlan Cox .ctl_name = KERN_SETUID_DUMPABLE, 1458d6e71144SAlan Cox .procname = "suid_dumpable", 1459d6e71144SAlan Cox .data = &suid_dumpable, 1460d6e71144SAlan Cox .maxlen = sizeof(int), 1461d6e71144SAlan Cox .mode = 0644, 14628e654fbaSMatthew Wilcox .proc_handler = &proc_dointvec_minmax, 14638e654fbaSMatthew Wilcox .strategy = &sysctl_intvec, 14648e654fbaSMatthew Wilcox .extra1 = &zero, 14658e654fbaSMatthew Wilcox .extra2 = &two, 1466d6e71144SAlan Cox }, 14672abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14682abc26fcSEric W. Biederman { 14692abc26fcSEric W. Biederman .ctl_name = CTL_UNNUMBERED, 14702abc26fcSEric W. Biederman .procname = "binfmt_misc", 14712abc26fcSEric W. Biederman .mode = 0555, 14722abc26fcSEric W. Biederman .child = binfmt_misc_table, 14732abc26fcSEric W. Biederman }, 14742abc26fcSEric W. Biederman #endif 14752be7fe07SAndrew Morton /* 14762be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14772be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14782be7fe07SAndrew Morton */ 14791da177e4SLinus Torvalds { .ctl_name = 0 } 14801da177e4SLinus Torvalds }; 14811da177e4SLinus Torvalds 1482d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1483d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC) 1484abd4f750SMasoud Asgharifard Sharbiani { 1485abd4f750SMasoud Asgharifard Sharbiani .ctl_name = CTL_UNNUMBERED, 1486abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1487abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1488abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1489abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1490abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1491abd4f750SMasoud Asgharifard Sharbiani }, 1492abd4f750SMasoud Asgharifard Sharbiani #endif 14931da177e4SLinus Torvalds { .ctl_name = 0 } 14941da177e4SLinus Torvalds }; 14951da177e4SLinus Torvalds 1496d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 14971da177e4SLinus Torvalds { .ctl_name = 0 } 14981da177e4SLinus Torvalds }; 14991da177e4SLinus Torvalds 1500330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1501330d57fbSAl Viro 1502330d57fbSAl Viro /* called under sysctl_lock */ 1503330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1504330d57fbSAl Viro { 1505330d57fbSAl Viro if (unlikely(p->unregistering)) 1506330d57fbSAl Viro return 0; 1507330d57fbSAl Viro p->used++; 1508330d57fbSAl Viro return 1; 1509330d57fbSAl Viro } 1510330d57fbSAl Viro 1511330d57fbSAl Viro /* called under sysctl_lock */ 1512330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1513330d57fbSAl Viro { 1514330d57fbSAl Viro if (!--p->used) 1515330d57fbSAl Viro if (unlikely(p->unregistering)) 1516330d57fbSAl Viro complete(p->unregistering); 1517330d57fbSAl Viro } 1518330d57fbSAl Viro 1519330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1520330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1521330d57fbSAl Viro { 1522330d57fbSAl Viro /* 1523330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1524330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1525330d57fbSAl Viro */ 1526330d57fbSAl Viro if (unlikely(p->used)) { 1527330d57fbSAl Viro struct completion wait; 1528330d57fbSAl Viro init_completion(&wait); 1529330d57fbSAl Viro p->unregistering = &wait; 1530330d57fbSAl Viro spin_unlock(&sysctl_lock); 1531330d57fbSAl Viro wait_for_completion(&wait); 1532330d57fbSAl Viro spin_lock(&sysctl_lock); 1533f7e6ced4SAl Viro } else { 1534f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1535f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1536330d57fbSAl Viro } 1537330d57fbSAl Viro /* 1538330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1539330d57fbSAl Viro * list in do_sysctl() relies on that. 1540330d57fbSAl Viro */ 1541330d57fbSAl Viro list_del_init(&p->ctl_entry); 1542330d57fbSAl Viro } 1543330d57fbSAl Viro 1544f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1545f7e6ced4SAl Viro { 1546f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1547f7e6ced4SAl Viro head->count++; 1548f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1549f7e6ced4SAl Viro } 1550f7e6ced4SAl Viro 1551f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1552f7e6ced4SAl Viro { 1553f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1554f7e6ced4SAl Viro if (!--head->count) 1555f7e6ced4SAl Viro kfree(head); 1556f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1557f7e6ced4SAl Viro } 1558f7e6ced4SAl Viro 1559f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1560f7e6ced4SAl Viro { 1561f7e6ced4SAl Viro if (!head) 1562f7e6ced4SAl Viro BUG(); 1563f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1564f7e6ced4SAl Viro if (!use_table(head)) 1565f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1566f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1567f7e6ced4SAl Viro return head; 1568f7e6ced4SAl Viro } 1569f7e6ced4SAl Viro 1570805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1571805b5d5eSEric W. Biederman { 1572805b5d5eSEric W. Biederman if (!head) 1573805b5d5eSEric W. Biederman return; 1574805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1575805b5d5eSEric W. Biederman unuse_table(head); 1576805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1577805b5d5eSEric W. Biederman } 1578805b5d5eSEric W. Biederman 157973455092SAl Viro static struct ctl_table_set * 158073455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 158173455092SAl Viro { 158273455092SAl Viro struct ctl_table_set *set = &root->default_set; 158373455092SAl Viro if (root->lookup) 158473455092SAl Viro set = root->lookup(root, namespaces); 158573455092SAl Viro return set; 158673455092SAl Viro } 158773455092SAl Viro 1588e51b6ba0SEric W. Biederman static struct list_head * 1589e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1590805b5d5eSEric W. Biederman { 159173455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 159273455092SAl Viro return &set->list; 1593e51b6ba0SEric W. Biederman } 1594e51b6ba0SEric W. Biederman 1595e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1596e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1597e51b6ba0SEric W. Biederman { 1598e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1599e51b6ba0SEric W. Biederman struct list_head *header_list; 1600805b5d5eSEric W. Biederman struct ctl_table_header *head; 1601805b5d5eSEric W. Biederman struct list_head *tmp; 1602e51b6ba0SEric W. Biederman 1603805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1604805b5d5eSEric W. Biederman if (prev) { 1605e51b6ba0SEric W. Biederman head = prev; 1606805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1607805b5d5eSEric W. Biederman unuse_table(prev); 1608805b5d5eSEric W. Biederman goto next; 1609805b5d5eSEric W. Biederman } 1610805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1611805b5d5eSEric W. Biederman for (;;) { 1612805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1613805b5d5eSEric W. Biederman 1614805b5d5eSEric W. Biederman if (!use_table(head)) 1615805b5d5eSEric W. Biederman goto next; 1616805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1617805b5d5eSEric W. Biederman return head; 1618805b5d5eSEric W. Biederman next: 1619e51b6ba0SEric W. Biederman root = head->root; 1620805b5d5eSEric W. Biederman tmp = tmp->next; 1621e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1622e51b6ba0SEric W. Biederman if (tmp != header_list) 1623e51b6ba0SEric W. Biederman continue; 1624e51b6ba0SEric W. Biederman 1625e51b6ba0SEric W. Biederman do { 1626e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1627e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1628e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1629e51b6ba0SEric W. Biederman goto out; 1630e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1631e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1632e51b6ba0SEric W. Biederman tmp = header_list->next; 1633805b5d5eSEric W. Biederman } 1634e51b6ba0SEric W. Biederman out: 1635805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1636805b5d5eSEric W. Biederman return NULL; 1637805b5d5eSEric W. Biederman } 1638805b5d5eSEric W. Biederman 1639e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1640e51b6ba0SEric W. Biederman { 1641e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1642e51b6ba0SEric W. Biederman } 1643e51b6ba0SEric W. Biederman 1644e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1645e51b6ba0SEric W. Biederman { 1646e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1647e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1648e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1649e51b6ba0SEric W. Biederman } 1650e51b6ba0SEric W. Biederman 1651b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 16522c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */ 1653d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root, 1654d7321cd6SPavel Emelyanov struct ctl_table *table, 16552c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 16562c4c7155SPavel Emelyanov void __user *newval, size_t newlen) 16572c4c7155SPavel Emelyanov { 16582c4c7155SPavel Emelyanov int op = 0, rc; 16592c4c7155SPavel Emelyanov 16602c4c7155SPavel Emelyanov if (oldval) 1661e6305c43SAl Viro op |= MAY_READ; 16622c4c7155SPavel Emelyanov if (newval) 1663e6305c43SAl Viro op |= MAY_WRITE; 1664d7321cd6SPavel Emelyanov if (sysctl_perm(root, table, op)) 16652c4c7155SPavel Emelyanov return -EPERM; 16662c4c7155SPavel Emelyanov 16672c4c7155SPavel Emelyanov if (table->strategy) { 1668f221e726SAlexey Dobriyan rc = table->strategy(table, oldval, oldlenp, newval, newlen); 16692c4c7155SPavel Emelyanov if (rc < 0) 16702c4c7155SPavel Emelyanov return rc; 16712c4c7155SPavel Emelyanov if (rc > 0) 16722c4c7155SPavel Emelyanov return 0; 16732c4c7155SPavel Emelyanov } 16742c4c7155SPavel Emelyanov 16752c4c7155SPavel Emelyanov /* If there is no strategy routine, or if the strategy returns 16762c4c7155SPavel Emelyanov * zero, proceed with automatic r/w */ 16772c4c7155SPavel Emelyanov if (table->data && table->maxlen) { 1678f221e726SAlexey Dobriyan rc = sysctl_data(table, oldval, oldlenp, newval, newlen); 16792c4c7155SPavel Emelyanov if (rc < 0) 16802c4c7155SPavel Emelyanov return rc; 16812c4c7155SPavel Emelyanov } 16822c4c7155SPavel Emelyanov return 0; 16832c4c7155SPavel Emelyanov } 16842c4c7155SPavel Emelyanov 16852c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen, 16862c4c7155SPavel Emelyanov void __user *oldval, size_t __user *oldlenp, 16872c4c7155SPavel Emelyanov void __user *newval, size_t newlen, 1688d7321cd6SPavel Emelyanov struct ctl_table_root *root, 16892c4c7155SPavel Emelyanov struct ctl_table *table) 16902c4c7155SPavel Emelyanov { 16912c4c7155SPavel Emelyanov int n; 16922c4c7155SPavel Emelyanov repeat: 16932c4c7155SPavel Emelyanov if (!nlen) 16942c4c7155SPavel Emelyanov return -ENOTDIR; 16952c4c7155SPavel Emelyanov if (get_user(n, name)) 16962c4c7155SPavel Emelyanov return -EFAULT; 16972c4c7155SPavel Emelyanov for ( ; table->ctl_name || table->procname; table++) { 16982c4c7155SPavel Emelyanov if (!table->ctl_name) 16992c4c7155SPavel Emelyanov continue; 17002c4c7155SPavel Emelyanov if (n == table->ctl_name) { 17012c4c7155SPavel Emelyanov int error; 17022c4c7155SPavel Emelyanov if (table->child) { 1703e6305c43SAl Viro if (sysctl_perm(root, table, MAY_EXEC)) 17042c4c7155SPavel Emelyanov return -EPERM; 17052c4c7155SPavel Emelyanov name++; 17062c4c7155SPavel Emelyanov nlen--; 17072c4c7155SPavel Emelyanov table = table->child; 17082c4c7155SPavel Emelyanov goto repeat; 17092c4c7155SPavel Emelyanov } 1710f221e726SAlexey Dobriyan error = do_sysctl_strategy(root, table, 17112c4c7155SPavel Emelyanov oldval, oldlenp, 17122c4c7155SPavel Emelyanov newval, newlen); 17132c4c7155SPavel Emelyanov return error; 17142c4c7155SPavel Emelyanov } 17152c4c7155SPavel Emelyanov } 17162c4c7155SPavel Emelyanov return -ENOTDIR; 17172c4c7155SPavel Emelyanov } 17182c4c7155SPavel Emelyanov 17191da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 17201da177e4SLinus Torvalds void __user *newval, size_t newlen) 17211da177e4SLinus Torvalds { 1722805b5d5eSEric W. Biederman struct ctl_table_header *head; 1723330d57fbSAl Viro int error = -ENOTDIR; 17241da177e4SLinus Torvalds 17251da177e4SLinus Torvalds if (nlen <= 0 || nlen >= CTL_MAXNAME) 17261da177e4SLinus Torvalds return -ENOTDIR; 17271da177e4SLinus Torvalds if (oldval) { 17281da177e4SLinus Torvalds int old_len; 17291da177e4SLinus Torvalds if (!oldlenp || get_user(old_len, oldlenp)) 17301da177e4SLinus Torvalds return -EFAULT; 17311da177e4SLinus Torvalds } 1732330d57fbSAl Viro 1733805b5d5eSEric W. Biederman for (head = sysctl_head_next(NULL); head; 1734805b5d5eSEric W. Biederman head = sysctl_head_next(head)) { 1735330d57fbSAl Viro error = parse_table(name, nlen, oldval, oldlenp, 1736d7321cd6SPavel Emelyanov newval, newlen, 1737d7321cd6SPavel Emelyanov head->root, head->ctl_table); 1738805b5d5eSEric W. Biederman if (error != -ENOTDIR) { 1739805b5d5eSEric W. Biederman sysctl_head_finish(head); 1740330d57fbSAl Viro break; 1741805b5d5eSEric W. Biederman } 1742805b5d5eSEric W. Biederman } 17431da177e4SLinus Torvalds return error; 17441da177e4SLinus Torvalds } 17451da177e4SLinus Torvalds 17461e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) 17471da177e4SLinus Torvalds { 17481da177e4SLinus Torvalds struct __sysctl_args tmp; 17491da177e4SLinus Torvalds int error; 17501da177e4SLinus Torvalds 17511da177e4SLinus Torvalds if (copy_from_user(&tmp, args, sizeof(tmp))) 17521da177e4SLinus Torvalds return -EFAULT; 17531da177e4SLinus Torvalds 17547058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 17557058cb02SEric W. Biederman if (error) 17567058cb02SEric W. Biederman goto out; 17577058cb02SEric W. Biederman 17581da177e4SLinus Torvalds lock_kernel(); 17591da177e4SLinus Torvalds error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, 17601da177e4SLinus Torvalds tmp.newval, tmp.newlen); 17611da177e4SLinus Torvalds unlock_kernel(); 17627058cb02SEric W. Biederman out: 17631da177e4SLinus Torvalds return error; 17641da177e4SLinus Torvalds } 1765b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 17661da177e4SLinus Torvalds 17671da177e4SLinus Torvalds /* 17681ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 17691da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 17701da177e4SLinus Torvalds */ 17711da177e4SLinus Torvalds 17721da177e4SLinus Torvalds static int test_perm(int mode, int op) 17731da177e4SLinus Torvalds { 177476aac0e9SDavid Howells if (!current_euid()) 17751da177e4SLinus Torvalds mode >>= 6; 17761da177e4SLinus Torvalds else if (in_egroup_p(0)) 17771da177e4SLinus Torvalds mode >>= 3; 1778e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 17791da177e4SLinus Torvalds return 0; 17801da177e4SLinus Torvalds return -EACCES; 17811da177e4SLinus Torvalds } 17821da177e4SLinus Torvalds 1783d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 17841da177e4SLinus Torvalds { 17851da177e4SLinus Torvalds int error; 1786d7321cd6SPavel Emelyanov int mode; 1787d7321cd6SPavel Emelyanov 1788e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 17891da177e4SLinus Torvalds if (error) 17901da177e4SLinus Torvalds return error; 1791d7321cd6SPavel Emelyanov 1792d7321cd6SPavel Emelyanov if (root->permissions) 1793d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1794d7321cd6SPavel Emelyanov else 1795d7321cd6SPavel Emelyanov mode = table->mode; 1796d7321cd6SPavel Emelyanov 1797d7321cd6SPavel Emelyanov return test_perm(mode, op); 17981da177e4SLinus Torvalds } 17991da177e4SLinus Torvalds 1800d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1801d912b0ccSEric W. Biederman { 1802d912b0ccSEric W. Biederman for (; table->ctl_name || table->procname; table++) { 1803d912b0ccSEric W. Biederman table->parent = parent; 1804d912b0ccSEric W. Biederman if (table->child) 1805d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1806d912b0ccSEric W. Biederman } 1807d912b0ccSEric W. Biederman } 1808d912b0ccSEric W. Biederman 1809d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1810d912b0ccSEric W. Biederman { 1811d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 181288f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 181388f458e4SHolger Schurig { 181488f458e4SHolger Schurig int err; 1815e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 181688f458e4SHolger Schurig } 181788f458e4SHolger Schurig #endif 1818d912b0ccSEric W. Biederman return 0; 1819d912b0ccSEric W. Biederman } 1820d912b0ccSEric W. Biederman 1821d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1822d912b0ccSEric W. Biederman 1823bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1824bfbcf034SAl Viro struct ctl_table *table) 1825ae7edeccSAl Viro { 1826ae7edeccSAl Viro struct ctl_table *p; 1827ae7edeccSAl Viro const char *s = branch->procname; 1828ae7edeccSAl Viro 1829ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1830ae7edeccSAl Viro if (!s || !branch->child) 1831bfbcf034SAl Viro return NULL; 1832ae7edeccSAl Viro 1833ae7edeccSAl Viro /* ... and nothing else */ 1834ae7edeccSAl Viro if (branch[1].procname || branch[1].ctl_name) 1835bfbcf034SAl Viro return NULL; 1836ae7edeccSAl Viro 1837ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 1838ae7edeccSAl Viro for (p = table; p->procname || p->ctl_name; p++) { 1839ae7edeccSAl Viro if (!p->child) 1840ae7edeccSAl Viro continue; 1841ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1842bfbcf034SAl Viro return p; 1843ae7edeccSAl Viro } 1844bfbcf034SAl Viro return NULL; 1845ae7edeccSAl Viro } 1846ae7edeccSAl Viro 1847ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1848ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1849ae7edeccSAl Viro { 1850ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1851bfbcf034SAl Viro struct ctl_table *next; 1852ae7edeccSAl Viro int is_better = 0; 1853ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1854ae7edeccSAl Viro 1855bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1856ae7edeccSAl Viro if (by == q->attached_by) 1857ae7edeccSAl Viro is_better = 1; 1858ae7edeccSAl Viro if (to == p->attached_by) 1859ae7edeccSAl Viro not_in_parent = 1; 1860ae7edeccSAl Viro by = by->child; 1861bfbcf034SAl Viro to = next->child; 1862ae7edeccSAl Viro } 1863ae7edeccSAl Viro 1864ae7edeccSAl Viro if (is_better && not_in_parent) { 1865ae7edeccSAl Viro q->attached_by = by; 1866ae7edeccSAl Viro q->attached_to = to; 1867ae7edeccSAl Viro q->parent = p; 1868ae7edeccSAl Viro } 1869ae7edeccSAl Viro } 1870ae7edeccSAl Viro 18711da177e4SLinus Torvalds /** 1872e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1873e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1874e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 187529e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 18761da177e4SLinus Torvalds * @table: the top-level table structure 18771da177e4SLinus Torvalds * 18781da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 187929e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 18801da177e4SLinus Torvalds * 1881d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 18821da177e4SLinus Torvalds * 18831da177e4SLinus Torvalds * ctl_name - This is the numeric sysctl value used by sysctl(2). The number 18841da177e4SLinus Torvalds * must be unique within that level of sysctl 18851da177e4SLinus Torvalds * 18861da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 18871da177e4SLinus Torvalds * enter a sysctl file 18881da177e4SLinus Torvalds * 18891da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 18901da177e4SLinus Torvalds * 18911da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 18921da177e4SLinus Torvalds * 18931da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 18941da177e4SLinus Torvalds * 18951da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 18961da177e4SLinus Torvalds * %NULL. 18971da177e4SLinus Torvalds * 18981da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 18991da177e4SLinus Torvalds * 19001da177e4SLinus Torvalds * strategy - the strategy routine (described below) 19011da177e4SLinus Torvalds * 19021da177e4SLinus Torvalds * de - for internal use by the sysctl routines 19031da177e4SLinus Torvalds * 19041da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 19051da177e4SLinus Torvalds * 19061da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 19071da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 19081da177e4SLinus Torvalds * 19091da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 19101da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 19111da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 19121da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 19131da177e4SLinus Torvalds * 19141da177e4SLinus Torvalds * More sophisticated management can be enabled by the provision of a 19151da177e4SLinus Torvalds * strategy routine with the table entry. This will be called before 19161da177e4SLinus Torvalds * any automatic read or write of the data is performed. 19171da177e4SLinus Torvalds * 19181da177e4SLinus Torvalds * The strategy routine may return 19191da177e4SLinus Torvalds * 19201da177e4SLinus Torvalds * < 0 - Error occurred (error is passed to user process) 19211da177e4SLinus Torvalds * 19221da177e4SLinus Torvalds * 0 - OK - proceed with automatic read or write. 19231da177e4SLinus Torvalds * 19241da177e4SLinus Torvalds * > 0 - OK - read or write has been done by the strategy routine, so 19251da177e4SLinus Torvalds * return immediately. 19261da177e4SLinus Torvalds * 19271da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 19281da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 19291da177e4SLinus Torvalds * directory handler). Several default handlers are available to 19301da177e4SLinus Torvalds * cover common cases - 19311da177e4SLinus Torvalds * 19321da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 19331da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 19341da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 19351da177e4SLinus Torvalds * 19361da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 19371da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 19381da177e4SLinus Torvalds * 19391da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 19401da177e4SLinus Torvalds * to the table header on success. 19411da177e4SLinus Torvalds */ 1942e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1943e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1944e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1945e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 19461da177e4SLinus Torvalds { 194729e796fdSEric W. Biederman struct ctl_table_header *header; 194829e796fdSEric W. Biederman struct ctl_table *new, **prevp; 194929e796fdSEric W. Biederman unsigned int n, npath; 1950ae7edeccSAl Viro struct ctl_table_set *set; 195129e796fdSEric W. Biederman 195229e796fdSEric W. Biederman /* Count the path components */ 195329e796fdSEric W. Biederman for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath) 195429e796fdSEric W. Biederman ; 195529e796fdSEric W. Biederman 195629e796fdSEric W. Biederman /* 195729e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 195829e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 195929e796fdSEric W. Biederman * for this, the second will be the sentinel (ctl_name == 0). 196029e796fdSEric W. Biederman * 196129e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 196229e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 196329e796fdSEric W. Biederman */ 196429e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 196529e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 196629e796fdSEric W. Biederman if (!header) 19671da177e4SLinus Torvalds return NULL; 196829e796fdSEric W. Biederman 196929e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 197029e796fdSEric W. Biederman 197129e796fdSEric W. Biederman /* Now connect the dots */ 197229e796fdSEric W. Biederman prevp = &header->ctl_table; 197329e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 197429e796fdSEric W. Biederman /* Copy the procname */ 197529e796fdSEric W. Biederman new->procname = path->procname; 197629e796fdSEric W. Biederman new->ctl_name = path->ctl_name; 197729e796fdSEric W. Biederman new->mode = 0555; 197829e796fdSEric W. Biederman 197929e796fdSEric W. Biederman *prevp = new; 198029e796fdSEric W. Biederman prevp = &new->child; 198129e796fdSEric W. Biederman 198229e796fdSEric W. Biederman new += 2; 198329e796fdSEric W. Biederman } 198429e796fdSEric W. Biederman *prevp = table; 198523eb06deSEric W. Biederman header->ctl_table_arg = table; 198629e796fdSEric W. Biederman 198729e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 198829e796fdSEric W. Biederman header->used = 0; 198929e796fdSEric W. Biederman header->unregistering = NULL; 1990e51b6ba0SEric W. Biederman header->root = root; 199129e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1992f7e6ced4SAl Viro header->count = 1; 199388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1994e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 199529e796fdSEric W. Biederman kfree(header); 1996fc6cd25bSEric W. Biederman return NULL; 1997fc6cd25bSEric W. Biederman } 199888f458e4SHolger Schurig #endif 1999330d57fbSAl Viro spin_lock(&sysctl_lock); 200073455092SAl Viro header->set = lookup_header_set(root, namespaces); 2001ae7edeccSAl Viro header->attached_by = header->ctl_table; 2002ae7edeccSAl Viro header->attached_to = root_table; 2003ae7edeccSAl Viro header->parent = &root_table_header; 2004ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 2005ae7edeccSAl Viro struct ctl_table_header *p; 2006ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 2007ae7edeccSAl Viro if (p->unregistering) 2008ae7edeccSAl Viro continue; 2009ae7edeccSAl Viro try_attach(p, header); 2010ae7edeccSAl Viro } 2011ae7edeccSAl Viro } 2012ae7edeccSAl Viro header->parent->count++; 201373455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 2014330d57fbSAl Viro spin_unlock(&sysctl_lock); 201529e796fdSEric W. Biederman 201629e796fdSEric W. Biederman return header; 201729e796fdSEric W. Biederman } 201829e796fdSEric W. Biederman 201929e796fdSEric W. Biederman /** 2020e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 2021e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 2022e51b6ba0SEric W. Biederman * @table: the top-level table structure 2023e51b6ba0SEric W. Biederman * 2024e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 2025e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 2026e51b6ba0SEric W. Biederman * 2027e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 2028e51b6ba0SEric W. Biederman */ 2029e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 2030e51b6ba0SEric W. Biederman struct ctl_table *table) 2031e51b6ba0SEric W. Biederman { 2032e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 2033e51b6ba0SEric W. Biederman path, table); 2034e51b6ba0SEric W. Biederman } 2035e51b6ba0SEric W. Biederman 2036e51b6ba0SEric W. Biederman /** 203729e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 203829e796fdSEric W. Biederman * @table: the top-level table structure 203929e796fdSEric W. Biederman * 204029e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 204129e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 204229e796fdSEric W. Biederman * 204329e796fdSEric W. Biederman * See register_sysctl_paths for more details. 204429e796fdSEric W. Biederman */ 204529e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 204629e796fdSEric W. Biederman { 204729e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 204829e796fdSEric W. Biederman 204929e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 20501da177e4SLinus Torvalds } 20511da177e4SLinus Torvalds 20521da177e4SLinus Torvalds /** 20531da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 20541da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 20551da177e4SLinus Torvalds * 20561da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 20571da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 20581da177e4SLinus Torvalds */ 20591da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 20601da177e4SLinus Torvalds { 2061330d57fbSAl Viro might_sleep(); 2062f1dad166SPavel Emelyanov 2063f1dad166SPavel Emelyanov if (header == NULL) 2064f1dad166SPavel Emelyanov return; 2065f1dad166SPavel Emelyanov 2066330d57fbSAl Viro spin_lock(&sysctl_lock); 2067330d57fbSAl Viro start_unregistering(header); 2068ae7edeccSAl Viro if (!--header->parent->count) { 2069ae7edeccSAl Viro WARN_ON(1); 2070ae7edeccSAl Viro kfree(header->parent); 2071ae7edeccSAl Viro } 2072f7e6ced4SAl Viro if (!--header->count) 20731da177e4SLinus Torvalds kfree(header); 2074f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 20751da177e4SLinus Torvalds } 20761da177e4SLinus Torvalds 20779043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 20789043476fSAl Viro { 20799043476fSAl Viro struct ctl_table_set *set = p->set; 20809043476fSAl Viro int res; 20819043476fSAl Viro spin_lock(&sysctl_lock); 20829043476fSAl Viro if (p->unregistering) 20839043476fSAl Viro res = 0; 20849043476fSAl Viro else if (!set->is_seen) 20859043476fSAl Viro res = 1; 20869043476fSAl Viro else 20879043476fSAl Viro res = set->is_seen(set); 20889043476fSAl Viro spin_unlock(&sysctl_lock); 20899043476fSAl Viro return res; 20909043476fSAl Viro } 20919043476fSAl Viro 209273455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 209373455092SAl Viro struct ctl_table_set *parent, 209473455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 209573455092SAl Viro { 209673455092SAl Viro INIT_LIST_HEAD(&p->list); 209773455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 209873455092SAl Viro p->is_seen = is_seen; 209973455092SAl Viro } 210073455092SAl Viro 2101b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 2102d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 2103b89a8171SEric W. Biederman { 2104b89a8171SEric W. Biederman return NULL; 2105b89a8171SEric W. Biederman } 2106b89a8171SEric W. Biederman 210729e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 210829e796fdSEric W. Biederman struct ctl_table *table) 210929e796fdSEric W. Biederman { 211029e796fdSEric W. Biederman return NULL; 211129e796fdSEric W. Biederman } 211229e796fdSEric W. Biederman 2113b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2114b89a8171SEric W. Biederman { 2115b89a8171SEric W. Biederman } 2116b89a8171SEric W. Biederman 211773455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 211873455092SAl Viro struct ctl_table_set *parent, 211973455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 212073455092SAl Viro { 212173455092SAl Viro } 212273455092SAl Viro 2123f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2124f7e6ced4SAl Viro { 2125f7e6ced4SAl Viro } 2126f7e6ced4SAl Viro 2127b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2128b89a8171SEric W. Biederman 21291da177e4SLinus Torvalds /* 21301da177e4SLinus Torvalds * /proc/sys support 21311da177e4SLinus Torvalds */ 21321da177e4SLinus Torvalds 2133b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 21341da177e4SLinus Torvalds 2135b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 2136b1ba4dddSAdrian Bunk struct file *filp, void __user *buffer, 2137b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2138f5dd3d6fSSam Vilain { 2139f5dd3d6fSSam Vilain size_t len; 2140f5dd3d6fSSam Vilain char __user *p; 2141f5dd3d6fSSam Vilain char c; 2142f5dd3d6fSSam Vilain 21438d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2144f5dd3d6fSSam Vilain *lenp = 0; 2145f5dd3d6fSSam Vilain return 0; 2146f5dd3d6fSSam Vilain } 2147f5dd3d6fSSam Vilain 2148f5dd3d6fSSam Vilain if (write) { 2149f5dd3d6fSSam Vilain len = 0; 2150f5dd3d6fSSam Vilain p = buffer; 2151f5dd3d6fSSam Vilain while (len < *lenp) { 2152f5dd3d6fSSam Vilain if (get_user(c, p++)) 2153f5dd3d6fSSam Vilain return -EFAULT; 2154f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2155f5dd3d6fSSam Vilain break; 2156f5dd3d6fSSam Vilain len++; 2157f5dd3d6fSSam Vilain } 2158f5dd3d6fSSam Vilain if (len >= maxlen) 2159f5dd3d6fSSam Vilain len = maxlen-1; 2160f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2161f5dd3d6fSSam Vilain return -EFAULT; 2162f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2163f5dd3d6fSSam Vilain *ppos += *lenp; 2164f5dd3d6fSSam Vilain } else { 2165f5dd3d6fSSam Vilain len = strlen(data); 2166f5dd3d6fSSam Vilain if (len > maxlen) 2167f5dd3d6fSSam Vilain len = maxlen; 21688d060877SOleg Nesterov 21698d060877SOleg Nesterov if (*ppos > len) { 21708d060877SOleg Nesterov *lenp = 0; 21718d060877SOleg Nesterov return 0; 21728d060877SOleg Nesterov } 21738d060877SOleg Nesterov 21748d060877SOleg Nesterov data += *ppos; 21758d060877SOleg Nesterov len -= *ppos; 21768d060877SOleg Nesterov 2177f5dd3d6fSSam Vilain if (len > *lenp) 2178f5dd3d6fSSam Vilain len = *lenp; 2179f5dd3d6fSSam Vilain if (len) 2180f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2181f5dd3d6fSSam Vilain return -EFAULT; 2182f5dd3d6fSSam Vilain if (len < *lenp) { 2183f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2184f5dd3d6fSSam Vilain return -EFAULT; 2185f5dd3d6fSSam Vilain len++; 2186f5dd3d6fSSam Vilain } 2187f5dd3d6fSSam Vilain *lenp = len; 2188f5dd3d6fSSam Vilain *ppos += len; 2189f5dd3d6fSSam Vilain } 2190f5dd3d6fSSam Vilain return 0; 2191f5dd3d6fSSam Vilain } 2192f5dd3d6fSSam Vilain 21931da177e4SLinus Torvalds /** 21941da177e4SLinus Torvalds * proc_dostring - read a string sysctl 21951da177e4SLinus Torvalds * @table: the sysctl table 21961da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21971da177e4SLinus Torvalds * @filp: the file structure 21981da177e4SLinus Torvalds * @buffer: the user buffer 21991da177e4SLinus Torvalds * @lenp: the size of the user buffer 22001da177e4SLinus Torvalds * @ppos: file position 22011da177e4SLinus Torvalds * 22021da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 22031da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 22041da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 22051da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 22061da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 22071da177e4SLinus Torvalds * not large enough. 22081da177e4SLinus Torvalds * 22091da177e4SLinus Torvalds * Returns 0 on success. 22101da177e4SLinus Torvalds */ 2211d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp, 22121da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22131da177e4SLinus Torvalds { 2214f5dd3d6fSSam Vilain return _proc_do_string(table->data, table->maxlen, write, filp, 2215f5dd3d6fSSam Vilain buffer, lenp, ppos); 22161da177e4SLinus Torvalds } 22171da177e4SLinus Torvalds 22181da177e4SLinus Torvalds 22191da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 22201da177e4SLinus Torvalds int *valp, 22211da177e4SLinus Torvalds int write, void *data) 22221da177e4SLinus Torvalds { 22231da177e4SLinus Torvalds if (write) { 22241da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 22251da177e4SLinus Torvalds } else { 22261da177e4SLinus Torvalds int val = *valp; 22271da177e4SLinus Torvalds if (val < 0) { 22281da177e4SLinus Torvalds *negp = -1; 22291da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22301da177e4SLinus Torvalds } else { 22311da177e4SLinus Torvalds *negp = 0; 22321da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22331da177e4SLinus Torvalds } 22341da177e4SLinus Torvalds } 22351da177e4SLinus Torvalds return 0; 22361da177e4SLinus Torvalds } 22371da177e4SLinus Torvalds 2238d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 2239fcfbd547SKirill Korotaev int write, struct file *filp, void __user *buffer, 2240fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 22411da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 22421da177e4SLinus Torvalds int write, void *data), 22431da177e4SLinus Torvalds void *data) 22441da177e4SLinus Torvalds { 22451da177e4SLinus Torvalds #define TMPBUFLEN 21 22461da177e4SLinus Torvalds int *i, vleft, first=1, neg, val; 22471da177e4SLinus Torvalds unsigned long lval; 22481da177e4SLinus Torvalds size_t left, len; 22491da177e4SLinus Torvalds 22501da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 22511da177e4SLinus Torvalds char __user *s = buffer; 22521da177e4SLinus Torvalds 2253fcfbd547SKirill Korotaev if (!tbl_data || !table->maxlen || !*lenp || 22541da177e4SLinus Torvalds (*ppos && !write)) { 22551da177e4SLinus Torvalds *lenp = 0; 22561da177e4SLinus Torvalds return 0; 22571da177e4SLinus Torvalds } 22581da177e4SLinus Torvalds 2259fcfbd547SKirill Korotaev i = (int *) tbl_data; 22601da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 22611da177e4SLinus Torvalds left = *lenp; 22621da177e4SLinus Torvalds 22631da177e4SLinus Torvalds if (!conv) 22641da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 22651da177e4SLinus Torvalds 22661da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 22671da177e4SLinus Torvalds if (write) { 22681da177e4SLinus Torvalds while (left) { 22691da177e4SLinus Torvalds char c; 22701da177e4SLinus Torvalds if (get_user(c, s)) 22711da177e4SLinus Torvalds return -EFAULT; 22721da177e4SLinus Torvalds if (!isspace(c)) 22731da177e4SLinus Torvalds break; 22741da177e4SLinus Torvalds left--; 22751da177e4SLinus Torvalds s++; 22761da177e4SLinus Torvalds } 22771da177e4SLinus Torvalds if (!left) 22781da177e4SLinus Torvalds break; 22791da177e4SLinus Torvalds neg = 0; 22801da177e4SLinus Torvalds len = left; 22811da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 22821da177e4SLinus Torvalds len = sizeof(buf) - 1; 22831da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 22841da177e4SLinus Torvalds return -EFAULT; 22851da177e4SLinus Torvalds buf[len] = 0; 22861da177e4SLinus Torvalds p = buf; 22871da177e4SLinus Torvalds if (*p == '-' && left > 1) { 22881da177e4SLinus Torvalds neg = 1; 2289bd9b0bacSBP, Praveen p++; 22901da177e4SLinus Torvalds } 22911da177e4SLinus Torvalds if (*p < '0' || *p > '9') 22921da177e4SLinus Torvalds break; 22931da177e4SLinus Torvalds 22941da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 22951da177e4SLinus Torvalds 22961da177e4SLinus Torvalds len = p-buf; 22971da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 22981da177e4SLinus Torvalds break; 22991da177e4SLinus Torvalds if (neg) 23001da177e4SLinus Torvalds val = -val; 23011da177e4SLinus Torvalds s += len; 23021da177e4SLinus Torvalds left -= len; 23031da177e4SLinus Torvalds 23041da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 23051da177e4SLinus Torvalds break; 23061da177e4SLinus Torvalds } else { 23071da177e4SLinus Torvalds p = buf; 23081da177e4SLinus Torvalds if (!first) 23091da177e4SLinus Torvalds *p++ = '\t'; 23101da177e4SLinus Torvalds 23111da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 23121da177e4SLinus Torvalds break; 23131da177e4SLinus Torvalds 23141da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 23151da177e4SLinus Torvalds len = strlen(buf); 23161da177e4SLinus Torvalds if (len > left) 23171da177e4SLinus Torvalds len = left; 23181da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 23191da177e4SLinus Torvalds return -EFAULT; 23201da177e4SLinus Torvalds left -= len; 23211da177e4SLinus Torvalds s += len; 23221da177e4SLinus Torvalds } 23231da177e4SLinus Torvalds } 23241da177e4SLinus Torvalds 23251da177e4SLinus Torvalds if (!write && !first && left) { 23261da177e4SLinus Torvalds if(put_user('\n', s)) 23271da177e4SLinus Torvalds return -EFAULT; 23281da177e4SLinus Torvalds left--, s++; 23291da177e4SLinus Torvalds } 23301da177e4SLinus Torvalds if (write) { 23311da177e4SLinus Torvalds while (left) { 23321da177e4SLinus Torvalds char c; 23331da177e4SLinus Torvalds if (get_user(c, s++)) 23341da177e4SLinus Torvalds return -EFAULT; 23351da177e4SLinus Torvalds if (!isspace(c)) 23361da177e4SLinus Torvalds break; 23371da177e4SLinus Torvalds left--; 23381da177e4SLinus Torvalds } 23391da177e4SLinus Torvalds } 23401da177e4SLinus Torvalds if (write && first) 23411da177e4SLinus Torvalds return -EINVAL; 23421da177e4SLinus Torvalds *lenp -= left; 23431da177e4SLinus Torvalds *ppos += *lenp; 23441da177e4SLinus Torvalds return 0; 23451da177e4SLinus Torvalds #undef TMPBUFLEN 23461da177e4SLinus Torvalds } 23471da177e4SLinus Torvalds 2348d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp, 2349fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2350fcfbd547SKirill Korotaev int (*conv)(int *negp, unsigned long *lvalp, int *valp, 2351fcfbd547SKirill Korotaev int write, void *data), 2352fcfbd547SKirill Korotaev void *data) 2353fcfbd547SKirill Korotaev { 2354fcfbd547SKirill Korotaev return __do_proc_dointvec(table->data, table, write, filp, 2355fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2356fcfbd547SKirill Korotaev } 2357fcfbd547SKirill Korotaev 23581da177e4SLinus Torvalds /** 23591da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 23601da177e4SLinus Torvalds * @table: the sysctl table 23611da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23621da177e4SLinus Torvalds * @filp: the file structure 23631da177e4SLinus Torvalds * @buffer: the user buffer 23641da177e4SLinus Torvalds * @lenp: the size of the user buffer 23651da177e4SLinus Torvalds * @ppos: file position 23661da177e4SLinus Torvalds * 23671da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23681da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23691da177e4SLinus Torvalds * 23701da177e4SLinus Torvalds * Returns 0 on success. 23711da177e4SLinus Torvalds */ 2372d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp, 23731da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23741da177e4SLinus Torvalds { 23751da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 23761da177e4SLinus Torvalds NULL,NULL); 23771da177e4SLinus Torvalds } 23781da177e4SLinus Torvalds 237934f5a398STheodore Ts'o /* 238034f5a398STheodore Ts'o * Taint values can only be increased 238125ddbb18SAndi Kleen * This means we can safely use a temporary. 238234f5a398STheodore Ts'o */ 238325ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp, 238434f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 238534f5a398STheodore Ts'o { 238625ddbb18SAndi Kleen struct ctl_table t; 238725ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 238825ddbb18SAndi Kleen int err; 238934f5a398STheodore Ts'o 239091fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 239134f5a398STheodore Ts'o return -EPERM; 239234f5a398STheodore Ts'o 239325ddbb18SAndi Kleen t = *table; 239425ddbb18SAndi Kleen t.data = &tmptaint; 239525ddbb18SAndi Kleen err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos); 239625ddbb18SAndi Kleen if (err < 0) 239725ddbb18SAndi Kleen return err; 239825ddbb18SAndi Kleen 239925ddbb18SAndi Kleen if (write) { 240025ddbb18SAndi Kleen /* 240125ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 240225ddbb18SAndi Kleen * to everyone's atomic.h for this 240325ddbb18SAndi Kleen */ 240425ddbb18SAndi Kleen int i; 240525ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 240625ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 240725ddbb18SAndi Kleen add_taint(i); 240825ddbb18SAndi Kleen } 240925ddbb18SAndi Kleen } 241025ddbb18SAndi Kleen 241125ddbb18SAndi Kleen return err; 241234f5a398STheodore Ts'o } 241334f5a398STheodore Ts'o 24141da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 24151da177e4SLinus Torvalds int *min; 24161da177e4SLinus Torvalds int *max; 24171da177e4SLinus Torvalds }; 24181da177e4SLinus Torvalds 24191da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 24201da177e4SLinus Torvalds int *valp, 24211da177e4SLinus Torvalds int write, void *data) 24221da177e4SLinus Torvalds { 24231da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 24241da177e4SLinus Torvalds if (write) { 24251da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 24261da177e4SLinus Torvalds if ((param->min && *param->min > val) || 24271da177e4SLinus Torvalds (param->max && *param->max < val)) 24281da177e4SLinus Torvalds return -EINVAL; 24291da177e4SLinus Torvalds *valp = val; 24301da177e4SLinus Torvalds } else { 24311da177e4SLinus Torvalds int val = *valp; 24321da177e4SLinus Torvalds if (val < 0) { 24331da177e4SLinus Torvalds *negp = -1; 24341da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 24351da177e4SLinus Torvalds } else { 24361da177e4SLinus Torvalds *negp = 0; 24371da177e4SLinus Torvalds *lvalp = (unsigned long)val; 24381da177e4SLinus Torvalds } 24391da177e4SLinus Torvalds } 24401da177e4SLinus Torvalds return 0; 24411da177e4SLinus Torvalds } 24421da177e4SLinus Torvalds 24431da177e4SLinus Torvalds /** 24441da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 24451da177e4SLinus Torvalds * @table: the sysctl table 24461da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24471da177e4SLinus Torvalds * @filp: the file structure 24481da177e4SLinus Torvalds * @buffer: the user buffer 24491da177e4SLinus Torvalds * @lenp: the size of the user buffer 24501da177e4SLinus Torvalds * @ppos: file position 24511da177e4SLinus Torvalds * 24521da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24531da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24541da177e4SLinus Torvalds * 24551da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24561da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24571da177e4SLinus Torvalds * 24581da177e4SLinus Torvalds * Returns 0 on success. 24591da177e4SLinus Torvalds */ 2460d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, 24611da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24621da177e4SLinus Torvalds { 24631da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 24641da177e4SLinus Torvalds .min = (int *) table->extra1, 24651da177e4SLinus Torvalds .max = (int *) table->extra2, 24661da177e4SLinus Torvalds }; 24671da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 24681da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 24691da177e4SLinus Torvalds } 24701da177e4SLinus Torvalds 2471d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 24721da177e4SLinus Torvalds struct file *filp, 24731da177e4SLinus Torvalds void __user *buffer, 24741da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 24751da177e4SLinus Torvalds unsigned long convmul, 24761da177e4SLinus Torvalds unsigned long convdiv) 24771da177e4SLinus Torvalds { 24781da177e4SLinus Torvalds #define TMPBUFLEN 21 24791da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 24801da177e4SLinus Torvalds int vleft, first=1, neg; 24811da177e4SLinus Torvalds size_t len, left; 24821da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 24831da177e4SLinus Torvalds char __user *s = buffer; 24841da177e4SLinus Torvalds 2485fcfbd547SKirill Korotaev if (!data || !table->maxlen || !*lenp || 24861da177e4SLinus Torvalds (*ppos && !write)) { 24871da177e4SLinus Torvalds *lenp = 0; 24881da177e4SLinus Torvalds return 0; 24891da177e4SLinus Torvalds } 24901da177e4SLinus Torvalds 2491fcfbd547SKirill Korotaev i = (unsigned long *) data; 24921da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 24931da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 24941da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 24951da177e4SLinus Torvalds left = *lenp; 24961da177e4SLinus Torvalds 24971da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 24981da177e4SLinus Torvalds if (write) { 24991da177e4SLinus Torvalds while (left) { 25001da177e4SLinus Torvalds char c; 25011da177e4SLinus Torvalds if (get_user(c, s)) 25021da177e4SLinus Torvalds return -EFAULT; 25031da177e4SLinus Torvalds if (!isspace(c)) 25041da177e4SLinus Torvalds break; 25051da177e4SLinus Torvalds left--; 25061da177e4SLinus Torvalds s++; 25071da177e4SLinus Torvalds } 25081da177e4SLinus Torvalds if (!left) 25091da177e4SLinus Torvalds break; 25101da177e4SLinus Torvalds neg = 0; 25111da177e4SLinus Torvalds len = left; 25121da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 25131da177e4SLinus Torvalds len = TMPBUFLEN-1; 25141da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 25151da177e4SLinus Torvalds return -EFAULT; 25161da177e4SLinus Torvalds buf[len] = 0; 25171da177e4SLinus Torvalds p = buf; 25181da177e4SLinus Torvalds if (*p == '-' && left > 1) { 25191da177e4SLinus Torvalds neg = 1; 2520bd9b0bacSBP, Praveen p++; 25211da177e4SLinus Torvalds } 25221da177e4SLinus Torvalds if (*p < '0' || *p > '9') 25231da177e4SLinus Torvalds break; 25241da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 25251da177e4SLinus Torvalds len = p-buf; 25261da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 25271da177e4SLinus Torvalds break; 25281da177e4SLinus Torvalds if (neg) 25291da177e4SLinus Torvalds val = -val; 25301da177e4SLinus Torvalds s += len; 25311da177e4SLinus Torvalds left -= len; 25321da177e4SLinus Torvalds 25331da177e4SLinus Torvalds if(neg) 25341da177e4SLinus Torvalds continue; 25351da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 25361da177e4SLinus Torvalds continue; 25371da177e4SLinus Torvalds *i = val; 25381da177e4SLinus Torvalds } else { 25391da177e4SLinus Torvalds p = buf; 25401da177e4SLinus Torvalds if (!first) 25411da177e4SLinus Torvalds *p++ = '\t'; 25421da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 25431da177e4SLinus Torvalds len = strlen(buf); 25441da177e4SLinus Torvalds if (len > left) 25451da177e4SLinus Torvalds len = left; 25461da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 25471da177e4SLinus Torvalds return -EFAULT; 25481da177e4SLinus Torvalds left -= len; 25491da177e4SLinus Torvalds s += len; 25501da177e4SLinus Torvalds } 25511da177e4SLinus Torvalds } 25521da177e4SLinus Torvalds 25531da177e4SLinus Torvalds if (!write && !first && left) { 25541da177e4SLinus Torvalds if(put_user('\n', s)) 25551da177e4SLinus Torvalds return -EFAULT; 25561da177e4SLinus Torvalds left--, s++; 25571da177e4SLinus Torvalds } 25581da177e4SLinus Torvalds if (write) { 25591da177e4SLinus Torvalds while (left) { 25601da177e4SLinus Torvalds char c; 25611da177e4SLinus Torvalds if (get_user(c, s++)) 25621da177e4SLinus Torvalds return -EFAULT; 25631da177e4SLinus Torvalds if (!isspace(c)) 25641da177e4SLinus Torvalds break; 25651da177e4SLinus Torvalds left--; 25661da177e4SLinus Torvalds } 25671da177e4SLinus Torvalds } 25681da177e4SLinus Torvalds if (write && first) 25691da177e4SLinus Torvalds return -EINVAL; 25701da177e4SLinus Torvalds *lenp -= left; 25711da177e4SLinus Torvalds *ppos += *lenp; 25721da177e4SLinus Torvalds return 0; 25731da177e4SLinus Torvalds #undef TMPBUFLEN 25741da177e4SLinus Torvalds } 25751da177e4SLinus Torvalds 2576d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2577fcfbd547SKirill Korotaev struct file *filp, 2578fcfbd547SKirill Korotaev void __user *buffer, 2579fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2580fcfbd547SKirill Korotaev unsigned long convmul, 2581fcfbd547SKirill Korotaev unsigned long convdiv) 2582fcfbd547SKirill Korotaev { 2583fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 2584fcfbd547SKirill Korotaev filp, buffer, lenp, ppos, convmul, convdiv); 2585fcfbd547SKirill Korotaev } 2586fcfbd547SKirill Korotaev 25871da177e4SLinus Torvalds /** 25881da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 25891da177e4SLinus Torvalds * @table: the sysctl table 25901da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25911da177e4SLinus Torvalds * @filp: the file structure 25921da177e4SLinus Torvalds * @buffer: the user buffer 25931da177e4SLinus Torvalds * @lenp: the size of the user buffer 25941da177e4SLinus Torvalds * @ppos: file position 25951da177e4SLinus Torvalds * 25961da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 25971da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25981da177e4SLinus Torvalds * 25991da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26001da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26011da177e4SLinus Torvalds * 26021da177e4SLinus Torvalds * Returns 0 on success. 26031da177e4SLinus Torvalds */ 2604d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, 26051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26061da177e4SLinus Torvalds { 26071da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l); 26081da177e4SLinus Torvalds } 26091da177e4SLinus Torvalds 26101da177e4SLinus Torvalds /** 26111da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 26121da177e4SLinus Torvalds * @table: the sysctl table 26131da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26141da177e4SLinus Torvalds * @filp: the file structure 26151da177e4SLinus Torvalds * @buffer: the user buffer 26161da177e4SLinus Torvalds * @lenp: the size of the user buffer 26171da177e4SLinus Torvalds * @ppos: file position 26181da177e4SLinus Torvalds * 26191da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26201da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 26211da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 26221da177e4SLinus Torvalds * 26231da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26241da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26251da177e4SLinus Torvalds * 26261da177e4SLinus Torvalds * Returns 0 on success. 26271da177e4SLinus Torvalds */ 2628d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26291da177e4SLinus Torvalds struct file *filp, 26301da177e4SLinus Torvalds void __user *buffer, 26311da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26321da177e4SLinus Torvalds { 26331da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, 26341da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 26351da177e4SLinus Torvalds } 26361da177e4SLinus Torvalds 26371da177e4SLinus Torvalds 26381da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 26391da177e4SLinus Torvalds int *valp, 26401da177e4SLinus Torvalds int write, void *data) 26411da177e4SLinus Torvalds { 26421da177e4SLinus Torvalds if (write) { 2643cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2644cba9f33dSBart Samwel return 1; 26451da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 26461da177e4SLinus Torvalds } else { 26471da177e4SLinus Torvalds int val = *valp; 26481da177e4SLinus Torvalds unsigned long lval; 26491da177e4SLinus Torvalds if (val < 0) { 26501da177e4SLinus Torvalds *negp = -1; 26511da177e4SLinus Torvalds lval = (unsigned long)-val; 26521da177e4SLinus Torvalds } else { 26531da177e4SLinus Torvalds *negp = 0; 26541da177e4SLinus Torvalds lval = (unsigned long)val; 26551da177e4SLinus Torvalds } 26561da177e4SLinus Torvalds *lvalp = lval / HZ; 26571da177e4SLinus Torvalds } 26581da177e4SLinus Torvalds return 0; 26591da177e4SLinus Torvalds } 26601da177e4SLinus Torvalds 26611da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 26621da177e4SLinus Torvalds int *valp, 26631da177e4SLinus Torvalds int write, void *data) 26641da177e4SLinus Torvalds { 26651da177e4SLinus Torvalds if (write) { 2666cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2667cba9f33dSBart Samwel return 1; 26681da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 26691da177e4SLinus Torvalds } else { 26701da177e4SLinus Torvalds int val = *valp; 26711da177e4SLinus Torvalds unsigned long lval; 26721da177e4SLinus Torvalds if (val < 0) { 26731da177e4SLinus Torvalds *negp = -1; 26741da177e4SLinus Torvalds lval = (unsigned long)-val; 26751da177e4SLinus Torvalds } else { 26761da177e4SLinus Torvalds *negp = 0; 26771da177e4SLinus Torvalds lval = (unsigned long)val; 26781da177e4SLinus Torvalds } 26791da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 26801da177e4SLinus Torvalds } 26811da177e4SLinus Torvalds return 0; 26821da177e4SLinus Torvalds } 26831da177e4SLinus Torvalds 26841da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 26851da177e4SLinus Torvalds int *valp, 26861da177e4SLinus Torvalds int write, void *data) 26871da177e4SLinus Torvalds { 26881da177e4SLinus Torvalds if (write) { 26891da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 26901da177e4SLinus Torvalds } else { 26911da177e4SLinus Torvalds int val = *valp; 26921da177e4SLinus Torvalds unsigned long lval; 26931da177e4SLinus Torvalds if (val < 0) { 26941da177e4SLinus Torvalds *negp = -1; 26951da177e4SLinus Torvalds lval = (unsigned long)-val; 26961da177e4SLinus Torvalds } else { 26971da177e4SLinus Torvalds *negp = 0; 26981da177e4SLinus Torvalds lval = (unsigned long)val; 26991da177e4SLinus Torvalds } 27001da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 27011da177e4SLinus Torvalds } 27021da177e4SLinus Torvalds return 0; 27031da177e4SLinus Torvalds } 27041da177e4SLinus Torvalds 27051da177e4SLinus Torvalds /** 27061da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 27071da177e4SLinus Torvalds * @table: the sysctl table 27081da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27091da177e4SLinus Torvalds * @filp: the file structure 27101da177e4SLinus Torvalds * @buffer: the user buffer 27111da177e4SLinus Torvalds * @lenp: the size of the user buffer 27121da177e4SLinus Torvalds * @ppos: file position 27131da177e4SLinus Torvalds * 27141da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27151da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27161da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 27171da177e4SLinus Torvalds * jiffies. 27181da177e4SLinus Torvalds * 27191da177e4SLinus Torvalds * Returns 0 on success. 27201da177e4SLinus Torvalds */ 2721d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, 27221da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27231da177e4SLinus Torvalds { 27241da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 27251da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 27261da177e4SLinus Torvalds } 27271da177e4SLinus Torvalds 27281da177e4SLinus Torvalds /** 27291da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 27301da177e4SLinus Torvalds * @table: the sysctl table 27311da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27321da177e4SLinus Torvalds * @filp: the file structure 27331da177e4SLinus Torvalds * @buffer: the user buffer 27341da177e4SLinus Torvalds * @lenp: the size of the user buffer 27351e5d5331SRandy Dunlap * @ppos: pointer to the file position 27361da177e4SLinus Torvalds * 27371da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27381da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27391da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 27401da177e4SLinus Torvalds * are converted into jiffies. 27411da177e4SLinus Torvalds * 27421da177e4SLinus Torvalds * Returns 0 on success. 27431da177e4SLinus Torvalds */ 2744d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, 27451da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27461da177e4SLinus Torvalds { 27471da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 27481da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 27491da177e4SLinus Torvalds } 27501da177e4SLinus Torvalds 27511da177e4SLinus Torvalds /** 27521da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 27531da177e4SLinus Torvalds * @table: the sysctl table 27541da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27551da177e4SLinus Torvalds * @filp: the file structure 27561da177e4SLinus Torvalds * @buffer: the user buffer 27571da177e4SLinus Torvalds * @lenp: the size of the user buffer 275867be2dd1SMartin Waitz * @ppos: file position 275967be2dd1SMartin Waitz * @ppos: the current position in the file 27601da177e4SLinus Torvalds * 27611da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27621da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27631da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 27641da177e4SLinus Torvalds * are converted into jiffies. 27651da177e4SLinus Torvalds * 27661da177e4SLinus Torvalds * Returns 0 on success. 27671da177e4SLinus Torvalds */ 2768d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, 27691da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27701da177e4SLinus Torvalds { 27711da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 27721da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 27731da177e4SLinus Torvalds } 27741da177e4SLinus Torvalds 2775d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 27769ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 27779ec52099SCedric Le Goater { 27789ec52099SCedric Le Goater struct pid *new_pid; 27799ec52099SCedric Le Goater pid_t tmp; 27809ec52099SCedric Le Goater int r; 27819ec52099SCedric Le Goater 27826c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 27839ec52099SCedric Le Goater 27849ec52099SCedric Le Goater r = __do_proc_dointvec(&tmp, table, write, filp, buffer, 27859ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 27869ec52099SCedric Le Goater if (r || !write) 27879ec52099SCedric Le Goater return r; 27889ec52099SCedric Le Goater 27899ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 27909ec52099SCedric Le Goater if (!new_pid) 27919ec52099SCedric Le Goater return -ESRCH; 27929ec52099SCedric Le Goater 27939ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 27949ec52099SCedric Le Goater return 0; 27959ec52099SCedric Le Goater } 27969ec52099SCedric Le Goater 27971da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 27981da177e4SLinus Torvalds 2799d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp, 28001da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28011da177e4SLinus Torvalds { 28021da177e4SLinus Torvalds return -ENOSYS; 28031da177e4SLinus Torvalds } 28041da177e4SLinus Torvalds 2805d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp, 28061da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28071da177e4SLinus Torvalds { 28081da177e4SLinus Torvalds return -ENOSYS; 28091da177e4SLinus Torvalds } 28101da177e4SLinus Torvalds 2811d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp, 28121da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28131da177e4SLinus Torvalds { 28141da177e4SLinus Torvalds return -ENOSYS; 28151da177e4SLinus Torvalds } 28161da177e4SLinus Torvalds 2817d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp, 28181da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28191da177e4SLinus Torvalds { 28201da177e4SLinus Torvalds return -ENOSYS; 28211da177e4SLinus Torvalds } 28221da177e4SLinus Torvalds 2823d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp, 28241da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28251da177e4SLinus Torvalds { 28261da177e4SLinus Torvalds return -ENOSYS; 28271da177e4SLinus Torvalds } 28281da177e4SLinus Torvalds 2829d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp, 28301da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28311da177e4SLinus Torvalds { 28321da177e4SLinus Torvalds return -ENOSYS; 28331da177e4SLinus Torvalds } 28341da177e4SLinus Torvalds 2835d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp, 28361da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 28371da177e4SLinus Torvalds { 28381da177e4SLinus Torvalds return -ENOSYS; 28391da177e4SLinus Torvalds } 28401da177e4SLinus Torvalds 2841d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 28421da177e4SLinus Torvalds struct file *filp, 28431da177e4SLinus Torvalds void __user *buffer, 28441da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 28451da177e4SLinus Torvalds { 28461da177e4SLinus Torvalds return -ENOSYS; 28471da177e4SLinus Torvalds } 28481da177e4SLinus Torvalds 28491da177e4SLinus Torvalds 28501da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 28511da177e4SLinus Torvalds 28521da177e4SLinus Torvalds 2853b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL 28541da177e4SLinus Torvalds /* 28551da177e4SLinus Torvalds * General sysctl support routines 28561da177e4SLinus Torvalds */ 28571da177e4SLinus Torvalds 285849a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */ 2859f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table, 286049a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 286149a0c458SEric W. Biederman void __user *newval, size_t newlen) 286249a0c458SEric W. Biederman { 286349a0c458SEric W. Biederman size_t len; 286449a0c458SEric W. Biederman 286549a0c458SEric W. Biederman /* Get out of I don't have a variable */ 286649a0c458SEric W. Biederman if (!table->data || !table->maxlen) 286749a0c458SEric W. Biederman return -ENOTDIR; 286849a0c458SEric W. Biederman 286949a0c458SEric W. Biederman if (oldval && oldlenp) { 287049a0c458SEric W. Biederman if (get_user(len, oldlenp)) 287149a0c458SEric W. Biederman return -EFAULT; 287249a0c458SEric W. Biederman if (len) { 287349a0c458SEric W. Biederman if (len > table->maxlen) 287449a0c458SEric W. Biederman len = table->maxlen; 287549a0c458SEric W. Biederman if (copy_to_user(oldval, table->data, len)) 287649a0c458SEric W. Biederman return -EFAULT; 287749a0c458SEric W. Biederman if (put_user(len, oldlenp)) 287849a0c458SEric W. Biederman return -EFAULT; 287949a0c458SEric W. Biederman } 288049a0c458SEric W. Biederman } 288149a0c458SEric W. Biederman 288249a0c458SEric W. Biederman if (newval && newlen) { 288349a0c458SEric W. Biederman if (newlen > table->maxlen) 288449a0c458SEric W. Biederman newlen = table->maxlen; 288549a0c458SEric W. Biederman 288649a0c458SEric W. Biederman if (copy_from_user(table->data, newval, newlen)) 288749a0c458SEric W. Biederman return -EFAULT; 288849a0c458SEric W. Biederman } 288949a0c458SEric W. Biederman return 1; 289049a0c458SEric W. Biederman } 289149a0c458SEric W. Biederman 28921da177e4SLinus Torvalds /* The generic string strategy routine: */ 2893f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table, 28941da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 28951f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 28961da177e4SLinus Torvalds { 28971da177e4SLinus Torvalds if (!table->data || !table->maxlen) 28981da177e4SLinus Torvalds return -ENOTDIR; 28991da177e4SLinus Torvalds 29001da177e4SLinus Torvalds if (oldval && oldlenp) { 2901de9e007dSLinus Torvalds size_t bufsize; 2902de9e007dSLinus Torvalds if (get_user(bufsize, oldlenp)) 29031da177e4SLinus Torvalds return -EFAULT; 2904de9e007dSLinus Torvalds if (bufsize) { 2905de9e007dSLinus Torvalds size_t len = strlen(table->data), copied; 2906de9e007dSLinus Torvalds 2907de9e007dSLinus Torvalds /* This shouldn't trigger for a well-formed sysctl */ 2908de9e007dSLinus Torvalds if (len > table->maxlen) 29091da177e4SLinus Torvalds len = table->maxlen; 2910de9e007dSLinus Torvalds 2911de9e007dSLinus Torvalds /* Copy up to a max of bufsize-1 bytes of the string */ 2912de9e007dSLinus Torvalds copied = (len >= bufsize) ? bufsize - 1 : len; 2913de9e007dSLinus Torvalds 2914de9e007dSLinus Torvalds if (copy_to_user(oldval, table->data, copied) || 2915de9e007dSLinus Torvalds put_user(0, (char __user *)(oldval + copied))) 29161da177e4SLinus Torvalds return -EFAULT; 29171da177e4SLinus Torvalds if (put_user(len, oldlenp)) 29181da177e4SLinus Torvalds return -EFAULT; 29191da177e4SLinus Torvalds } 29201da177e4SLinus Torvalds } 29211da177e4SLinus Torvalds if (newval && newlen) { 2922de9e007dSLinus Torvalds size_t len = newlen; 29231da177e4SLinus Torvalds if (len > table->maxlen) 29241da177e4SLinus Torvalds len = table->maxlen; 29251da177e4SLinus Torvalds if(copy_from_user(table->data, newval, len)) 29261da177e4SLinus Torvalds return -EFAULT; 29271da177e4SLinus Torvalds if (len == table->maxlen) 29281da177e4SLinus Torvalds len--; 29291da177e4SLinus Torvalds ((char *) table->data)[len] = 0; 29301da177e4SLinus Torvalds } 293182c9df82SYi Yang return 1; 29321da177e4SLinus Torvalds } 29331da177e4SLinus Torvalds 29341da177e4SLinus Torvalds /* 29351da177e4SLinus Torvalds * This function makes sure that all of the integers in the vector 29361da177e4SLinus Torvalds * are between the minimum and maximum values given in the arrays 29371da177e4SLinus Torvalds * table->extra1 and table->extra2, respectively. 29381da177e4SLinus Torvalds */ 2939f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table, 29401da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 29411f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 29421da177e4SLinus Torvalds { 29431da177e4SLinus Torvalds 29441da177e4SLinus Torvalds if (newval && newlen) { 29451da177e4SLinus Torvalds int __user *vec = (int __user *) newval; 29461da177e4SLinus Torvalds int *min = (int *) table->extra1; 29471da177e4SLinus Torvalds int *max = (int *) table->extra2; 29481da177e4SLinus Torvalds size_t length; 29491da177e4SLinus Torvalds int i; 29501da177e4SLinus Torvalds 29511da177e4SLinus Torvalds if (newlen % sizeof(int) != 0) 29521da177e4SLinus Torvalds return -EINVAL; 29531da177e4SLinus Torvalds 29541da177e4SLinus Torvalds if (!table->extra1 && !table->extra2) 29551da177e4SLinus Torvalds return 0; 29561da177e4SLinus Torvalds 29571da177e4SLinus Torvalds if (newlen > table->maxlen) 29581da177e4SLinus Torvalds newlen = table->maxlen; 29591da177e4SLinus Torvalds length = newlen / sizeof(int); 29601da177e4SLinus Torvalds 29611da177e4SLinus Torvalds for (i = 0; i < length; i++) { 29621da177e4SLinus Torvalds int value; 29631da177e4SLinus Torvalds if (get_user(value, vec + i)) 29641da177e4SLinus Torvalds return -EFAULT; 29651da177e4SLinus Torvalds if (min && value < min[i]) 29661da177e4SLinus Torvalds return -EINVAL; 29671da177e4SLinus Torvalds if (max && value > max[i]) 29681da177e4SLinus Torvalds return -EINVAL; 29691da177e4SLinus Torvalds } 29701da177e4SLinus Torvalds } 29711da177e4SLinus Torvalds return 0; 29721da177e4SLinus Torvalds } 29731da177e4SLinus Torvalds 29741da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 2975f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table, 29761da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 29771f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 29781da177e4SLinus Torvalds { 29793ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 29801da177e4SLinus Torvalds size_t olen; 29813ee75ac3SAlexey Dobriyan 29821da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 29831da177e4SLinus Torvalds return -EFAULT; 29843ee75ac3SAlexey Dobriyan if (olen) { 29853ee75ac3SAlexey Dobriyan int val; 29863ee75ac3SAlexey Dobriyan 29873ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 29881da177e4SLinus Torvalds return -EINVAL; 29893ee75ac3SAlexey Dobriyan 29903ee75ac3SAlexey Dobriyan val = *(int *)(table->data) / HZ; 29913ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 29921da177e4SLinus Torvalds return -EFAULT; 29933ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 29943ee75ac3SAlexey Dobriyan return -EFAULT; 29953ee75ac3SAlexey Dobriyan } 29961da177e4SLinus Torvalds } 29971da177e4SLinus Torvalds if (newval && newlen) { 29981da177e4SLinus Torvalds int new; 29991da177e4SLinus Torvalds if (newlen != sizeof(int)) 30001da177e4SLinus Torvalds return -EINVAL; 30011da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 30021da177e4SLinus Torvalds return -EFAULT; 30031da177e4SLinus Torvalds *(int *)(table->data) = new*HZ; 30041da177e4SLinus Torvalds } 30051da177e4SLinus Torvalds return 1; 30061da177e4SLinus Torvalds } 30071da177e4SLinus Torvalds 30081da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 3009f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table, 30101da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30111f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30121da177e4SLinus Torvalds { 30133ee75ac3SAlexey Dobriyan if (oldval && oldlenp) { 30141da177e4SLinus Torvalds size_t olen; 30153ee75ac3SAlexey Dobriyan 30161da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 30171da177e4SLinus Torvalds return -EFAULT; 30183ee75ac3SAlexey Dobriyan if (olen) { 30193ee75ac3SAlexey Dobriyan int val; 30203ee75ac3SAlexey Dobriyan 30213ee75ac3SAlexey Dobriyan if (olen < sizeof(int)) 30221da177e4SLinus Torvalds return -EINVAL; 30233ee75ac3SAlexey Dobriyan 30243ee75ac3SAlexey Dobriyan val = jiffies_to_msecs(*(int *)(table->data)); 30253ee75ac3SAlexey Dobriyan if (put_user(val, (int __user *)oldval)) 30261da177e4SLinus Torvalds return -EFAULT; 30273ee75ac3SAlexey Dobriyan if (put_user(sizeof(int), oldlenp)) 30283ee75ac3SAlexey Dobriyan return -EFAULT; 30293ee75ac3SAlexey Dobriyan } 30301da177e4SLinus Torvalds } 30311da177e4SLinus Torvalds if (newval && newlen) { 30321da177e4SLinus Torvalds int new; 30331da177e4SLinus Torvalds if (newlen != sizeof(int)) 30341da177e4SLinus Torvalds return -EINVAL; 30351da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 30361da177e4SLinus Torvalds return -EFAULT; 30371da177e4SLinus Torvalds *(int *)(table->data) = msecs_to_jiffies(new); 30381da177e4SLinus Torvalds } 30391da177e4SLinus Torvalds return 1; 30401da177e4SLinus Torvalds } 30411da177e4SLinus Torvalds 3042c4b8b769SEric W. Biederman 3043c4b8b769SEric W. Biederman 3044b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */ 30451da177e4SLinus Torvalds 30461da177e4SLinus Torvalds 30471e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) 30481da177e4SLinus Torvalds { 30490e009be8SEric W. Biederman struct __sysctl_args tmp; 30507058cb02SEric W. Biederman int error; 30510e009be8SEric W. Biederman 30520e009be8SEric W. Biederman if (copy_from_user(&tmp, args, sizeof(tmp))) 30530e009be8SEric W. Biederman return -EFAULT; 30540e009be8SEric W. Biederman 30557058cb02SEric W. Biederman error = deprecated_sysctl_warning(&tmp); 3056b89a8171SEric W. Biederman 30577058cb02SEric W. Biederman /* If no error reading the parameters then just -ENOSYS ... */ 30587058cb02SEric W. Biederman if (!error) 30597058cb02SEric W. Biederman error = -ENOSYS; 30607058cb02SEric W. Biederman 30617058cb02SEric W. Biederman return error; 30621da177e4SLinus Torvalds } 30631da177e4SLinus Torvalds 3064f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table, 306549a0c458SEric W. Biederman void __user *oldval, size_t __user *oldlenp, 306649a0c458SEric W. Biederman void __user *newval, size_t newlen) 306749a0c458SEric W. Biederman { 306849a0c458SEric W. Biederman return -ENOSYS; 306949a0c458SEric W. Biederman } 307049a0c458SEric W. Biederman 3071f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table, 30721da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30731f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30741da177e4SLinus Torvalds { 30751da177e4SLinus Torvalds return -ENOSYS; 30761da177e4SLinus Torvalds } 30771da177e4SLinus Torvalds 3078f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table, 30791da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30801f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30811da177e4SLinus Torvalds { 30821da177e4SLinus Torvalds return -ENOSYS; 30831da177e4SLinus Torvalds } 30841da177e4SLinus Torvalds 3085f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table, 30861da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30871f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30881da177e4SLinus Torvalds { 30891da177e4SLinus Torvalds return -ENOSYS; 30901da177e4SLinus Torvalds } 30911da177e4SLinus Torvalds 3092f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table, 30931da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 30941f29bcd7SAlexey Dobriyan void __user *newval, size_t newlen) 30951da177e4SLinus Torvalds { 30961da177e4SLinus Torvalds return -ENOSYS; 30971da177e4SLinus Torvalds } 30981da177e4SLinus Torvalds 3099b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */ 31001da177e4SLinus Torvalds 31017058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args) 31027058cb02SEric W. Biederman { 31037058cb02SEric W. Biederman static int msg_count; 31047058cb02SEric W. Biederman int name[CTL_MAXNAME]; 31057058cb02SEric W. Biederman int i; 31067058cb02SEric W. Biederman 31076fc48af8STetsuo Handa /* Check args->nlen. */ 31086fc48af8STetsuo Handa if (args->nlen < 0 || args->nlen > CTL_MAXNAME) 31096fc48af8STetsuo Handa return -ENOTDIR; 31106fc48af8STetsuo Handa 31117058cb02SEric W. Biederman /* Read in the sysctl name for better debug message logging */ 31127058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 31137058cb02SEric W. Biederman if (get_user(name[i], args->name + i)) 31147058cb02SEric W. Biederman return -EFAULT; 31157058cb02SEric W. Biederman 31167058cb02SEric W. Biederman /* Ignore accesses to kernel.version */ 31177058cb02SEric W. Biederman if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION)) 31187058cb02SEric W. Biederman return 0; 31197058cb02SEric W. Biederman 31207058cb02SEric W. Biederman if (msg_count < 5) { 31217058cb02SEric W. Biederman msg_count++; 31227058cb02SEric W. Biederman printk(KERN_INFO 31237058cb02SEric W. Biederman "warning: process `%s' used the deprecated sysctl " 31247058cb02SEric W. Biederman "system call with ", current->comm); 31257058cb02SEric W. Biederman for (i = 0; i < args->nlen; i++) 31267058cb02SEric W. Biederman printk("%d.", name[i]); 31277058cb02SEric W. Biederman printk("\n"); 31287058cb02SEric W. Biederman } 31297058cb02SEric W. Biederman return 0; 31307058cb02SEric W. Biederman } 31317058cb02SEric W. Biederman 31321da177e4SLinus Torvalds /* 31331da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 31341da177e4SLinus Torvalds * exception granted :-) 31351da177e4SLinus Torvalds */ 31361da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 31371da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 31381da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 31391da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 31401da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 31411da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 31421da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 31431da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 31441da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 314529e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 31461da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec); 31471da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies); 31481da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies); 31491da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string); 315049a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data); 31511da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 3152