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> 26d33ed52dSDave Young #include <linux/signal.h> 27455cd5abSDan Rosenberg #include <linux/printk.h> 281da177e4SLinus Torvalds #include <linux/proc_fs.h> 2972c2d582SAndrew Morgan #include <linux/security.h> 301da177e4SLinus Torvalds #include <linux/ctype.h> 31dfec072eSVegard Nossum #include <linux/kmemcheck.h> 3262239ac2SAdrian Bunk #include <linux/fs.h> 331da177e4SLinus Torvalds #include <linux/init.h> 341da177e4SLinus Torvalds #include <linux/kernel.h> 350296b228SKay Sievers #include <linux/kobject.h> 3620380731SArnaldo Carvalho de Melo #include <linux/net.h> 371da177e4SLinus Torvalds #include <linux/sysrq.h> 381da177e4SLinus Torvalds #include <linux/highuid.h> 391da177e4SLinus Torvalds #include <linux/writeback.h> 403fff4c42SIngo Molnar #include <linux/ratelimit.h> 4176ab0f53SMel Gorman #include <linux/compaction.h> 421da177e4SLinus Torvalds #include <linux/hugetlb.h> 431da177e4SLinus Torvalds #include <linux/initrd.h> 440b77f5bfSDavid Howells #include <linux/key.h> 451da177e4SLinus Torvalds #include <linux/times.h> 461da177e4SLinus Torvalds #include <linux/limits.h> 471da177e4SLinus Torvalds #include <linux/dcache.h> 486e006701SAlexey Dobriyan #include <linux/dnotify.h> 491da177e4SLinus Torvalds #include <linux/syscalls.h> 50c748e134SAdrian Bunk #include <linux/vmstat.h> 51c255d844SPavel Machek #include <linux/nfs_fs.h> 52c255d844SPavel Machek #include <linux/acpi.h> 5310a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 54b0fc494fSSteven Rostedt #include <linux/ftrace.h> 55cdd6c482SIngo Molnar #include <linux/perf_event.h> 56b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 57b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 588e4228e1SDavid Rientjes #include <linux/oom.h> 5917f60a7dSEric Paris #include <linux/kmod.h> 6073efc039SDan Ballard #include <linux/capability.h> 6140401530SAl Viro #include <linux/binfmts.h> 621da177e4SLinus Torvalds 631da177e4SLinus Torvalds #include <asm/uaccess.h> 641da177e4SLinus Torvalds #include <asm/processor.h> 651da177e4SLinus Torvalds 6629cbc78bSAndi Kleen #ifdef CONFIG_X86 6729cbc78bSAndi Kleen #include <asm/nmi.h> 680741f4d2SChuck Ebbert #include <asm/stacktrace.h> 696e7c4025SIngo Molnar #include <asm/io.h> 7029cbc78bSAndi Kleen #endif 71*d550bbd4SDavid Howells #ifdef CONFIG_SPARC 72*d550bbd4SDavid Howells #include <asm/setup.h> 73*d550bbd4SDavid Howells #endif 74c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 75c55b7c3eSDave Young #include <linux/acct.h> 76c55b7c3eSDave Young #endif 774f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 784f0e056fSDave Young #include <linux/rtmutex.h> 794f0e056fSDave Young #endif 802edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 812edf5e49SDave Young #include <linux/lockdep.h> 822edf5e49SDave Young #endif 8315485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 8415485a46SDave Young #include <scsi/sg.h> 8515485a46SDave Young #endif 8629cbc78bSAndi Kleen 8758687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 88504d7cf1SDon Zickus #include <linux/nmi.h> 89504d7cf1SDon Zickus #endif 90504d7cf1SDon Zickus 917058cb02SEric W. Biederman 921da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 931da177e4SLinus Torvalds 941da177e4SLinus Torvalds /* External variables not in a header file. */ 951da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 961da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 971da177e4SLinus Torvalds extern int max_threads; 981da177e4SLinus Torvalds extern int core_uses_pid; 99d6e71144SAlan Cox extern int suid_dumpable; 1001da177e4SLinus Torvalds extern char core_pattern[]; 101a293980cSNeil Horman extern unsigned int core_pipe_limit; 1021da177e4SLinus Torvalds extern int pid_max; 1031da177e4SLinus Torvalds extern int min_free_kbytes; 1041da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 1059d0243bcSAndrew Morton extern int sysctl_drop_caches; 1068ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 107bebfa101SAndi Kleen extern int compat_log; 1089745512cSArjan van de Ven extern int latencytop_enabled; 109eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 110dd8632a1SPaul Mundt #ifndef CONFIG_MMU 111dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 112dd8632a1SPaul Mundt #endif 113cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 1145e605b64SJens Axboe extern int blk_iopoll_enabled; 115cb684b5bSJens Axboe #endif 1161da177e4SLinus Torvalds 117c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1182508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 119c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1209383d967SDimitri Sivanich static int neg_one = -1; 121c4f3b63fSRavikiran G Thirumalai #endif 122c4f3b63fSRavikiran G Thirumalai 123c4f3b63fSRavikiran G Thirumalai static int zero; 124cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 125cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 126cb16e95fSPetr Holasek static int __maybe_unused three = 3; 127fc3501d4SSven Wegener static unsigned long one_ul = 1; 128c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 129af91322eSDave Young #ifdef CONFIG_PRINTK 130af91322eSDave Young static int ten_thousand = 10000; 131af91322eSDave Young #endif 132c4f3b63fSRavikiran G Thirumalai 1339e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1349e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1359e4a5bdaSAndrea Righi 1361da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1371da177e4SLinus Torvalds static int maxolduid = 65535; 1381da177e4SLinus Torvalds static int minolduid; 1398ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1401da177e4SLinus Torvalds 1411da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 14273efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1431da177e4SLinus Torvalds 144d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 145d14f1729SDave Young #include <linux/inotify.h> 146d14f1729SDave Young #endif 14772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 14817f04fbbSDavid S. Miller #include <asm/system.h> 1491da177e4SLinus Torvalds #endif 1501da177e4SLinus Torvalds 1510871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1520871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1530871420fSDavid S. Miller #endif 1540871420fSDavid S. Miller 1551da177e4SLinus Torvalds #ifdef __hppa__ 1561da177e4SLinus Torvalds extern int pwrsw_enabled; 1571da177e4SLinus Torvalds extern int unaligned_enabled; 1581da177e4SLinus Torvalds #endif 1591da177e4SLinus Torvalds 160d2b176edSJes Sorensen #ifdef CONFIG_IA64 161d2b176edSJes Sorensen extern int no_unaligned_warning; 16288fc241fSDoug Chapman extern int unaligned_dump_stack; 163d2b176edSJes Sorensen #endif 164d2b176edSJes Sorensen 165d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1668d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1679ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1688d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 16934f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 170d6f8ff73SRandy Dunlap #endif 1719ec52099SCedric Le Goater 172bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 173bfdc0b49SRichard Weinberger static int proc_dmesg_restrict(struct ctl_table *table, int write, 174bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos); 175bfdc0b49SRichard Weinberger #endif 176bfdc0b49SRichard Weinberger 17797f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ 1788c6a98b2SAndy Whitcroft /* Note: sysrq code uses it's own private copy */ 1798c6a98b2SAndy Whitcroft static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; 18097f5f0cdSDmitry Torokhov 18197f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write, 18297f5f0cdSDmitry Torokhov void __user *buffer, size_t *lenp, 18397f5f0cdSDmitry Torokhov loff_t *ppos) 18497f5f0cdSDmitry Torokhov { 18597f5f0cdSDmitry Torokhov int error; 18697f5f0cdSDmitry Torokhov 18797f5f0cdSDmitry Torokhov error = proc_dointvec(table, write, buffer, lenp, ppos); 18897f5f0cdSDmitry Torokhov if (error) 18997f5f0cdSDmitry Torokhov return error; 19097f5f0cdSDmitry Torokhov 19197f5f0cdSDmitry Torokhov if (write) 19297f5f0cdSDmitry Torokhov sysrq_toggle_support(__sysrq_enabled); 19397f5f0cdSDmitry Torokhov 19497f5f0cdSDmitry Torokhov return 0; 19597f5f0cdSDmitry Torokhov } 19697f5f0cdSDmitry Torokhov 19797f5f0cdSDmitry Torokhov #endif 19897f5f0cdSDmitry Torokhov 199d8217f07SEric W. Biederman static struct ctl_table root_table[]; 200e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 201e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 202dfef6dcdSAl Viro {{.count = 1, 203e51b6ba0SEric W. Biederman .ctl_table = root_table, 204dfef6dcdSAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, 205e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 20673455092SAl Viro .set = &sysctl_table_root.default_set, 207e51b6ba0SEric W. Biederman }; 208e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 209e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 21073455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 211e51b6ba0SEric W. Biederman }; 2121da177e4SLinus Torvalds 213d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 214d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 215d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 216d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 217d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 218d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 2197ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 2207ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 2217ef9964eSDavide Libenzi #endif 2221da177e4SLinus Torvalds 2231da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2241da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2251da177e4SLinus Torvalds #endif 2261da177e4SLinus Torvalds 2271da177e4SLinus Torvalds /* The default sysctl tables: */ 2281da177e4SLinus Torvalds 229d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2301da177e4SLinus Torvalds { 2311da177e4SLinus Torvalds .procname = "kernel", 2321da177e4SLinus Torvalds .mode = 0555, 2331da177e4SLinus Torvalds .child = kern_table, 2341da177e4SLinus Torvalds }, 2351da177e4SLinus Torvalds { 2361da177e4SLinus Torvalds .procname = "vm", 2371da177e4SLinus Torvalds .mode = 0555, 2381da177e4SLinus Torvalds .child = vm_table, 2391da177e4SLinus Torvalds }, 2401da177e4SLinus Torvalds { 2411da177e4SLinus Torvalds .procname = "fs", 2421da177e4SLinus Torvalds .mode = 0555, 2431da177e4SLinus Torvalds .child = fs_table, 2441da177e4SLinus Torvalds }, 2451da177e4SLinus Torvalds { 2461da177e4SLinus Torvalds .procname = "debug", 2471da177e4SLinus Torvalds .mode = 0555, 2481da177e4SLinus Torvalds .child = debug_table, 2491da177e4SLinus Torvalds }, 2501da177e4SLinus Torvalds { 2511da177e4SLinus Torvalds .procname = "dev", 2521da177e4SLinus Torvalds .mode = 0555, 2531da177e4SLinus Torvalds .child = dev_table, 2541da177e4SLinus Torvalds }, 2556fce56ecSEric W. Biederman { } 2561da177e4SLinus Torvalds }; 2571da177e4SLinus Torvalds 25877e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 25973c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 26073c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 26173c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 26273c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2631983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2641983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 26577e54a1fSIngo Molnar #endif 26677e54a1fSIngo Molnar 2675e771905SMel Gorman #ifdef CONFIG_COMPACTION 2685e771905SMel Gorman static int min_extfrag_threshold; 2695e771905SMel Gorman static int max_extfrag_threshold = 1000; 2705e771905SMel Gorman #endif 2715e771905SMel Gorman 272d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2732bba22c5SMike Galbraith { 2742bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2752bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2762bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2772bba22c5SMike Galbraith .mode = 0644, 2786d456111SEric W. Biederman .proc_handler = proc_dointvec, 2792bba22c5SMike Galbraith }, 28077e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 28177e54a1fSIngo Molnar { 282b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 283b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 28477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28577e54a1fSIngo Molnar .mode = 0644, 286702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 287b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 288b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28977e54a1fSIngo Molnar }, 29077e54a1fSIngo Molnar { 29121805085SPeter Zijlstra .procname = "sched_latency_ns", 29221805085SPeter Zijlstra .data = &sysctl_sched_latency, 29321805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 29421805085SPeter Zijlstra .mode = 0644, 295702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 29621805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 29721805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 29821805085SPeter Zijlstra }, 29921805085SPeter Zijlstra { 30077e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 30177e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 30277e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 30377e54a1fSIngo Molnar .mode = 0644, 304702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 30577e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 30677e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 30777e54a1fSIngo Molnar }, 30877e54a1fSIngo Molnar { 3091983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3101983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3111983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3121983a922SChristian Ehrhardt .mode = 0644, 313702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3141983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3151983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3162398f2c6SPeter Zijlstra }, 3172398f2c6SPeter Zijlstra { 318da84d961SIngo Molnar .procname = "sched_migration_cost", 319da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 320da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 321da84d961SIngo Molnar .mode = 0644, 3226d456111SEric W. Biederman .proc_handler = proc_dointvec, 323da84d961SIngo Molnar }, 324b82d9fddSPeter Zijlstra { 325b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 326b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 327b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 328fa85ae24SPeter Zijlstra .mode = 0644, 3296d456111SEric W. Biederman .proc_handler = proc_dointvec, 330fa85ae24SPeter Zijlstra }, 331cd1bb94bSArun R Bharadwaj { 332e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 333e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 334e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 335e9e9250bSPeter Zijlstra .mode = 0644, 3366d456111SEric W. Biederman .proc_handler = proc_dointvec, 337e9e9250bSPeter Zijlstra }, 338e9e9250bSPeter Zijlstra { 339a7a4f8a7SPaul Turner .procname = "sched_shares_window", 340a7a4f8a7SPaul Turner .data = &sysctl_sched_shares_window, 341a7a4f8a7SPaul Turner .maxlen = sizeof(unsigned int), 342a7a4f8a7SPaul Turner .mode = 0644, 343a7a4f8a7SPaul Turner .proc_handler = proc_dointvec, 344a7a4f8a7SPaul Turner }, 345a7a4f8a7SPaul Turner { 346cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 347cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 348cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 349cd1bb94bSArun R Bharadwaj .mode = 0644, 3506d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 351bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 352bfdb4d9fSArun R Bharadwaj .extra2 = &one, 353cd1bb94bSArun R Bharadwaj }, 3541fc84aaaSPeter Zijlstra #endif 3551799e35dSIngo Molnar { 3569f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3579f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3589f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3599f0c1e56SPeter Zijlstra .mode = 0644, 3606d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3619f0c1e56SPeter Zijlstra }, 3629f0c1e56SPeter Zijlstra { 3639f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3649f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3659f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3669f0c1e56SPeter Zijlstra .mode = 0644, 3676d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3689f0c1e56SPeter Zijlstra }, 3695091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 3705091faa4SMike Galbraith { 3715091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 3725091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 3735091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 3745091faa4SMike Galbraith .mode = 0644, 3751747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 3765091faa4SMike Galbraith .extra1 = &zero, 3775091faa4SMike Galbraith .extra2 = &one, 3785091faa4SMike Galbraith }, 3795091faa4SMike Galbraith #endif 380ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 381ec12cb7fSPaul Turner { 382ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 383ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 384ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 385ec12cb7fSPaul Turner .mode = 0644, 386ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 387ec12cb7fSPaul Turner .extra1 = &one, 388ec12cb7fSPaul Turner }, 389ec12cb7fSPaul Turner #endif 390f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 391f20786ffSPeter Zijlstra { 392f20786ffSPeter Zijlstra .procname = "prove_locking", 393f20786ffSPeter Zijlstra .data = &prove_locking, 394f20786ffSPeter Zijlstra .maxlen = sizeof(int), 395f20786ffSPeter Zijlstra .mode = 0644, 3966d456111SEric W. Biederman .proc_handler = proc_dointvec, 397f20786ffSPeter Zijlstra }, 398f20786ffSPeter Zijlstra #endif 399f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 400f20786ffSPeter Zijlstra { 401f20786ffSPeter Zijlstra .procname = "lock_stat", 402f20786ffSPeter Zijlstra .data = &lock_stat, 403f20786ffSPeter Zijlstra .maxlen = sizeof(int), 404f20786ffSPeter Zijlstra .mode = 0644, 4056d456111SEric W. Biederman .proc_handler = proc_dointvec, 406f20786ffSPeter Zijlstra }, 407f20786ffSPeter Zijlstra #endif 40877e54a1fSIngo Molnar { 4091da177e4SLinus Torvalds .procname = "panic", 4101da177e4SLinus Torvalds .data = &panic_timeout, 4111da177e4SLinus Torvalds .maxlen = sizeof(int), 4121da177e4SLinus Torvalds .mode = 0644, 4136d456111SEric W. Biederman .proc_handler = proc_dointvec, 4141da177e4SLinus Torvalds }, 4151da177e4SLinus Torvalds { 4161da177e4SLinus Torvalds .procname = "core_uses_pid", 4171da177e4SLinus Torvalds .data = &core_uses_pid, 4181da177e4SLinus Torvalds .maxlen = sizeof(int), 4191da177e4SLinus Torvalds .mode = 0644, 4206d456111SEric W. Biederman .proc_handler = proc_dointvec, 4211da177e4SLinus Torvalds }, 4221da177e4SLinus Torvalds { 4231da177e4SLinus Torvalds .procname = "core_pattern", 4241da177e4SLinus Torvalds .data = core_pattern, 42571ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4261da177e4SLinus Torvalds .mode = 0644, 4276d456111SEric W. Biederman .proc_handler = proc_dostring, 4281da177e4SLinus Torvalds }, 429a293980cSNeil Horman { 430a293980cSNeil Horman .procname = "core_pipe_limit", 431a293980cSNeil Horman .data = &core_pipe_limit, 432a293980cSNeil Horman .maxlen = sizeof(unsigned int), 433a293980cSNeil Horman .mode = 0644, 4346d456111SEric W. Biederman .proc_handler = proc_dointvec, 435a293980cSNeil Horman }, 43634f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4371da177e4SLinus Torvalds { 4381da177e4SLinus Torvalds .procname = "tainted", 43925ddbb18SAndi Kleen .maxlen = sizeof(long), 44034f5a398STheodore Ts'o .mode = 0644, 4416d456111SEric W. Biederman .proc_handler = proc_taint, 4421da177e4SLinus Torvalds }, 44334f5a398STheodore Ts'o #endif 4449745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4459745512cSArjan van de Ven { 4469745512cSArjan van de Ven .procname = "latencytop", 4479745512cSArjan van de Ven .data = &latencytop_enabled, 4489745512cSArjan van de Ven .maxlen = sizeof(int), 4499745512cSArjan van de Ven .mode = 0644, 4506d456111SEric W. Biederman .proc_handler = proc_dointvec, 4519745512cSArjan van de Ven }, 4529745512cSArjan van de Ven #endif 4531da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4541da177e4SLinus Torvalds { 4551da177e4SLinus Torvalds .procname = "real-root-dev", 4561da177e4SLinus Torvalds .data = &real_root_dev, 4571da177e4SLinus Torvalds .maxlen = sizeof(int), 4581da177e4SLinus Torvalds .mode = 0644, 4596d456111SEric W. Biederman .proc_handler = proc_dointvec, 4601da177e4SLinus Torvalds }, 4611da177e4SLinus Torvalds #endif 46245807a1dSIngo Molnar { 46345807a1dSIngo Molnar .procname = "print-fatal-signals", 46445807a1dSIngo Molnar .data = &print_fatal_signals, 46545807a1dSIngo Molnar .maxlen = sizeof(int), 46645807a1dSIngo Molnar .mode = 0644, 4676d456111SEric W. Biederman .proc_handler = proc_dointvec, 46845807a1dSIngo Molnar }, 46972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4701da177e4SLinus Torvalds { 4711da177e4SLinus Torvalds .procname = "reboot-cmd", 4721da177e4SLinus Torvalds .data = reboot_command, 4731da177e4SLinus Torvalds .maxlen = 256, 4741da177e4SLinus Torvalds .mode = 0644, 4756d456111SEric W. Biederman .proc_handler = proc_dostring, 4761da177e4SLinus Torvalds }, 4771da177e4SLinus Torvalds { 4781da177e4SLinus Torvalds .procname = "stop-a", 4791da177e4SLinus Torvalds .data = &stop_a_enabled, 4801da177e4SLinus Torvalds .maxlen = sizeof (int), 4811da177e4SLinus Torvalds .mode = 0644, 4826d456111SEric W. Biederman .proc_handler = proc_dointvec, 4831da177e4SLinus Torvalds }, 4841da177e4SLinus Torvalds { 4851da177e4SLinus Torvalds .procname = "scons-poweroff", 4861da177e4SLinus Torvalds .data = &scons_pwroff, 4871da177e4SLinus Torvalds .maxlen = sizeof (int), 4881da177e4SLinus Torvalds .mode = 0644, 4896d456111SEric W. Biederman .proc_handler = proc_dointvec, 4901da177e4SLinus Torvalds }, 4911da177e4SLinus Torvalds #endif 4920871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4930871420fSDavid S. Miller { 4940871420fSDavid S. Miller .procname = "tsb-ratio", 4950871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4960871420fSDavid S. Miller .maxlen = sizeof (int), 4970871420fSDavid S. Miller .mode = 0644, 4986d456111SEric W. Biederman .proc_handler = proc_dointvec, 4990871420fSDavid S. Miller }, 5000871420fSDavid S. Miller #endif 5011da177e4SLinus Torvalds #ifdef __hppa__ 5021da177e4SLinus Torvalds { 5031da177e4SLinus Torvalds .procname = "soft-power", 5041da177e4SLinus Torvalds .data = &pwrsw_enabled, 5051da177e4SLinus Torvalds .maxlen = sizeof (int), 5061da177e4SLinus Torvalds .mode = 0644, 5076d456111SEric W. Biederman .proc_handler = proc_dointvec, 5081da177e4SLinus Torvalds }, 5091da177e4SLinus Torvalds { 5101da177e4SLinus Torvalds .procname = "unaligned-trap", 5111da177e4SLinus Torvalds .data = &unaligned_enabled, 5121da177e4SLinus Torvalds .maxlen = sizeof (int), 5131da177e4SLinus Torvalds .mode = 0644, 5146d456111SEric W. Biederman .proc_handler = proc_dointvec, 5151da177e4SLinus Torvalds }, 5161da177e4SLinus Torvalds #endif 5171da177e4SLinus Torvalds { 5181da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5191da177e4SLinus Torvalds .data = &C_A_D, 5201da177e4SLinus Torvalds .maxlen = sizeof(int), 5211da177e4SLinus Torvalds .mode = 0644, 5226d456111SEric W. Biederman .proc_handler = proc_dointvec, 5231da177e4SLinus Torvalds }, 524606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 525b0fc494fSSteven Rostedt { 526b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 527b0fc494fSSteven Rostedt .data = &ftrace_enabled, 528b0fc494fSSteven Rostedt .maxlen = sizeof(int), 529b0fc494fSSteven Rostedt .mode = 0644, 5306d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 531b0fc494fSSteven Rostedt }, 532b0fc494fSSteven Rostedt #endif 533f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 534f38f1d2aSSteven Rostedt { 535f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 536f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 537f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 538f38f1d2aSSteven Rostedt .mode = 0644, 5396d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 540f38f1d2aSSteven Rostedt }, 541f38f1d2aSSteven Rostedt #endif 542944ac425SSteven Rostedt #ifdef CONFIG_TRACING 543944ac425SSteven Rostedt { 5443299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 545944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 546944ac425SSteven Rostedt .maxlen = sizeof(int), 547944ac425SSteven Rostedt .mode = 0644, 5486d456111SEric W. Biederman .proc_handler = proc_dointvec, 549944ac425SSteven Rostedt }, 550944ac425SSteven Rostedt #endif 551a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5521da177e4SLinus Torvalds { 5531da177e4SLinus Torvalds .procname = "modprobe", 5541da177e4SLinus Torvalds .data = &modprobe_path, 5551da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5561da177e4SLinus Torvalds .mode = 0644, 5576d456111SEric W. Biederman .proc_handler = proc_dostring, 5581da177e4SLinus Torvalds }, 5593d43321bSKees Cook { 5603d43321bSKees Cook .procname = "modules_disabled", 5613d43321bSKees Cook .data = &modules_disabled, 5623d43321bSKees Cook .maxlen = sizeof(int), 5633d43321bSKees Cook .mode = 0644, 5643d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5656d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5663d43321bSKees Cook .extra1 = &one, 5673d43321bSKees Cook .extra2 = &one, 5683d43321bSKees Cook }, 5691da177e4SLinus Torvalds #endif 57094f17cd7SIan Abbott #ifdef CONFIG_HOTPLUG 5711da177e4SLinus Torvalds { 5721da177e4SLinus Torvalds .procname = "hotplug", 573312c004dSKay Sievers .data = &uevent_helper, 574312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5751da177e4SLinus Torvalds .mode = 0644, 5766d456111SEric W. Biederman .proc_handler = proc_dostring, 5771da177e4SLinus Torvalds }, 5781da177e4SLinus Torvalds #endif 5791da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5801da177e4SLinus Torvalds { 5811da177e4SLinus Torvalds .procname = "sg-big-buff", 5821da177e4SLinus Torvalds .data = &sg_big_buff, 5831da177e4SLinus Torvalds .maxlen = sizeof (int), 5841da177e4SLinus Torvalds .mode = 0444, 5856d456111SEric W. Biederman .proc_handler = proc_dointvec, 5861da177e4SLinus Torvalds }, 5871da177e4SLinus Torvalds #endif 5881da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5891da177e4SLinus Torvalds { 5901da177e4SLinus Torvalds .procname = "acct", 5911da177e4SLinus Torvalds .data = &acct_parm, 5921da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5931da177e4SLinus Torvalds .mode = 0644, 5946d456111SEric W. Biederman .proc_handler = proc_dointvec, 5951da177e4SLinus Torvalds }, 5961da177e4SLinus Torvalds #endif 5971da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5981da177e4SLinus Torvalds { 5991da177e4SLinus Torvalds .procname = "sysrq", 6005d6f647fSIngo Molnar .data = &__sysrq_enabled, 6011da177e4SLinus Torvalds .maxlen = sizeof (int), 6021da177e4SLinus Torvalds .mode = 0644, 60397f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 6041da177e4SLinus Torvalds }, 6051da177e4SLinus Torvalds #endif 606d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 6071da177e4SLinus Torvalds { 6081da177e4SLinus Torvalds .procname = "cad_pid", 6099ec52099SCedric Le Goater .data = NULL, 6101da177e4SLinus Torvalds .maxlen = sizeof (int), 6111da177e4SLinus Torvalds .mode = 0600, 6126d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 6131da177e4SLinus Torvalds }, 614d6f8ff73SRandy Dunlap #endif 6151da177e4SLinus Torvalds { 6161da177e4SLinus Torvalds .procname = "threads-max", 6171da177e4SLinus Torvalds .data = &max_threads, 6181da177e4SLinus Torvalds .maxlen = sizeof(int), 6191da177e4SLinus Torvalds .mode = 0644, 6206d456111SEric W. Biederman .proc_handler = proc_dointvec, 6211da177e4SLinus Torvalds }, 6221da177e4SLinus Torvalds { 6231da177e4SLinus Torvalds .procname = "random", 6241da177e4SLinus Torvalds .mode = 0555, 6251da177e4SLinus Torvalds .child = random_table, 6261da177e4SLinus Torvalds }, 6271da177e4SLinus Torvalds { 62817f60a7dSEric Paris .procname = "usermodehelper", 62917f60a7dSEric Paris .mode = 0555, 63017f60a7dSEric Paris .child = usermodehelper_table, 63117f60a7dSEric Paris }, 63217f60a7dSEric Paris { 6331da177e4SLinus Torvalds .procname = "overflowuid", 6341da177e4SLinus Torvalds .data = &overflowuid, 6351da177e4SLinus Torvalds .maxlen = sizeof(int), 6361da177e4SLinus Torvalds .mode = 0644, 6376d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6381da177e4SLinus Torvalds .extra1 = &minolduid, 6391da177e4SLinus Torvalds .extra2 = &maxolduid, 6401da177e4SLinus Torvalds }, 6411da177e4SLinus Torvalds { 6421da177e4SLinus Torvalds .procname = "overflowgid", 6431da177e4SLinus Torvalds .data = &overflowgid, 6441da177e4SLinus Torvalds .maxlen = sizeof(int), 6451da177e4SLinus Torvalds .mode = 0644, 6466d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6471da177e4SLinus Torvalds .extra1 = &minolduid, 6481da177e4SLinus Torvalds .extra2 = &maxolduid, 6491da177e4SLinus Torvalds }, 650347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6511da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6521da177e4SLinus Torvalds { 6531da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6541da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6551da177e4SLinus Torvalds .maxlen = sizeof(int), 6561da177e4SLinus Torvalds .mode = 0644, 6576d456111SEric W. Biederman .proc_handler = proc_dointvec, 6581da177e4SLinus Torvalds }, 6591da177e4SLinus Torvalds #endif 6601da177e4SLinus Torvalds { 6611da177e4SLinus Torvalds .procname = "userprocess_debug", 662ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 6631da177e4SLinus Torvalds .maxlen = sizeof(int), 6641da177e4SLinus Torvalds .mode = 0644, 6656d456111SEric W. Biederman .proc_handler = proc_dointvec, 6661da177e4SLinus Torvalds }, 6671da177e4SLinus Torvalds #endif 6681da177e4SLinus Torvalds { 6691da177e4SLinus Torvalds .procname = "pid_max", 6701da177e4SLinus Torvalds .data = &pid_max, 6711da177e4SLinus Torvalds .maxlen = sizeof (int), 6721da177e4SLinus Torvalds .mode = 0644, 6736d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6741da177e4SLinus Torvalds .extra1 = &pid_max_min, 6751da177e4SLinus Torvalds .extra2 = &pid_max_max, 6761da177e4SLinus Torvalds }, 6771da177e4SLinus Torvalds { 6781da177e4SLinus Torvalds .procname = "panic_on_oops", 6791da177e4SLinus Torvalds .data = &panic_on_oops, 6801da177e4SLinus Torvalds .maxlen = sizeof(int), 6811da177e4SLinus Torvalds .mode = 0644, 6826d456111SEric W. Biederman .proc_handler = proc_dointvec, 6831da177e4SLinus Torvalds }, 6847ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6857ef3d2fdSJoe Perches { 6867ef3d2fdSJoe Perches .procname = "printk", 6877ef3d2fdSJoe Perches .data = &console_loglevel, 6887ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6897ef3d2fdSJoe Perches .mode = 0644, 6906d456111SEric W. Biederman .proc_handler = proc_dointvec, 6917ef3d2fdSJoe Perches }, 6921da177e4SLinus Torvalds { 6931da177e4SLinus Torvalds .procname = "printk_ratelimit", 694717115e1SDave Young .data = &printk_ratelimit_state.interval, 6951da177e4SLinus Torvalds .maxlen = sizeof(int), 6961da177e4SLinus Torvalds .mode = 0644, 6976d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6981da177e4SLinus Torvalds }, 6991da177e4SLinus Torvalds { 7001da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 701717115e1SDave Young .data = &printk_ratelimit_state.burst, 7021da177e4SLinus Torvalds .maxlen = sizeof(int), 7031da177e4SLinus Torvalds .mode = 0644, 7046d456111SEric W. Biederman .proc_handler = proc_dointvec, 7051da177e4SLinus Torvalds }, 706af91322eSDave Young { 707af91322eSDave Young .procname = "printk_delay", 708af91322eSDave Young .data = &printk_delay_msec, 709af91322eSDave Young .maxlen = sizeof(int), 710af91322eSDave Young .mode = 0644, 7116d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 712af91322eSDave Young .extra1 = &zero, 713af91322eSDave Young .extra2 = &ten_thousand, 714af91322eSDave Young }, 7151da177e4SLinus Torvalds { 716eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 717eaf06b24SDan Rosenberg .data = &dmesg_restrict, 718eaf06b24SDan Rosenberg .maxlen = sizeof(int), 719eaf06b24SDan Rosenberg .mode = 0644, 720eaf06b24SDan Rosenberg .proc_handler = proc_dointvec_minmax, 721eaf06b24SDan Rosenberg .extra1 = &zero, 722eaf06b24SDan Rosenberg .extra2 = &one, 723eaf06b24SDan Rosenberg }, 724455cd5abSDan Rosenberg { 725455cd5abSDan Rosenberg .procname = "kptr_restrict", 726455cd5abSDan Rosenberg .data = &kptr_restrict, 727455cd5abSDan Rosenberg .maxlen = sizeof(int), 728455cd5abSDan Rosenberg .mode = 0644, 729bfdc0b49SRichard Weinberger .proc_handler = proc_dmesg_restrict, 730455cd5abSDan Rosenberg .extra1 = &zero, 731455cd5abSDan Rosenberg .extra2 = &two, 732455cd5abSDan Rosenberg }, 733df6e61d4SJoe Perches #endif 734eaf06b24SDan Rosenberg { 7351da177e4SLinus Torvalds .procname = "ngroups_max", 7361da177e4SLinus Torvalds .data = &ngroups_max, 7371da177e4SLinus Torvalds .maxlen = sizeof (int), 7381da177e4SLinus Torvalds .mode = 0444, 7396d456111SEric W. Biederman .proc_handler = proc_dointvec, 7401da177e4SLinus Torvalds }, 74173efc039SDan Ballard { 74273efc039SDan Ballard .procname = "cap_last_cap", 74373efc039SDan Ballard .data = (void *)&cap_last_cap, 74473efc039SDan Ballard .maxlen = sizeof(int), 74573efc039SDan Ballard .mode = 0444, 74673efc039SDan Ballard .proc_handler = proc_dointvec, 74773efc039SDan Ballard }, 74858687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 749504d7cf1SDon Zickus { 75058687acbSDon Zickus .procname = "watchdog", 75158687acbSDon Zickus .data = &watchdog_enabled, 752504d7cf1SDon Zickus .maxlen = sizeof (int), 753504d7cf1SDon Zickus .mode = 0644, 754586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 755586692a5SMandeep Singh Baines .extra1 = &zero, 756586692a5SMandeep Singh Baines .extra2 = &one, 75758687acbSDon Zickus }, 75858687acbSDon Zickus { 75958687acbSDon Zickus .procname = "watchdog_thresh", 760586692a5SMandeep Singh Baines .data = &watchdog_thresh, 76158687acbSDon Zickus .maxlen = sizeof(int), 76258687acbSDon Zickus .mode = 0644, 763586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 76458687acbSDon Zickus .extra1 = &neg_one, 76558687acbSDon Zickus .extra2 = &sixty, 766504d7cf1SDon Zickus }, 7672508ce18SDon Zickus { 7682508ce18SDon Zickus .procname = "softlockup_panic", 7692508ce18SDon Zickus .data = &softlockup_panic, 7702508ce18SDon Zickus .maxlen = sizeof(int), 7712508ce18SDon Zickus .mode = 0644, 7722508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 7732508ce18SDon Zickus .extra1 = &zero, 7742508ce18SDon Zickus .extra2 = &one, 7752508ce18SDon Zickus }, 7765dc30558SDon Zickus { 7775dc30558SDon Zickus .procname = "nmi_watchdog", 7785dc30558SDon Zickus .data = &watchdog_enabled, 7795dc30558SDon Zickus .maxlen = sizeof (int), 7805dc30558SDon Zickus .mode = 0644, 781586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 782586692a5SMandeep Singh Baines .extra1 = &zero, 783586692a5SMandeep Singh Baines .extra2 = &one, 7845dc30558SDon Zickus }, 7855dc30558SDon Zickus #endif 7865dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7875dc30558SDon Zickus { 7885dc30558SDon Zickus .procname = "unknown_nmi_panic", 7895dc30558SDon Zickus .data = &unknown_nmi_panic, 7905dc30558SDon Zickus .maxlen = sizeof (int), 7915dc30558SDon Zickus .mode = 0644, 7925dc30558SDon Zickus .proc_handler = proc_dointvec, 7935dc30558SDon Zickus }, 794504d7cf1SDon Zickus #endif 7951da177e4SLinus Torvalds #if defined(CONFIG_X86) 7961da177e4SLinus Torvalds { 7978da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7988da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7998da5addaSDon Zickus .maxlen = sizeof(int), 8008da5addaSDon Zickus .mode = 0644, 8016d456111SEric W. Biederman .proc_handler = proc_dointvec, 8028da5addaSDon Zickus }, 8038da5addaSDon Zickus { 8045211a242SKurt Garloff .procname = "panic_on_io_nmi", 8055211a242SKurt Garloff .data = &panic_on_io_nmi, 8065211a242SKurt Garloff .maxlen = sizeof(int), 8075211a242SKurt Garloff .mode = 0644, 8086d456111SEric W. Biederman .proc_handler = proc_dointvec, 8095211a242SKurt Garloff }, 81055af7796SMitsuo Hayasaka #ifdef CONFIG_DEBUG_STACKOVERFLOW 81155af7796SMitsuo Hayasaka { 81255af7796SMitsuo Hayasaka .procname = "panic_on_stackoverflow", 81355af7796SMitsuo Hayasaka .data = &sysctl_panic_on_stackoverflow, 81455af7796SMitsuo Hayasaka .maxlen = sizeof(int), 81555af7796SMitsuo Hayasaka .mode = 0644, 81655af7796SMitsuo Hayasaka .proc_handler = proc_dointvec, 81755af7796SMitsuo Hayasaka }, 81855af7796SMitsuo Hayasaka #endif 8195211a242SKurt Garloff { 8201da177e4SLinus Torvalds .procname = "bootloader_type", 8211da177e4SLinus Torvalds .data = &bootloader_type, 8221da177e4SLinus Torvalds .maxlen = sizeof (int), 8231da177e4SLinus Torvalds .mode = 0444, 8246d456111SEric W. Biederman .proc_handler = proc_dointvec, 8251da177e4SLinus Torvalds }, 8260741f4d2SChuck Ebbert { 8275031296cSH. Peter Anvin .procname = "bootloader_version", 8285031296cSH. Peter Anvin .data = &bootloader_version, 8295031296cSH. Peter Anvin .maxlen = sizeof (int), 8305031296cSH. Peter Anvin .mode = 0444, 8316d456111SEric W. Biederman .proc_handler = proc_dointvec, 8325031296cSH. Peter Anvin }, 8335031296cSH. Peter Anvin { 8340741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 8350741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 8360741f4d2SChuck Ebbert .maxlen = sizeof(int), 8370741f4d2SChuck Ebbert .mode = 0644, 8386d456111SEric W. Biederman .proc_handler = proc_dointvec, 8390741f4d2SChuck Ebbert }, 8406e7c4025SIngo Molnar { 8416e7c4025SIngo Molnar .procname = "io_delay_type", 8426e7c4025SIngo Molnar .data = &io_delay_type, 8436e7c4025SIngo Molnar .maxlen = sizeof(int), 8446e7c4025SIngo Molnar .mode = 0644, 8456d456111SEric W. Biederman .proc_handler = proc_dointvec, 8466e7c4025SIngo Molnar }, 8471da177e4SLinus Torvalds #endif 8487a9166e3SLuke Yang #if defined(CONFIG_MMU) 8491da177e4SLinus Torvalds { 8501da177e4SLinus Torvalds .procname = "randomize_va_space", 8511da177e4SLinus Torvalds .data = &randomize_va_space, 8521da177e4SLinus Torvalds .maxlen = sizeof(int), 8531da177e4SLinus Torvalds .mode = 0644, 8546d456111SEric W. Biederman .proc_handler = proc_dointvec, 8551da177e4SLinus Torvalds }, 8567a9166e3SLuke Yang #endif 8570152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 858951f22d5SMartin Schwidefsky { 859951f22d5SMartin Schwidefsky .procname = "spin_retry", 860951f22d5SMartin Schwidefsky .data = &spin_retry, 861951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 862951f22d5SMartin Schwidefsky .mode = 0644, 8636d456111SEric W. Biederman .proc_handler = proc_dointvec, 864951f22d5SMartin Schwidefsky }, 865951f22d5SMartin Schwidefsky #endif 866673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 867c255d844SPavel Machek { 868c255d844SPavel Machek .procname = "acpi_video_flags", 86977afcf78SPavel Machek .data = &acpi_realmode_flags, 870c255d844SPavel Machek .maxlen = sizeof (unsigned long), 871c255d844SPavel Machek .mode = 0644, 8726d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 873c255d844SPavel Machek }, 874c255d844SPavel Machek #endif 875d2b176edSJes Sorensen #ifdef CONFIG_IA64 876d2b176edSJes Sorensen { 877d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 878d2b176edSJes Sorensen .data = &no_unaligned_warning, 879d2b176edSJes Sorensen .maxlen = sizeof (int), 880d2b176edSJes Sorensen .mode = 0644, 8816d456111SEric W. Biederman .proc_handler = proc_dointvec, 882d2b176edSJes Sorensen }, 88388fc241fSDoug Chapman { 88488fc241fSDoug Chapman .procname = "unaligned-dump-stack", 88588fc241fSDoug Chapman .data = &unaligned_dump_stack, 88688fc241fSDoug Chapman .maxlen = sizeof (int), 88788fc241fSDoug Chapman .mode = 0644, 8886d456111SEric W. Biederman .proc_handler = proc_dointvec, 88988fc241fSDoug Chapman }, 890d2b176edSJes Sorensen #endif 891e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 892e162b39aSMandeep Singh Baines { 893e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 894e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 895e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 896e162b39aSMandeep Singh Baines .mode = 0644, 8976d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 898e162b39aSMandeep Singh Baines .extra1 = &zero, 899e162b39aSMandeep Singh Baines .extra2 = &one, 900e162b39aSMandeep Singh Baines }, 90182a1fcb9SIngo Molnar { 90282a1fcb9SIngo Molnar .procname = "hung_task_check_count", 90382a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 90490739081SIngo Molnar .maxlen = sizeof(unsigned long), 90582a1fcb9SIngo Molnar .mode = 0644, 9066d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 90782a1fcb9SIngo Molnar }, 90882a1fcb9SIngo Molnar { 90982a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 91082a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 91190739081SIngo Molnar .maxlen = sizeof(unsigned long), 91282a1fcb9SIngo Molnar .mode = 0644, 9136d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 91482a1fcb9SIngo Molnar }, 91582a1fcb9SIngo Molnar { 91682a1fcb9SIngo Molnar .procname = "hung_task_warnings", 91782a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 91890739081SIngo Molnar .maxlen = sizeof(unsigned long), 91982a1fcb9SIngo Molnar .mode = 0644, 9206d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 92182a1fcb9SIngo Molnar }, 922c4f3b63fSRavikiran G Thirumalai #endif 923bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 924bebfa101SAndi Kleen { 925bebfa101SAndi Kleen .procname = "compat-log", 926bebfa101SAndi Kleen .data = &compat_log, 927bebfa101SAndi Kleen .maxlen = sizeof (int), 928bebfa101SAndi Kleen .mode = 0644, 9296d456111SEric W. Biederman .proc_handler = proc_dointvec, 930bebfa101SAndi Kleen }, 931bebfa101SAndi Kleen #endif 93223f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 93323f78d4aSIngo Molnar { 93423f78d4aSIngo Molnar .procname = "max_lock_depth", 93523f78d4aSIngo Molnar .data = &max_lock_depth, 93623f78d4aSIngo Molnar .maxlen = sizeof(int), 93723f78d4aSIngo Molnar .mode = 0644, 9386d456111SEric W. Biederman .proc_handler = proc_dointvec, 93923f78d4aSIngo Molnar }, 94023f78d4aSIngo Molnar #endif 94110a0a8d4SJeremy Fitzhardinge { 94210a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 94310a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 94410a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 94510a0a8d4SJeremy Fitzhardinge .mode = 0644, 9466d456111SEric W. Biederman .proc_handler = proc_dostring, 94710a0a8d4SJeremy Fitzhardinge }, 9480b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9490b77f5bfSDavid Howells { 9500b77f5bfSDavid Howells .procname = "keys", 9510b77f5bfSDavid Howells .mode = 0555, 9520b77f5bfSDavid Howells .child = key_sysctls, 9530b77f5bfSDavid Howells }, 9540b77f5bfSDavid Howells #endif 95531a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 95631a72bceSPaul E. McKenney { 95731a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 95831a72bceSPaul E. McKenney .data = &rcutorture_runnable, 95931a72bceSPaul E. McKenney .maxlen = sizeof(int), 96031a72bceSPaul E. McKenney .mode = 0644, 9616d456111SEric W. Biederman .proc_handler = proc_dointvec, 96231a72bceSPaul E. McKenney }, 96331a72bceSPaul E. McKenney #endif 964cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 965aa4a2218SVince Weaver /* 966aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 967aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 968aa4a2218SVince Weaver * 969aa4a2218SVince Weaver * So it's an ABI, do not remove! 970aa4a2218SVince Weaver */ 9711ccd1549SPeter Zijlstra { 972cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 973cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 974cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9751ccd1549SPeter Zijlstra .mode = 0644, 9766d456111SEric W. Biederman .proc_handler = proc_dointvec, 9771ccd1549SPeter Zijlstra }, 978c5078f78SPeter Zijlstra { 979cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 980cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 981cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 982c5078f78SPeter Zijlstra .mode = 0644, 9836d456111SEric W. Biederman .proc_handler = proc_dointvec, 984c5078f78SPeter Zijlstra }, 985a78ac325SPeter Zijlstra { 986cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 987cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 988cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 989a78ac325SPeter Zijlstra .mode = 0644, 990163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 991a78ac325SPeter Zijlstra }, 9921ccd1549SPeter Zijlstra #endif 993dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 994dfec072eSVegard Nossum { 995dfec072eSVegard Nossum .procname = "kmemcheck", 996dfec072eSVegard Nossum .data = &kmemcheck_enabled, 997dfec072eSVegard Nossum .maxlen = sizeof(int), 998dfec072eSVegard Nossum .mode = 0644, 9996d456111SEric W. Biederman .proc_handler = proc_dointvec, 1000dfec072eSVegard Nossum }, 1001dfec072eSVegard Nossum #endif 1002cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 10035e605b64SJens Axboe { 10045e605b64SJens Axboe .procname = "blk_iopoll", 10055e605b64SJens Axboe .data = &blk_iopoll_enabled, 10065e605b64SJens Axboe .maxlen = sizeof(int), 10075e605b64SJens Axboe .mode = 0644, 10086d456111SEric W. Biederman .proc_handler = proc_dointvec, 10095e605b64SJens Axboe }, 1010cb684b5bSJens Axboe #endif 10116fce56ecSEric W. Biederman { } 10121da177e4SLinus Torvalds }; 10131da177e4SLinus Torvalds 1014d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 10151da177e4SLinus Torvalds { 10161da177e4SLinus Torvalds .procname = "overcommit_memory", 10171da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 10181da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 10191da177e4SLinus Torvalds .mode = 0644, 1020cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1021cb16e95fSPetr Holasek .extra1 = &zero, 1022cb16e95fSPetr Holasek .extra2 = &two, 10231da177e4SLinus Torvalds }, 10241da177e4SLinus Torvalds { 1025fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1026fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1027fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1028fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1029cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1030cb16e95fSPetr Holasek .extra1 = &zero, 1031cb16e95fSPetr Holasek .extra2 = &two, 1032fadd8fbdSKAMEZAWA Hiroyuki }, 1033fadd8fbdSKAMEZAWA Hiroyuki { 1034fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1035fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1036fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1037fe071d7eSDavid Rientjes .mode = 0644, 10386d456111SEric W. Biederman .proc_handler = proc_dointvec, 1039fe071d7eSDavid Rientjes }, 1040fe071d7eSDavid Rientjes { 1041fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1042fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1043fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1044fef1bdd6SDavid Rientjes .mode = 0644, 10456d456111SEric W. Biederman .proc_handler = proc_dointvec, 1046fef1bdd6SDavid Rientjes }, 1047fef1bdd6SDavid Rientjes { 10481da177e4SLinus Torvalds .procname = "overcommit_ratio", 10491da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10501da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10511da177e4SLinus Torvalds .mode = 0644, 10526d456111SEric W. Biederman .proc_handler = proc_dointvec, 10531da177e4SLinus Torvalds }, 10541da177e4SLinus Torvalds { 10551da177e4SLinus Torvalds .procname = "page-cluster", 10561da177e4SLinus Torvalds .data = &page_cluster, 10571da177e4SLinus Torvalds .maxlen = sizeof(int), 10581da177e4SLinus Torvalds .mode = 0644, 1059cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1060cb16e95fSPetr Holasek .extra1 = &zero, 10611da177e4SLinus Torvalds }, 10621da177e4SLinus Torvalds { 10631da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10641da177e4SLinus Torvalds .data = &dirty_background_ratio, 10651da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10661da177e4SLinus Torvalds .mode = 0644, 10676d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 10681da177e4SLinus Torvalds .extra1 = &zero, 10691da177e4SLinus Torvalds .extra2 = &one_hundred, 10701da177e4SLinus Torvalds }, 10711da177e4SLinus Torvalds { 10722da02997SDavid Rientjes .procname = "dirty_background_bytes", 10732da02997SDavid Rientjes .data = &dirty_background_bytes, 10742da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10752da02997SDavid Rientjes .mode = 0644, 10766d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1077fc3501d4SSven Wegener .extra1 = &one_ul, 10782da02997SDavid Rientjes }, 10792da02997SDavid Rientjes { 10801da177e4SLinus Torvalds .procname = "dirty_ratio", 10811da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10821da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10831da177e4SLinus Torvalds .mode = 0644, 10846d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10851da177e4SLinus Torvalds .extra1 = &zero, 10861da177e4SLinus Torvalds .extra2 = &one_hundred, 10871da177e4SLinus Torvalds }, 10881da177e4SLinus Torvalds { 10892da02997SDavid Rientjes .procname = "dirty_bytes", 10902da02997SDavid Rientjes .data = &vm_dirty_bytes, 10912da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10922da02997SDavid Rientjes .mode = 0644, 10936d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10949e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10952da02997SDavid Rientjes }, 10962da02997SDavid Rientjes { 10971da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1098f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1099f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 11001da177e4SLinus Torvalds .mode = 0644, 11016d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 11021da177e4SLinus Torvalds }, 11031da177e4SLinus Torvalds { 11041da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1105f6ef9438SBart Samwel .data = &dirty_expire_interval, 1106f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 11071da177e4SLinus Torvalds .mode = 0644, 1108cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1109cb16e95fSPetr Holasek .extra1 = &zero, 11101da177e4SLinus Torvalds }, 11111da177e4SLinus Torvalds { 11121da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 11131da177e4SLinus Torvalds .data = &nr_pdflush_threads, 11141da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 11151da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 11166d456111SEric W. Biederman .proc_handler = proc_dointvec, 11171da177e4SLinus Torvalds }, 11181da177e4SLinus Torvalds { 11191da177e4SLinus Torvalds .procname = "swappiness", 11201da177e4SLinus Torvalds .data = &vm_swappiness, 11211da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 11221da177e4SLinus Torvalds .mode = 0644, 11236d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 11241da177e4SLinus Torvalds .extra1 = &zero, 11251da177e4SLinus Torvalds .extra2 = &one_hundred, 11261da177e4SLinus Torvalds }, 11271da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11281da177e4SLinus Torvalds { 11291da177e4SLinus Torvalds .procname = "nr_hugepages", 1130e5ff2159SAndi Kleen .data = NULL, 11311da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11321da177e4SLinus Torvalds .mode = 0644, 11336d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 11341da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11351da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11361da177e4SLinus Torvalds }, 113706808b08SLee Schermerhorn #ifdef CONFIG_NUMA 113806808b08SLee Schermerhorn { 113906808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 114006808b08SLee Schermerhorn .data = NULL, 114106808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 114206808b08SLee Schermerhorn .mode = 0644, 114306808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 114406808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 114506808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 114606808b08SLee Schermerhorn }, 114706808b08SLee Schermerhorn #endif 11481da177e4SLinus Torvalds { 11491da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11501da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11511da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11521da177e4SLinus Torvalds .mode = 0644, 11536d456111SEric W. Biederman .proc_handler = proc_dointvec, 11541da177e4SLinus Torvalds }, 1155396faf03SMel Gorman { 1156396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1157396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1158396faf03SMel Gorman .maxlen = sizeof(int), 1159396faf03SMel Gorman .mode = 0644, 11606d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1161396faf03SMel Gorman }, 116254f9f80dSAdam Litke { 1163d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1164e5ff2159SAndi Kleen .data = NULL, 1165e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1166d1c3fb1fSNishanth Aravamudan .mode = 0644, 11676d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1168e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1169e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1170d1c3fb1fSNishanth Aravamudan }, 11711da177e4SLinus Torvalds #endif 11721da177e4SLinus Torvalds { 11731da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11741da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11751da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11761da177e4SLinus Torvalds .mode = 0644, 11776d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11781da177e4SLinus Torvalds }, 11791da177e4SLinus Torvalds { 11809d0243bcSAndrew Morton .procname = "drop_caches", 11819d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11829d0243bcSAndrew Morton .maxlen = sizeof(int), 11839d0243bcSAndrew Morton .mode = 0644, 11849d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 1185cb16e95fSPetr Holasek .extra1 = &one, 1186cb16e95fSPetr Holasek .extra2 = &three, 11879d0243bcSAndrew Morton }, 118876ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 118976ab0f53SMel Gorman { 119076ab0f53SMel Gorman .procname = "compact_memory", 119176ab0f53SMel Gorman .data = &sysctl_compact_memory, 119276ab0f53SMel Gorman .maxlen = sizeof(int), 119376ab0f53SMel Gorman .mode = 0200, 119476ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 119576ab0f53SMel Gorman }, 11965e771905SMel Gorman { 11975e771905SMel Gorman .procname = "extfrag_threshold", 11985e771905SMel Gorman .data = &sysctl_extfrag_threshold, 11995e771905SMel Gorman .maxlen = sizeof(int), 12005e771905SMel Gorman .mode = 0644, 12015e771905SMel Gorman .proc_handler = sysctl_extfrag_handler, 12025e771905SMel Gorman .extra1 = &min_extfrag_threshold, 12035e771905SMel Gorman .extra2 = &max_extfrag_threshold, 12045e771905SMel Gorman }, 12055e771905SMel Gorman 120676ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 12079d0243bcSAndrew Morton { 12081da177e4SLinus Torvalds .procname = "min_free_kbytes", 12091da177e4SLinus Torvalds .data = &min_free_kbytes, 12101da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 12111da177e4SLinus Torvalds .mode = 0644, 12126d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 12131da177e4SLinus Torvalds .extra1 = &zero, 12141da177e4SLinus Torvalds }, 12158ad4b1fbSRohit Seth { 12168ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 12178ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 12188ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 12198ad4b1fbSRohit Seth .mode = 0644, 12206d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 12218ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 12228ad4b1fbSRohit Seth }, 12231da177e4SLinus Torvalds #ifdef CONFIG_MMU 12241da177e4SLinus Torvalds { 12251da177e4SLinus Torvalds .procname = "max_map_count", 12261da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12271da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12281da177e4SLinus Torvalds .mode = 0644, 12293e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 123070da2340SAmerigo Wang .extra1 = &zero, 12311da177e4SLinus Torvalds }, 1232dd8632a1SPaul Mundt #else 1233dd8632a1SPaul Mundt { 1234dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1235dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1236dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1237dd8632a1SPaul Mundt .mode = 0644, 12386d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1239dd8632a1SPaul Mundt .extra1 = &zero, 1240dd8632a1SPaul Mundt }, 12411da177e4SLinus Torvalds #endif 12421da177e4SLinus Torvalds { 12431da177e4SLinus Torvalds .procname = "laptop_mode", 12441da177e4SLinus Torvalds .data = &laptop_mode, 12451da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12461da177e4SLinus Torvalds .mode = 0644, 12476d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 12481da177e4SLinus Torvalds }, 12491da177e4SLinus Torvalds { 12501da177e4SLinus Torvalds .procname = "block_dump", 12511da177e4SLinus Torvalds .data = &block_dump, 12521da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12531da177e4SLinus Torvalds .mode = 0644, 12546d456111SEric W. Biederman .proc_handler = proc_dointvec, 12551da177e4SLinus Torvalds .extra1 = &zero, 12561da177e4SLinus Torvalds }, 12571da177e4SLinus Torvalds { 12581da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12591da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12601da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12611da177e4SLinus Torvalds .mode = 0644, 12626d456111SEric W. Biederman .proc_handler = proc_dointvec, 12631da177e4SLinus Torvalds .extra1 = &zero, 12641da177e4SLinus Torvalds }, 12651da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12661da177e4SLinus Torvalds { 12671da177e4SLinus Torvalds .procname = "legacy_va_layout", 12681da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12691da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12701da177e4SLinus Torvalds .mode = 0644, 12716d456111SEric W. Biederman .proc_handler = proc_dointvec, 12721da177e4SLinus Torvalds .extra1 = &zero, 12731da177e4SLinus Torvalds }, 12741da177e4SLinus Torvalds #endif 12751743660bSChristoph Lameter #ifdef CONFIG_NUMA 12761743660bSChristoph Lameter { 12771743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12781743660bSChristoph Lameter .data = &zone_reclaim_mode, 12791743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12801743660bSChristoph Lameter .mode = 0644, 12816d456111SEric W. Biederman .proc_handler = proc_dointvec, 1282c84db23cSChristoph Lameter .extra1 = &zero, 12831743660bSChristoph Lameter }, 12849614634fSChristoph Lameter { 12859614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12869614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12879614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12889614634fSChristoph Lameter .mode = 0644, 12896d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 12909614634fSChristoph Lameter .extra1 = &zero, 12919614634fSChristoph Lameter .extra2 = &one_hundred, 12929614634fSChristoph Lameter }, 12930ff38490SChristoph Lameter { 12940ff38490SChristoph Lameter .procname = "min_slab_ratio", 12950ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12960ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12970ff38490SChristoph Lameter .mode = 0644, 12986d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12990ff38490SChristoph Lameter .extra1 = &zero, 13000ff38490SChristoph Lameter .extra2 = &one_hundred, 13010ff38490SChristoph Lameter }, 13021743660bSChristoph Lameter #endif 130377461ab3SChristoph Lameter #ifdef CONFIG_SMP 130477461ab3SChristoph Lameter { 130577461ab3SChristoph Lameter .procname = "stat_interval", 130677461ab3SChristoph Lameter .data = &sysctl_stat_interval, 130777461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 130877461ab3SChristoph Lameter .mode = 0644, 13096d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 131077461ab3SChristoph Lameter }, 131177461ab3SChristoph Lameter #endif 13126e141546SDavid Howells #ifdef CONFIG_MMU 1313ed032189SEric Paris { 1314ed032189SEric Paris .procname = "mmap_min_addr", 1315788084abSEric Paris .data = &dac_mmap_min_addr, 1316ed032189SEric Paris .maxlen = sizeof(unsigned long), 1317ed032189SEric Paris .mode = 0644, 13186d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1319ed032189SEric Paris }, 13206e141546SDavid Howells #endif 1321f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1322f0c0b2b8SKAMEZAWA Hiroyuki { 1323f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1324f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1325f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1326f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 13276d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1328f0c0b2b8SKAMEZAWA Hiroyuki }, 1329f0c0b2b8SKAMEZAWA Hiroyuki #endif 13302b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13315c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1332e6e5494cSIngo Molnar { 1333e6e5494cSIngo Molnar .procname = "vdso_enabled", 1334e6e5494cSIngo Molnar .data = &vdso_enabled, 1335e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1336e6e5494cSIngo Molnar .mode = 0644, 13376d456111SEric W. Biederman .proc_handler = proc_dointvec, 1338e6e5494cSIngo Molnar .extra1 = &zero, 1339e6e5494cSIngo Molnar }, 1340e6e5494cSIngo Molnar #endif 1341195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1342195cf453SBron Gondwana { 1343195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1344195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1345195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1346195cf453SBron Gondwana .mode = 0644, 13476d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1348195cf453SBron Gondwana .extra1 = &zero, 1349195cf453SBron Gondwana .extra2 = &one, 1350195cf453SBron Gondwana }, 1351195cf453SBron Gondwana #endif 13524be6f6bbSPeter Zijlstra { 13534be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13544be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13554be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13564be6f6bbSPeter Zijlstra .mode = 0644, 13576d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 13584be6f6bbSPeter Zijlstra }, 13596a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 13606a46079cSAndi Kleen { 13616a46079cSAndi Kleen .procname = "memory_failure_early_kill", 13626a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 13636a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 13646a46079cSAndi Kleen .mode = 0644, 13656d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13666a46079cSAndi Kleen .extra1 = &zero, 13676a46079cSAndi Kleen .extra2 = &one, 13686a46079cSAndi Kleen }, 13696a46079cSAndi Kleen { 13706a46079cSAndi Kleen .procname = "memory_failure_recovery", 13716a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 13726a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 13736a46079cSAndi Kleen .mode = 0644, 13746d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13756a46079cSAndi Kleen .extra1 = &zero, 13766a46079cSAndi Kleen .extra2 = &one, 13776a46079cSAndi Kleen }, 13786a46079cSAndi Kleen #endif 13796fce56ecSEric W. Biederman { } 13801da177e4SLinus Torvalds }; 13811da177e4SLinus Torvalds 13822abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1383d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13846fce56ecSEric W. Biederman { } 13852abc26fcSEric W. Biederman }; 13862abc26fcSEric W. Biederman #endif 13872abc26fcSEric W. Biederman 1388d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13891da177e4SLinus Torvalds { 13901da177e4SLinus Torvalds .procname = "inode-nr", 13911da177e4SLinus Torvalds .data = &inodes_stat, 13921da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13931da177e4SLinus Torvalds .mode = 0444, 1394cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13951da177e4SLinus Torvalds }, 13961da177e4SLinus Torvalds { 13971da177e4SLinus Torvalds .procname = "inode-state", 13981da177e4SLinus Torvalds .data = &inodes_stat, 13991da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 14001da177e4SLinus Torvalds .mode = 0444, 1401cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 14021da177e4SLinus Torvalds }, 14031da177e4SLinus Torvalds { 14041da177e4SLinus Torvalds .procname = "file-nr", 14051da177e4SLinus Torvalds .data = &files_stat, 1406518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 14071da177e4SLinus Torvalds .mode = 0444, 14086d456111SEric W. Biederman .proc_handler = proc_nr_files, 14091da177e4SLinus Torvalds }, 14101da177e4SLinus Torvalds { 14111da177e4SLinus Torvalds .procname = "file-max", 14121da177e4SLinus Torvalds .data = &files_stat.max_files, 1413518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 14141da177e4SLinus Torvalds .mode = 0644, 1415518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 14161da177e4SLinus Torvalds }, 14171da177e4SLinus Torvalds { 14189cfe015aSEric Dumazet .procname = "nr_open", 14199cfe015aSEric Dumazet .data = &sysctl_nr_open, 14209cfe015aSEric Dumazet .maxlen = sizeof(int), 14219cfe015aSEric Dumazet .mode = 0644, 14226d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1423eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1424eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14259cfe015aSEric Dumazet }, 14269cfe015aSEric Dumazet { 14271da177e4SLinus Torvalds .procname = "dentry-state", 14281da177e4SLinus Torvalds .data = &dentry_stat, 14291da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14301da177e4SLinus Torvalds .mode = 0444, 1431312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 14321da177e4SLinus Torvalds }, 14331da177e4SLinus Torvalds { 14341da177e4SLinus Torvalds .procname = "overflowuid", 14351da177e4SLinus Torvalds .data = &fs_overflowuid, 14361da177e4SLinus Torvalds .maxlen = sizeof(int), 14371da177e4SLinus Torvalds .mode = 0644, 14386d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14391da177e4SLinus Torvalds .extra1 = &minolduid, 14401da177e4SLinus Torvalds .extra2 = &maxolduid, 14411da177e4SLinus Torvalds }, 14421da177e4SLinus Torvalds { 14431da177e4SLinus Torvalds .procname = "overflowgid", 14441da177e4SLinus Torvalds .data = &fs_overflowgid, 14451da177e4SLinus Torvalds .maxlen = sizeof(int), 14461da177e4SLinus Torvalds .mode = 0644, 14476d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14481da177e4SLinus Torvalds .extra1 = &minolduid, 14491da177e4SLinus Torvalds .extra2 = &maxolduid, 14501da177e4SLinus Torvalds }, 1451bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14521da177e4SLinus Torvalds { 14531da177e4SLinus Torvalds .procname = "leases-enable", 14541da177e4SLinus Torvalds .data = &leases_enable, 14551da177e4SLinus Torvalds .maxlen = sizeof(int), 14561da177e4SLinus Torvalds .mode = 0644, 14576d456111SEric W. Biederman .proc_handler = proc_dointvec, 14581da177e4SLinus Torvalds }, 1459bfcd17a6SThomas Petazzoni #endif 14601da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14611da177e4SLinus Torvalds { 14621da177e4SLinus Torvalds .procname = "dir-notify-enable", 14631da177e4SLinus Torvalds .data = &dir_notify_enable, 14641da177e4SLinus Torvalds .maxlen = sizeof(int), 14651da177e4SLinus Torvalds .mode = 0644, 14666d456111SEric W. Biederman .proc_handler = proc_dointvec, 14671da177e4SLinus Torvalds }, 14681da177e4SLinus Torvalds #endif 14691da177e4SLinus Torvalds #ifdef CONFIG_MMU 1470bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14711da177e4SLinus Torvalds { 14721da177e4SLinus Torvalds .procname = "lease-break-time", 14731da177e4SLinus Torvalds .data = &lease_break_time, 14741da177e4SLinus Torvalds .maxlen = sizeof(int), 14751da177e4SLinus Torvalds .mode = 0644, 14766d456111SEric W. Biederman .proc_handler = proc_dointvec, 14771da177e4SLinus Torvalds }, 1478bfcd17a6SThomas Petazzoni #endif 1479ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14801da177e4SLinus Torvalds { 14811da177e4SLinus Torvalds .procname = "aio-nr", 14821da177e4SLinus Torvalds .data = &aio_nr, 14831da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14841da177e4SLinus Torvalds .mode = 0444, 14856d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14861da177e4SLinus Torvalds }, 14871da177e4SLinus Torvalds { 14881da177e4SLinus Torvalds .procname = "aio-max-nr", 14891da177e4SLinus Torvalds .data = &aio_max_nr, 14901da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14911da177e4SLinus Torvalds .mode = 0644, 14926d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14931da177e4SLinus Torvalds }, 1494ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14952d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14960399cb08SRobert Love { 14970399cb08SRobert Love .procname = "inotify", 14980399cb08SRobert Love .mode = 0555, 14990399cb08SRobert Love .child = inotify_table, 15000399cb08SRobert Love }, 15010399cb08SRobert Love #endif 15027ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 15037ef9964eSDavide Libenzi { 15047ef9964eSDavide Libenzi .procname = "epoll", 15057ef9964eSDavide Libenzi .mode = 0555, 15067ef9964eSDavide Libenzi .child = epoll_table, 15077ef9964eSDavide Libenzi }, 15087ef9964eSDavide Libenzi #endif 15091da177e4SLinus Torvalds #endif 1510d6e71144SAlan Cox { 1511d6e71144SAlan Cox .procname = "suid_dumpable", 1512d6e71144SAlan Cox .data = &suid_dumpable, 1513d6e71144SAlan Cox .maxlen = sizeof(int), 1514d6e71144SAlan Cox .mode = 0644, 15156d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 15168e654fbaSMatthew Wilcox .extra1 = &zero, 15178e654fbaSMatthew Wilcox .extra2 = &two, 1518d6e71144SAlan Cox }, 15192abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 15202abc26fcSEric W. Biederman { 15212abc26fcSEric W. Biederman .procname = "binfmt_misc", 15222abc26fcSEric W. Biederman .mode = 0555, 15232abc26fcSEric W. Biederman .child = binfmt_misc_table, 15242abc26fcSEric W. Biederman }, 15252abc26fcSEric W. Biederman #endif 1526b492e95bSJens Axboe { 1527ff9da691SJens Axboe .procname = "pipe-max-size", 1528ff9da691SJens Axboe .data = &pipe_max_size, 1529b492e95bSJens Axboe .maxlen = sizeof(int), 1530b492e95bSJens Axboe .mode = 0644, 1531ff9da691SJens Axboe .proc_handler = &pipe_proc_fn, 1532ff9da691SJens Axboe .extra1 = &pipe_min_size, 1533b492e95bSJens Axboe }, 15346fce56ecSEric W. Biederman { } 15351da177e4SLinus Torvalds }; 15361da177e4SLinus Torvalds 1537d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1538ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ 1539571d76acSChris Metcalf defined(CONFIG_S390) || defined(CONFIG_TILE) 1540abd4f750SMasoud Asgharifard Sharbiani { 1541abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1542abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1543abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1544abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1545abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1546abd4f750SMasoud Asgharifard Sharbiani }, 1547abd4f750SMasoud Asgharifard Sharbiani #endif 1548b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1549b2be84dfSMasami Hiramatsu { 1550b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1551b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1552b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1553b2be84dfSMasami Hiramatsu .mode = 0644, 1554b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1555b2be84dfSMasami Hiramatsu .extra1 = &zero, 1556b2be84dfSMasami Hiramatsu .extra2 = &one, 1557b2be84dfSMasami Hiramatsu }, 1558b2be84dfSMasami Hiramatsu #endif 15596fce56ecSEric W. Biederman { } 15601da177e4SLinus Torvalds }; 15611da177e4SLinus Torvalds 1562d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15636fce56ecSEric W. Biederman { } 15641da177e4SLinus Torvalds }; 15651da177e4SLinus Torvalds 1566330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1567330d57fbSAl Viro 1568330d57fbSAl Viro /* called under sysctl_lock */ 1569330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1570330d57fbSAl Viro { 1571330d57fbSAl Viro if (unlikely(p->unregistering)) 1572330d57fbSAl Viro return 0; 1573330d57fbSAl Viro p->used++; 1574330d57fbSAl Viro return 1; 1575330d57fbSAl Viro } 1576330d57fbSAl Viro 1577330d57fbSAl Viro /* called under sysctl_lock */ 1578330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1579330d57fbSAl Viro { 1580330d57fbSAl Viro if (!--p->used) 1581330d57fbSAl Viro if (unlikely(p->unregistering)) 1582330d57fbSAl Viro complete(p->unregistering); 1583330d57fbSAl Viro } 1584330d57fbSAl Viro 1585330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1586330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1587330d57fbSAl Viro { 1588330d57fbSAl Viro /* 1589330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1590330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1591330d57fbSAl Viro */ 1592330d57fbSAl Viro if (unlikely(p->used)) { 1593330d57fbSAl Viro struct completion wait; 1594330d57fbSAl Viro init_completion(&wait); 1595330d57fbSAl Viro p->unregistering = &wait; 1596330d57fbSAl Viro spin_unlock(&sysctl_lock); 1597330d57fbSAl Viro wait_for_completion(&wait); 1598330d57fbSAl Viro spin_lock(&sysctl_lock); 1599f7e6ced4SAl Viro } else { 1600f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1601f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1602330d57fbSAl Viro } 1603330d57fbSAl Viro /* 1604330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1605330d57fbSAl Viro * list in do_sysctl() relies on that. 1606330d57fbSAl Viro */ 1607330d57fbSAl Viro list_del_init(&p->ctl_entry); 1608330d57fbSAl Viro } 1609330d57fbSAl Viro 1610f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1611f7e6ced4SAl Viro { 1612f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1613f7e6ced4SAl Viro head->count++; 1614f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1615f7e6ced4SAl Viro } 1616f7e6ced4SAl Viro 1617f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1618f7e6ced4SAl Viro { 1619f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1620f7e6ced4SAl Viro if (!--head->count) 1621a95cded3SPaul E. McKenney kfree_rcu(head, rcu); 1622f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1623f7e6ced4SAl Viro } 1624f7e6ced4SAl Viro 1625f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1626f7e6ced4SAl Viro { 1627f7e6ced4SAl Viro if (!head) 1628f7e6ced4SAl Viro BUG(); 1629f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1630f7e6ced4SAl Viro if (!use_table(head)) 1631f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1632f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1633f7e6ced4SAl Viro return head; 1634f7e6ced4SAl Viro } 1635f7e6ced4SAl Viro 1636805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1637805b5d5eSEric W. Biederman { 1638805b5d5eSEric W. Biederman if (!head) 1639805b5d5eSEric W. Biederman return; 1640805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1641805b5d5eSEric W. Biederman unuse_table(head); 1642805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1643805b5d5eSEric W. Biederman } 1644805b5d5eSEric W. Biederman 164573455092SAl Viro static struct ctl_table_set * 164673455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 164773455092SAl Viro { 164873455092SAl Viro struct ctl_table_set *set = &root->default_set; 164973455092SAl Viro if (root->lookup) 165073455092SAl Viro set = root->lookup(root, namespaces); 165173455092SAl Viro return set; 165273455092SAl Viro } 165373455092SAl Viro 1654e51b6ba0SEric W. Biederman static struct list_head * 1655e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1656805b5d5eSEric W. Biederman { 165773455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 165873455092SAl Viro return &set->list; 1659e51b6ba0SEric W. Biederman } 1660e51b6ba0SEric W. Biederman 1661e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1662e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1663e51b6ba0SEric W. Biederman { 1664e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1665e51b6ba0SEric W. Biederman struct list_head *header_list; 1666805b5d5eSEric W. Biederman struct ctl_table_header *head; 1667805b5d5eSEric W. Biederman struct list_head *tmp; 1668e51b6ba0SEric W. Biederman 1669805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1670805b5d5eSEric W. Biederman if (prev) { 1671e51b6ba0SEric W. Biederman head = prev; 1672805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1673805b5d5eSEric W. Biederman unuse_table(prev); 1674805b5d5eSEric W. Biederman goto next; 1675805b5d5eSEric W. Biederman } 1676805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1677805b5d5eSEric W. Biederman for (;;) { 1678805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1679805b5d5eSEric W. Biederman 1680805b5d5eSEric W. Biederman if (!use_table(head)) 1681805b5d5eSEric W. Biederman goto next; 1682805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1683805b5d5eSEric W. Biederman return head; 1684805b5d5eSEric W. Biederman next: 1685e51b6ba0SEric W. Biederman root = head->root; 1686805b5d5eSEric W. Biederman tmp = tmp->next; 1687e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1688e51b6ba0SEric W. Biederman if (tmp != header_list) 1689e51b6ba0SEric W. Biederman continue; 1690e51b6ba0SEric W. Biederman 1691e51b6ba0SEric W. Biederman do { 1692e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1693e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1694e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1695e51b6ba0SEric W. Biederman goto out; 1696e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1697e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1698e51b6ba0SEric W. Biederman tmp = header_list->next; 1699805b5d5eSEric W. Biederman } 1700e51b6ba0SEric W. Biederman out: 1701805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1702805b5d5eSEric W. Biederman return NULL; 1703805b5d5eSEric W. Biederman } 1704805b5d5eSEric W. Biederman 1705e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1706e51b6ba0SEric W. Biederman { 1707e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1708e51b6ba0SEric W. Biederman } 1709e51b6ba0SEric W. Biederman 1710e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1711e51b6ba0SEric W. Biederman { 1712e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1713e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1714e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1715e51b6ba0SEric W. Biederman } 1716e51b6ba0SEric W. Biederman 17171da177e4SLinus Torvalds /* 17181ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 17191da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 17201da177e4SLinus Torvalds */ 17211da177e4SLinus Torvalds 17221da177e4SLinus Torvalds static int test_perm(int mode, int op) 17231da177e4SLinus Torvalds { 172476aac0e9SDavid Howells if (!current_euid()) 17251da177e4SLinus Torvalds mode >>= 6; 17261da177e4SLinus Torvalds else if (in_egroup_p(0)) 17271da177e4SLinus Torvalds mode >>= 3; 1728e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 17291da177e4SLinus Torvalds return 0; 17301da177e4SLinus Torvalds return -EACCES; 17311da177e4SLinus Torvalds } 17321da177e4SLinus Torvalds 1733d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 17341da177e4SLinus Torvalds { 1735d7321cd6SPavel Emelyanov int mode; 1736d7321cd6SPavel Emelyanov 1737d7321cd6SPavel Emelyanov if (root->permissions) 1738d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1739d7321cd6SPavel Emelyanov else 1740d7321cd6SPavel Emelyanov mode = table->mode; 1741d7321cd6SPavel Emelyanov 1742d7321cd6SPavel Emelyanov return test_perm(mode, op); 17431da177e4SLinus Torvalds } 17441da177e4SLinus Torvalds 1745d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1746d912b0ccSEric W. Biederman { 17472315ffa0SEric W. Biederman for (; table->procname; table++) { 1748d912b0ccSEric W. Biederman table->parent = parent; 1749d912b0ccSEric W. Biederman if (table->child) 1750d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1751d912b0ccSEric W. Biederman } 1752d912b0ccSEric W. Biederman } 1753d912b0ccSEric W. Biederman 1754d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1755d912b0ccSEric W. Biederman { 1756d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 175788f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1758b3bd3de6SAndi Kleen sysctl_check_table(current->nsproxy, root_table); 175988f458e4SHolger Schurig #endif 1760d912b0ccSEric W. Biederman return 0; 1761d912b0ccSEric W. Biederman } 1762d912b0ccSEric W. Biederman 1763d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1764d912b0ccSEric W. Biederman 1765bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1766bfbcf034SAl Viro struct ctl_table *table) 1767ae7edeccSAl Viro { 1768ae7edeccSAl Viro struct ctl_table *p; 1769ae7edeccSAl Viro const char *s = branch->procname; 1770ae7edeccSAl Viro 1771ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1772ae7edeccSAl Viro if (!s || !branch->child) 1773bfbcf034SAl Viro return NULL; 1774ae7edeccSAl Viro 1775ae7edeccSAl Viro /* ... and nothing else */ 17762315ffa0SEric W. Biederman if (branch[1].procname) 1777bfbcf034SAl Viro return NULL; 1778ae7edeccSAl Viro 1779ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 17802315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1781ae7edeccSAl Viro if (!p->child) 1782ae7edeccSAl Viro continue; 1783ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1784bfbcf034SAl Viro return p; 1785ae7edeccSAl Viro } 1786bfbcf034SAl Viro return NULL; 1787ae7edeccSAl Viro } 1788ae7edeccSAl Viro 1789ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1790ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1791ae7edeccSAl Viro { 1792ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1793bfbcf034SAl Viro struct ctl_table *next; 1794ae7edeccSAl Viro int is_better = 0; 1795ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1796ae7edeccSAl Viro 1797bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1798ae7edeccSAl Viro if (by == q->attached_by) 1799ae7edeccSAl Viro is_better = 1; 1800ae7edeccSAl Viro if (to == p->attached_by) 1801ae7edeccSAl Viro not_in_parent = 1; 1802ae7edeccSAl Viro by = by->child; 1803bfbcf034SAl Viro to = next->child; 1804ae7edeccSAl Viro } 1805ae7edeccSAl Viro 1806ae7edeccSAl Viro if (is_better && not_in_parent) { 1807ae7edeccSAl Viro q->attached_by = by; 1808ae7edeccSAl Viro q->attached_to = to; 1809ae7edeccSAl Viro q->parent = p; 1810ae7edeccSAl Viro } 1811ae7edeccSAl Viro } 1812ae7edeccSAl Viro 18131da177e4SLinus Torvalds /** 1814e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1815e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1816e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 181729e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 18181da177e4SLinus Torvalds * @table: the top-level table structure 18191da177e4SLinus Torvalds * 18201da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 182129e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 18221da177e4SLinus Torvalds * 1823d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 18241da177e4SLinus Torvalds * 18251da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 18261da177e4SLinus Torvalds * enter a sysctl file 18271da177e4SLinus Torvalds * 18281da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 18291da177e4SLinus Torvalds * 18301da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 18311da177e4SLinus Torvalds * 18321da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 18331da177e4SLinus Torvalds * 18341da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 18351da177e4SLinus Torvalds * %NULL. 18361da177e4SLinus Torvalds * 18371da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 18381da177e4SLinus Torvalds * 18391da177e4SLinus Torvalds * de - for internal use by the sysctl routines 18401da177e4SLinus Torvalds * 18411da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 18421da177e4SLinus Torvalds * 18431da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 18441da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 18451da177e4SLinus Torvalds * 18461da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 18471da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 18481da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 18491da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 18501da177e4SLinus Torvalds * 18511da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 18521da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 18531da177e4SLinus Torvalds * directory handler). Several default handlers are available to 18541da177e4SLinus Torvalds * cover common cases - 18551da177e4SLinus Torvalds * 18561da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 18571da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 18581da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 18591da177e4SLinus Torvalds * 18601da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 18611da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 18621da177e4SLinus Torvalds * 18631da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 18641da177e4SLinus Torvalds * to the table header on success. 18651da177e4SLinus Torvalds */ 1866e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1867e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1868e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1869e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 18701da177e4SLinus Torvalds { 187129e796fdSEric W. Biederman struct ctl_table_header *header; 187229e796fdSEric W. Biederman struct ctl_table *new, **prevp; 187329e796fdSEric W. Biederman unsigned int n, npath; 1874ae7edeccSAl Viro struct ctl_table_set *set; 187529e796fdSEric W. Biederman 187629e796fdSEric W. Biederman /* Count the path components */ 18772315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 187829e796fdSEric W. Biederman ; 187929e796fdSEric W. Biederman 188029e796fdSEric W. Biederman /* 188129e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 188229e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 18832315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 188429e796fdSEric W. Biederman * 188529e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 188629e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 188729e796fdSEric W. Biederman */ 188829e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 188929e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 189029e796fdSEric W. Biederman if (!header) 18911da177e4SLinus Torvalds return NULL; 189229e796fdSEric W. Biederman 189329e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 189429e796fdSEric W. Biederman 189529e796fdSEric W. Biederman /* Now connect the dots */ 189629e796fdSEric W. Biederman prevp = &header->ctl_table; 189729e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 189829e796fdSEric W. Biederman /* Copy the procname */ 189929e796fdSEric W. Biederman new->procname = path->procname; 190029e796fdSEric W. Biederman new->mode = 0555; 190129e796fdSEric W. Biederman 190229e796fdSEric W. Biederman *prevp = new; 190329e796fdSEric W. Biederman prevp = &new->child; 190429e796fdSEric W. Biederman 190529e796fdSEric W. Biederman new += 2; 190629e796fdSEric W. Biederman } 190729e796fdSEric W. Biederman *prevp = table; 190823eb06deSEric W. Biederman header->ctl_table_arg = table; 190929e796fdSEric W. Biederman 191029e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 191129e796fdSEric W. Biederman header->used = 0; 191229e796fdSEric W. Biederman header->unregistering = NULL; 1913e51b6ba0SEric W. Biederman header->root = root; 191429e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1915f7e6ced4SAl Viro header->count = 1; 191688f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1917e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 191829e796fdSEric W. Biederman kfree(header); 1919fc6cd25bSEric W. Biederman return NULL; 1920fc6cd25bSEric W. Biederman } 192188f458e4SHolger Schurig #endif 1922330d57fbSAl Viro spin_lock(&sysctl_lock); 192373455092SAl Viro header->set = lookup_header_set(root, namespaces); 1924ae7edeccSAl Viro header->attached_by = header->ctl_table; 1925ae7edeccSAl Viro header->attached_to = root_table; 1926ae7edeccSAl Viro header->parent = &root_table_header; 1927ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1928ae7edeccSAl Viro struct ctl_table_header *p; 1929ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1930ae7edeccSAl Viro if (p->unregistering) 1931ae7edeccSAl Viro continue; 1932ae7edeccSAl Viro try_attach(p, header); 1933ae7edeccSAl Viro } 1934ae7edeccSAl Viro } 1935ae7edeccSAl Viro header->parent->count++; 193673455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1937330d57fbSAl Viro spin_unlock(&sysctl_lock); 193829e796fdSEric W. Biederman 193929e796fdSEric W. Biederman return header; 194029e796fdSEric W. Biederman } 194129e796fdSEric W. Biederman 194229e796fdSEric W. Biederman /** 1943e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1944e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1945e51b6ba0SEric W. Biederman * @table: the top-level table structure 1946e51b6ba0SEric W. Biederman * 1947e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1948e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1949e51b6ba0SEric W. Biederman * 1950e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1951e51b6ba0SEric W. Biederman */ 1952e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1953e51b6ba0SEric W. Biederman struct ctl_table *table) 1954e51b6ba0SEric W. Biederman { 1955e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1956e51b6ba0SEric W. Biederman path, table); 1957e51b6ba0SEric W. Biederman } 1958e51b6ba0SEric W. Biederman 1959e51b6ba0SEric W. Biederman /** 196029e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 196129e796fdSEric W. Biederman * @table: the top-level table structure 196229e796fdSEric W. Biederman * 196329e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 196429e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 196529e796fdSEric W. Biederman * 196629e796fdSEric W. Biederman * See register_sysctl_paths for more details. 196729e796fdSEric W. Biederman */ 196829e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 196929e796fdSEric W. Biederman { 197029e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 197129e796fdSEric W. Biederman 197229e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 19731da177e4SLinus Torvalds } 19741da177e4SLinus Torvalds 19751da177e4SLinus Torvalds /** 19761da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 19771da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 19781da177e4SLinus Torvalds * 19791da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 19801da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 19811da177e4SLinus Torvalds */ 19821da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 19831da177e4SLinus Torvalds { 1984330d57fbSAl Viro might_sleep(); 1985f1dad166SPavel Emelyanov 1986f1dad166SPavel Emelyanov if (header == NULL) 1987f1dad166SPavel Emelyanov return; 1988f1dad166SPavel Emelyanov 1989330d57fbSAl Viro spin_lock(&sysctl_lock); 1990330d57fbSAl Viro start_unregistering(header); 1991ae7edeccSAl Viro if (!--header->parent->count) { 1992ae7edeccSAl Viro WARN_ON(1); 1993a95cded3SPaul E. McKenney kfree_rcu(header->parent, rcu); 1994ae7edeccSAl Viro } 1995f7e6ced4SAl Viro if (!--header->count) 1996a95cded3SPaul E. McKenney kfree_rcu(header, rcu); 1997f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19981da177e4SLinus Torvalds } 19991da177e4SLinus Torvalds 20009043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 20019043476fSAl Viro { 20029043476fSAl Viro struct ctl_table_set *set = p->set; 20039043476fSAl Viro int res; 20049043476fSAl Viro spin_lock(&sysctl_lock); 20059043476fSAl Viro if (p->unregistering) 20069043476fSAl Viro res = 0; 20079043476fSAl Viro else if (!set->is_seen) 20089043476fSAl Viro res = 1; 20099043476fSAl Viro else 20109043476fSAl Viro res = set->is_seen(set); 20119043476fSAl Viro spin_unlock(&sysctl_lock); 20129043476fSAl Viro return res; 20139043476fSAl Viro } 20149043476fSAl Viro 201573455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 201673455092SAl Viro struct ctl_table_set *parent, 201773455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 201873455092SAl Viro { 201973455092SAl Viro INIT_LIST_HEAD(&p->list); 202073455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 202173455092SAl Viro p->is_seen = is_seen; 202273455092SAl Viro } 202373455092SAl Viro 2024b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 2025d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 2026b89a8171SEric W. Biederman { 2027b89a8171SEric W. Biederman return NULL; 2028b89a8171SEric W. Biederman } 2029b89a8171SEric W. Biederman 203029e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 203129e796fdSEric W. Biederman struct ctl_table *table) 203229e796fdSEric W. Biederman { 203329e796fdSEric W. Biederman return NULL; 203429e796fdSEric W. Biederman } 203529e796fdSEric W. Biederman 2036b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2037b89a8171SEric W. Biederman { 2038b89a8171SEric W. Biederman } 2039b89a8171SEric W. Biederman 204073455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 204173455092SAl Viro struct ctl_table_set *parent, 204273455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 204373455092SAl Viro { 204473455092SAl Viro } 204573455092SAl Viro 2046f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2047f7e6ced4SAl Viro { 2048f7e6ced4SAl Viro } 2049f7e6ced4SAl Viro 2050b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2051b89a8171SEric W. Biederman 20521da177e4SLinus Torvalds /* 20531da177e4SLinus Torvalds * /proc/sys support 20541da177e4SLinus Torvalds */ 20551da177e4SLinus Torvalds 2056b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 20571da177e4SLinus Torvalds 2058b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 20598d65af78SAlexey Dobriyan void __user *buffer, 2060b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2061f5dd3d6fSSam Vilain { 2062f5dd3d6fSSam Vilain size_t len; 2063f5dd3d6fSSam Vilain char __user *p; 2064f5dd3d6fSSam Vilain char c; 2065f5dd3d6fSSam Vilain 20668d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2067f5dd3d6fSSam Vilain *lenp = 0; 2068f5dd3d6fSSam Vilain return 0; 2069f5dd3d6fSSam Vilain } 2070f5dd3d6fSSam Vilain 2071f5dd3d6fSSam Vilain if (write) { 2072f5dd3d6fSSam Vilain len = 0; 2073f5dd3d6fSSam Vilain p = buffer; 2074f5dd3d6fSSam Vilain while (len < *lenp) { 2075f5dd3d6fSSam Vilain if (get_user(c, p++)) 2076f5dd3d6fSSam Vilain return -EFAULT; 2077f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2078f5dd3d6fSSam Vilain break; 2079f5dd3d6fSSam Vilain len++; 2080f5dd3d6fSSam Vilain } 2081f5dd3d6fSSam Vilain if (len >= maxlen) 2082f5dd3d6fSSam Vilain len = maxlen-1; 2083f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2084f5dd3d6fSSam Vilain return -EFAULT; 2085f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2086f5dd3d6fSSam Vilain *ppos += *lenp; 2087f5dd3d6fSSam Vilain } else { 2088f5dd3d6fSSam Vilain len = strlen(data); 2089f5dd3d6fSSam Vilain if (len > maxlen) 2090f5dd3d6fSSam Vilain len = maxlen; 20918d060877SOleg Nesterov 20928d060877SOleg Nesterov if (*ppos > len) { 20938d060877SOleg Nesterov *lenp = 0; 20948d060877SOleg Nesterov return 0; 20958d060877SOleg Nesterov } 20968d060877SOleg Nesterov 20978d060877SOleg Nesterov data += *ppos; 20988d060877SOleg Nesterov len -= *ppos; 20998d060877SOleg Nesterov 2100f5dd3d6fSSam Vilain if (len > *lenp) 2101f5dd3d6fSSam Vilain len = *lenp; 2102f5dd3d6fSSam Vilain if (len) 2103f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2104f5dd3d6fSSam Vilain return -EFAULT; 2105f5dd3d6fSSam Vilain if (len < *lenp) { 2106f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2107f5dd3d6fSSam Vilain return -EFAULT; 2108f5dd3d6fSSam Vilain len++; 2109f5dd3d6fSSam Vilain } 2110f5dd3d6fSSam Vilain *lenp = len; 2111f5dd3d6fSSam Vilain *ppos += len; 2112f5dd3d6fSSam Vilain } 2113f5dd3d6fSSam Vilain return 0; 2114f5dd3d6fSSam Vilain } 2115f5dd3d6fSSam Vilain 21161da177e4SLinus Torvalds /** 21171da177e4SLinus Torvalds * proc_dostring - read a string sysctl 21181da177e4SLinus Torvalds * @table: the sysctl table 21191da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21201da177e4SLinus Torvalds * @buffer: the user buffer 21211da177e4SLinus Torvalds * @lenp: the size of the user buffer 21221da177e4SLinus Torvalds * @ppos: file position 21231da177e4SLinus Torvalds * 21241da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 21251da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 21261da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 21271da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 21281da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 21291da177e4SLinus Torvalds * not large enough. 21301da177e4SLinus Torvalds * 21311da177e4SLinus Torvalds * Returns 0 on success. 21321da177e4SLinus Torvalds */ 21338d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 21341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21351da177e4SLinus Torvalds { 21368d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2137f5dd3d6fSSam Vilain buffer, lenp, ppos); 21381da177e4SLinus Torvalds } 21391da177e4SLinus Torvalds 214000b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 214100b7c339SAmerigo Wang { 214200b7c339SAmerigo Wang size_t ret; 214300b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 214400b7c339SAmerigo Wang ret = tmp - *buf; 214500b7c339SAmerigo Wang *buf = tmp; 214600b7c339SAmerigo Wang return ret; 214700b7c339SAmerigo Wang } 21481da177e4SLinus Torvalds 21499f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v) 21509f977fb7SOctavian Purdila { 21519f977fb7SOctavian Purdila while (*size) { 21529f977fb7SOctavian Purdila if (**buf != v) 21539f977fb7SOctavian Purdila break; 21549f977fb7SOctavian Purdila (*size)--; 21559f977fb7SOctavian Purdila (*buf)++; 21569f977fb7SOctavian Purdila } 21579f977fb7SOctavian Purdila } 21589f977fb7SOctavian Purdila 215900b7c339SAmerigo Wang #define TMPBUFLEN 22 216000b7c339SAmerigo Wang /** 21610fc377bdSRandy Dunlap * proc_get_long - reads an ASCII formatted integer from a user buffer 216200b7c339SAmerigo Wang * 21630fc377bdSRandy Dunlap * @buf: a kernel buffer 21640fc377bdSRandy Dunlap * @size: size of the kernel buffer 21650fc377bdSRandy Dunlap * @val: this is where the number will be stored 21660fc377bdSRandy Dunlap * @neg: set to %TRUE if number is negative 21670fc377bdSRandy Dunlap * @perm_tr: a vector which contains the allowed trailers 21680fc377bdSRandy Dunlap * @perm_tr_len: size of the perm_tr vector 21690fc377bdSRandy Dunlap * @tr: pointer to store the trailer character 217000b7c339SAmerigo Wang * 21710fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 21720fc377bdSRandy Dunlap * the amount of bytes read. If @tr is non-NULL and a trailing 21730fc377bdSRandy Dunlap * character exists (size is non-zero after returning from this 21740fc377bdSRandy Dunlap * function), @tr is updated with the trailing character. 217500b7c339SAmerigo Wang */ 217600b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 217700b7c339SAmerigo Wang unsigned long *val, bool *neg, 217800b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 217900b7c339SAmerigo Wang { 218000b7c339SAmerigo Wang int len; 218100b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 218200b7c339SAmerigo Wang 218300b7c339SAmerigo Wang if (!*size) 218400b7c339SAmerigo Wang return -EINVAL; 218500b7c339SAmerigo Wang 218600b7c339SAmerigo Wang len = *size; 218700b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 218800b7c339SAmerigo Wang len = TMPBUFLEN - 1; 218900b7c339SAmerigo Wang 219000b7c339SAmerigo Wang memcpy(tmp, *buf, len); 219100b7c339SAmerigo Wang 219200b7c339SAmerigo Wang tmp[len] = 0; 219300b7c339SAmerigo Wang p = tmp; 219400b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 219500b7c339SAmerigo Wang *neg = true; 219600b7c339SAmerigo Wang p++; 219700b7c339SAmerigo Wang } else 219800b7c339SAmerigo Wang *neg = false; 219900b7c339SAmerigo Wang if (!isdigit(*p)) 220000b7c339SAmerigo Wang return -EINVAL; 220100b7c339SAmerigo Wang 220200b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 220300b7c339SAmerigo Wang 220400b7c339SAmerigo Wang len = p - tmp; 220500b7c339SAmerigo Wang 220600b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 220700b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 220800b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 220900b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 221000b7c339SAmerigo Wang return -EINVAL; 221100b7c339SAmerigo Wang 221200b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 221300b7c339SAmerigo Wang return -EINVAL; 221400b7c339SAmerigo Wang 221500b7c339SAmerigo Wang if (tr && (len < *size)) 221600b7c339SAmerigo Wang *tr = *p; 221700b7c339SAmerigo Wang 221800b7c339SAmerigo Wang *buf += len; 221900b7c339SAmerigo Wang *size -= len; 222000b7c339SAmerigo Wang 222100b7c339SAmerigo Wang return 0; 222200b7c339SAmerigo Wang } 222300b7c339SAmerigo Wang 222400b7c339SAmerigo Wang /** 22250fc377bdSRandy Dunlap * proc_put_long - converts an integer to a decimal ASCII formatted string 222600b7c339SAmerigo Wang * 22270fc377bdSRandy Dunlap * @buf: the user buffer 22280fc377bdSRandy Dunlap * @size: the size of the user buffer 22290fc377bdSRandy Dunlap * @val: the integer to be converted 22300fc377bdSRandy Dunlap * @neg: sign of the number, %TRUE for negative 223100b7c339SAmerigo Wang * 22320fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 22330fc377bdSRandy Dunlap * the amount of bytes written. 223400b7c339SAmerigo Wang */ 223500b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 223600b7c339SAmerigo Wang bool neg) 223700b7c339SAmerigo Wang { 223800b7c339SAmerigo Wang int len; 223900b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 224000b7c339SAmerigo Wang 224100b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 224200b7c339SAmerigo Wang len = strlen(tmp); 224300b7c339SAmerigo Wang if (len > *size) 224400b7c339SAmerigo Wang len = *size; 224500b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 224600b7c339SAmerigo Wang return -EFAULT; 224700b7c339SAmerigo Wang *size -= len; 224800b7c339SAmerigo Wang *buf += len; 224900b7c339SAmerigo Wang return 0; 225000b7c339SAmerigo Wang } 225100b7c339SAmerigo Wang #undef TMPBUFLEN 225200b7c339SAmerigo Wang 225300b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 225400b7c339SAmerigo Wang { 225500b7c339SAmerigo Wang if (*size) { 225600b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 225700b7c339SAmerigo Wang if (put_user(c, *buffer)) 225800b7c339SAmerigo Wang return -EFAULT; 225900b7c339SAmerigo Wang (*size)--, (*buffer)++; 226000b7c339SAmerigo Wang *buf = *buffer; 226100b7c339SAmerigo Wang } 226200b7c339SAmerigo Wang return 0; 226300b7c339SAmerigo Wang } 226400b7c339SAmerigo Wang 226500b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 22661da177e4SLinus Torvalds int *valp, 22671da177e4SLinus Torvalds int write, void *data) 22681da177e4SLinus Torvalds { 22691da177e4SLinus Torvalds if (write) { 22701da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 22711da177e4SLinus Torvalds } else { 22721da177e4SLinus Torvalds int val = *valp; 22731da177e4SLinus Torvalds if (val < 0) { 227400b7c339SAmerigo Wang *negp = true; 22751da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22761da177e4SLinus Torvalds } else { 227700b7c339SAmerigo Wang *negp = false; 22781da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22791da177e4SLinus Torvalds } 22801da177e4SLinus Torvalds } 22811da177e4SLinus Torvalds return 0; 22821da177e4SLinus Torvalds } 22831da177e4SLinus Torvalds 228400b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 228500b7c339SAmerigo Wang 2286d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 22878d65af78SAlexey Dobriyan int write, void __user *buffer, 2288fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 228900b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 22901da177e4SLinus Torvalds int write, void *data), 22911da177e4SLinus Torvalds void *data) 22921da177e4SLinus Torvalds { 229300b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 229400b7c339SAmerigo Wang unsigned long page = 0; 229500b7c339SAmerigo Wang size_t left; 229600b7c339SAmerigo Wang char *kbuf; 22971da177e4SLinus Torvalds 229800b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 22991da177e4SLinus Torvalds *lenp = 0; 23001da177e4SLinus Torvalds return 0; 23011da177e4SLinus Torvalds } 23021da177e4SLinus Torvalds 2303fcfbd547SKirill Korotaev i = (int *) tbl_data; 23041da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 23051da177e4SLinus Torvalds left = *lenp; 23061da177e4SLinus Torvalds 23071da177e4SLinus Torvalds if (!conv) 23081da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 23091da177e4SLinus Torvalds 231000b7c339SAmerigo Wang if (write) { 231100b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 231200b7c339SAmerigo Wang left = PAGE_SIZE - 1; 231300b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 231400b7c339SAmerigo Wang kbuf = (char *) page; 231500b7c339SAmerigo Wang if (!kbuf) 231600b7c339SAmerigo Wang return -ENOMEM; 231700b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 231800b7c339SAmerigo Wang err = -EFAULT; 231900b7c339SAmerigo Wang goto free; 232000b7c339SAmerigo Wang } 232100b7c339SAmerigo Wang kbuf[left] = 0; 232200b7c339SAmerigo Wang } 232300b7c339SAmerigo Wang 23241da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 232500b7c339SAmerigo Wang unsigned long lval; 232600b7c339SAmerigo Wang bool neg; 232700b7c339SAmerigo Wang 23281da177e4SLinus Torvalds if (write) { 232900b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 233000b7c339SAmerigo Wang 2331563b0467SJ. R. Okajima if (!left) 2332563b0467SJ. R. Okajima break; 233300b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 233400b7c339SAmerigo Wang proc_wspace_sep, 233500b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 233600b7c339SAmerigo Wang if (err) 23371da177e4SLinus Torvalds break; 233800b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 233900b7c339SAmerigo Wang err = -EINVAL; 234000b7c339SAmerigo Wang break; 23411da177e4SLinus Torvalds } 23421da177e4SLinus Torvalds } else { 234300b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 234400b7c339SAmerigo Wang err = -EINVAL; 234500b7c339SAmerigo Wang break; 234600b7c339SAmerigo Wang } 23471da177e4SLinus Torvalds if (!first) 234800b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 234900b7c339SAmerigo Wang if (err) 23501da177e4SLinus Torvalds break; 235100b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 235200b7c339SAmerigo Wang if (err) 235300b7c339SAmerigo Wang break; 23541da177e4SLinus Torvalds } 23551da177e4SLinus Torvalds } 23561da177e4SLinus Torvalds 235700b7c339SAmerigo Wang if (!write && !first && left && !err) 235800b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 2359563b0467SJ. R. Okajima if (write && !err && left) 236000b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 236100b7c339SAmerigo Wang free: 23621da177e4SLinus Torvalds if (write) { 236300b7c339SAmerigo Wang free_page(page); 236400b7c339SAmerigo Wang if (first) 236500b7c339SAmerigo Wang return err ? : -EINVAL; 23661da177e4SLinus Torvalds } 23671da177e4SLinus Torvalds *lenp -= left; 23681da177e4SLinus Torvalds *ppos += *lenp; 236900b7c339SAmerigo Wang return err; 23701da177e4SLinus Torvalds } 23711da177e4SLinus Torvalds 23728d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2373fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 237400b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 2375fcfbd547SKirill Korotaev int write, void *data), 2376fcfbd547SKirill Korotaev void *data) 2377fcfbd547SKirill Korotaev { 23788d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2379fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2380fcfbd547SKirill Korotaev } 2381fcfbd547SKirill Korotaev 23821da177e4SLinus Torvalds /** 23831da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 23841da177e4SLinus Torvalds * @table: the sysctl table 23851da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23861da177e4SLinus Torvalds * @buffer: the user buffer 23871da177e4SLinus Torvalds * @lenp: the size of the user buffer 23881da177e4SLinus Torvalds * @ppos: file position 23891da177e4SLinus Torvalds * 23901da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23911da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23921da177e4SLinus Torvalds * 23931da177e4SLinus Torvalds * Returns 0 on success. 23941da177e4SLinus Torvalds */ 23958d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 23961da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23971da177e4SLinus Torvalds { 23988d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 23991da177e4SLinus Torvalds NULL,NULL); 24001da177e4SLinus Torvalds } 24011da177e4SLinus Torvalds 240234f5a398STheodore Ts'o /* 240334f5a398STheodore Ts'o * Taint values can only be increased 240425ddbb18SAndi Kleen * This means we can safely use a temporary. 240534f5a398STheodore Ts'o */ 24068d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 240734f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 240834f5a398STheodore Ts'o { 240925ddbb18SAndi Kleen struct ctl_table t; 241025ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 241125ddbb18SAndi Kleen int err; 241234f5a398STheodore Ts'o 241391fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 241434f5a398STheodore Ts'o return -EPERM; 241534f5a398STheodore Ts'o 241625ddbb18SAndi Kleen t = *table; 241725ddbb18SAndi Kleen t.data = &tmptaint; 24188d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 241925ddbb18SAndi Kleen if (err < 0) 242025ddbb18SAndi Kleen return err; 242125ddbb18SAndi Kleen 242225ddbb18SAndi Kleen if (write) { 242325ddbb18SAndi Kleen /* 242425ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 242525ddbb18SAndi Kleen * to everyone's atomic.h for this 242625ddbb18SAndi Kleen */ 242725ddbb18SAndi Kleen int i; 242825ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 242925ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 243025ddbb18SAndi Kleen add_taint(i); 243125ddbb18SAndi Kleen } 243225ddbb18SAndi Kleen } 243325ddbb18SAndi Kleen 243425ddbb18SAndi Kleen return err; 243534f5a398STheodore Ts'o } 243634f5a398STheodore Ts'o 2437bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 2438bfdc0b49SRichard Weinberger static int proc_dmesg_restrict(struct ctl_table *table, int write, 2439bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos) 2440bfdc0b49SRichard Weinberger { 2441bfdc0b49SRichard Weinberger if (write && !capable(CAP_SYS_ADMIN)) 2442bfdc0b49SRichard Weinberger return -EPERM; 2443bfdc0b49SRichard Weinberger 2444bfdc0b49SRichard Weinberger return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 2445bfdc0b49SRichard Weinberger } 2446bfdc0b49SRichard Weinberger #endif 2447bfdc0b49SRichard Weinberger 24481da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 24491da177e4SLinus Torvalds int *min; 24501da177e4SLinus Torvalds int *max; 24511da177e4SLinus Torvalds }; 24521da177e4SLinus Torvalds 245300b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 24541da177e4SLinus Torvalds int *valp, 24551da177e4SLinus Torvalds int write, void *data) 24561da177e4SLinus Torvalds { 24571da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 24581da177e4SLinus Torvalds if (write) { 24591da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 24601da177e4SLinus Torvalds if ((param->min && *param->min > val) || 24611da177e4SLinus Torvalds (param->max && *param->max < val)) 24621da177e4SLinus Torvalds return -EINVAL; 24631da177e4SLinus Torvalds *valp = val; 24641da177e4SLinus Torvalds } else { 24651da177e4SLinus Torvalds int val = *valp; 24661da177e4SLinus Torvalds if (val < 0) { 246700b7c339SAmerigo Wang *negp = true; 24681da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 24691da177e4SLinus Torvalds } else { 247000b7c339SAmerigo Wang *negp = false; 24711da177e4SLinus Torvalds *lvalp = (unsigned long)val; 24721da177e4SLinus Torvalds } 24731da177e4SLinus Torvalds } 24741da177e4SLinus Torvalds return 0; 24751da177e4SLinus Torvalds } 24761da177e4SLinus Torvalds 24771da177e4SLinus Torvalds /** 24781da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 24791da177e4SLinus Torvalds * @table: the sysctl table 24801da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24811da177e4SLinus Torvalds * @buffer: the user buffer 24821da177e4SLinus Torvalds * @lenp: the size of the user buffer 24831da177e4SLinus Torvalds * @ppos: file position 24841da177e4SLinus Torvalds * 24851da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24861da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24871da177e4SLinus Torvalds * 24881da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24891da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24901da177e4SLinus Torvalds * 24911da177e4SLinus Torvalds * Returns 0 on success. 24921da177e4SLinus Torvalds */ 24938d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 24941da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24951da177e4SLinus Torvalds { 24961da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 24971da177e4SLinus Torvalds .min = (int *) table->extra1, 24981da177e4SLinus Torvalds .max = (int *) table->extra2, 24991da177e4SLinus Torvalds }; 25008d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 25011da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 25021da177e4SLinus Torvalds } 25031da177e4SLinus Torvalds 2504d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 25051da177e4SLinus Torvalds void __user *buffer, 25061da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 25071da177e4SLinus Torvalds unsigned long convmul, 25081da177e4SLinus Torvalds unsigned long convdiv) 25091da177e4SLinus Torvalds { 251000b7c339SAmerigo Wang unsigned long *i, *min, *max; 251100b7c339SAmerigo Wang int vleft, first = 1, err = 0; 251200b7c339SAmerigo Wang unsigned long page = 0; 251300b7c339SAmerigo Wang size_t left; 251400b7c339SAmerigo Wang char *kbuf; 25151da177e4SLinus Torvalds 251600b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 25171da177e4SLinus Torvalds *lenp = 0; 25181da177e4SLinus Torvalds return 0; 25191da177e4SLinus Torvalds } 25201da177e4SLinus Torvalds 2521fcfbd547SKirill Korotaev i = (unsigned long *) data; 25221da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 25231da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 25241da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 25251da177e4SLinus Torvalds left = *lenp; 25261da177e4SLinus Torvalds 25271da177e4SLinus Torvalds if (write) { 252800b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 252900b7c339SAmerigo Wang left = PAGE_SIZE - 1; 253000b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 253100b7c339SAmerigo Wang kbuf = (char *) page; 253200b7c339SAmerigo Wang if (!kbuf) 253300b7c339SAmerigo Wang return -ENOMEM; 253400b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 253500b7c339SAmerigo Wang err = -EFAULT; 253600b7c339SAmerigo Wang goto free; 25371da177e4SLinus Torvalds } 253800b7c339SAmerigo Wang kbuf[left] = 0; 25391da177e4SLinus Torvalds } 25401da177e4SLinus Torvalds 254127b3d80aSEric Dumazet for (; left && vleft--; i++, first = 0) { 254200b7c339SAmerigo Wang unsigned long val; 254300b7c339SAmerigo Wang 254400b7c339SAmerigo Wang if (write) { 254500b7c339SAmerigo Wang bool neg; 254600b7c339SAmerigo Wang 254700b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 254800b7c339SAmerigo Wang 254900b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 255000b7c339SAmerigo Wang proc_wspace_sep, 255100b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 255200b7c339SAmerigo Wang if (err) 255300b7c339SAmerigo Wang break; 25541da177e4SLinus Torvalds if (neg) 25551da177e4SLinus Torvalds continue; 25561da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 25571da177e4SLinus Torvalds continue; 25581da177e4SLinus Torvalds *i = val; 25591da177e4SLinus Torvalds } else { 256000b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 25611da177e4SLinus Torvalds if (!first) 256200b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 256300b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 256400b7c339SAmerigo Wang if (err) 256500b7c339SAmerigo Wang break; 25661da177e4SLinus Torvalds } 25671da177e4SLinus Torvalds } 25681da177e4SLinus Torvalds 256900b7c339SAmerigo Wang if (!write && !first && left && !err) 257000b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 257100b7c339SAmerigo Wang if (write && !err) 257200b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 257300b7c339SAmerigo Wang free: 25741da177e4SLinus Torvalds if (write) { 257500b7c339SAmerigo Wang free_page(page); 257600b7c339SAmerigo Wang if (first) 257700b7c339SAmerigo Wang return err ? : -EINVAL; 25781da177e4SLinus Torvalds } 25791da177e4SLinus Torvalds *lenp -= left; 25801da177e4SLinus Torvalds *ppos += *lenp; 258100b7c339SAmerigo Wang return err; 25821da177e4SLinus Torvalds } 25831da177e4SLinus Torvalds 2584d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2585fcfbd547SKirill Korotaev void __user *buffer, 2586fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2587fcfbd547SKirill Korotaev unsigned long convmul, 2588fcfbd547SKirill Korotaev unsigned long convdiv) 2589fcfbd547SKirill Korotaev { 2590fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 25918d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2592fcfbd547SKirill Korotaev } 2593fcfbd547SKirill Korotaev 25941da177e4SLinus Torvalds /** 25951da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 25961da177e4SLinus Torvalds * @table: the sysctl table 25971da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25981da177e4SLinus Torvalds * @buffer: the user buffer 25991da177e4SLinus Torvalds * @lenp: the size of the user buffer 26001da177e4SLinus Torvalds * @ppos: file position 26011da177e4SLinus Torvalds * 26021da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26031da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 26041da177e4SLinus Torvalds * 26051da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26061da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26071da177e4SLinus Torvalds * 26081da177e4SLinus Torvalds * Returns 0 on success. 26091da177e4SLinus Torvalds */ 26108d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 26111da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26121da177e4SLinus Torvalds { 26138d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 26141da177e4SLinus Torvalds } 26151da177e4SLinus Torvalds 26161da177e4SLinus Torvalds /** 26171da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 26181da177e4SLinus Torvalds * @table: the sysctl table 26191da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26201da177e4SLinus Torvalds * @buffer: the user buffer 26211da177e4SLinus Torvalds * @lenp: the size of the user buffer 26221da177e4SLinus Torvalds * @ppos: file position 26231da177e4SLinus Torvalds * 26241da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26251da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 26261da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 26271da177e4SLinus Torvalds * 26281da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26291da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26301da177e4SLinus Torvalds * 26311da177e4SLinus Torvalds * Returns 0 on success. 26321da177e4SLinus Torvalds */ 2633d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26341da177e4SLinus Torvalds void __user *buffer, 26351da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26361da177e4SLinus Torvalds { 26378d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 26381da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 26391da177e4SLinus Torvalds } 26401da177e4SLinus Torvalds 26411da177e4SLinus Torvalds 264200b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 26431da177e4SLinus Torvalds int *valp, 26441da177e4SLinus Torvalds int write, void *data) 26451da177e4SLinus Torvalds { 26461da177e4SLinus Torvalds if (write) { 2647cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2648cba9f33dSBart Samwel return 1; 26491da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 26501da177e4SLinus Torvalds } else { 26511da177e4SLinus Torvalds int val = *valp; 26521da177e4SLinus Torvalds unsigned long lval; 26531da177e4SLinus Torvalds if (val < 0) { 265400b7c339SAmerigo Wang *negp = true; 26551da177e4SLinus Torvalds lval = (unsigned long)-val; 26561da177e4SLinus Torvalds } else { 265700b7c339SAmerigo Wang *negp = false; 26581da177e4SLinus Torvalds lval = (unsigned long)val; 26591da177e4SLinus Torvalds } 26601da177e4SLinus Torvalds *lvalp = lval / HZ; 26611da177e4SLinus Torvalds } 26621da177e4SLinus Torvalds return 0; 26631da177e4SLinus Torvalds } 26641da177e4SLinus Torvalds 266500b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 26661da177e4SLinus Torvalds int *valp, 26671da177e4SLinus Torvalds int write, void *data) 26681da177e4SLinus Torvalds { 26691da177e4SLinus Torvalds if (write) { 2670cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2671cba9f33dSBart Samwel return 1; 26721da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 26731da177e4SLinus Torvalds } else { 26741da177e4SLinus Torvalds int val = *valp; 26751da177e4SLinus Torvalds unsigned long lval; 26761da177e4SLinus Torvalds if (val < 0) { 267700b7c339SAmerigo Wang *negp = true; 26781da177e4SLinus Torvalds lval = (unsigned long)-val; 26791da177e4SLinus Torvalds } else { 268000b7c339SAmerigo Wang *negp = false; 26811da177e4SLinus Torvalds lval = (unsigned long)val; 26821da177e4SLinus Torvalds } 26831da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 26841da177e4SLinus Torvalds } 26851da177e4SLinus Torvalds return 0; 26861da177e4SLinus Torvalds } 26871da177e4SLinus Torvalds 268800b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 26891da177e4SLinus Torvalds int *valp, 26901da177e4SLinus Torvalds int write, void *data) 26911da177e4SLinus Torvalds { 26921da177e4SLinus Torvalds if (write) { 26931da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 26941da177e4SLinus Torvalds } else { 26951da177e4SLinus Torvalds int val = *valp; 26961da177e4SLinus Torvalds unsigned long lval; 26971da177e4SLinus Torvalds if (val < 0) { 269800b7c339SAmerigo Wang *negp = true; 26991da177e4SLinus Torvalds lval = (unsigned long)-val; 27001da177e4SLinus Torvalds } else { 270100b7c339SAmerigo Wang *negp = false; 27021da177e4SLinus Torvalds lval = (unsigned long)val; 27031da177e4SLinus Torvalds } 27041da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 27051da177e4SLinus Torvalds } 27061da177e4SLinus Torvalds return 0; 27071da177e4SLinus Torvalds } 27081da177e4SLinus Torvalds 27091da177e4SLinus Torvalds /** 27101da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 27111da177e4SLinus Torvalds * @table: the sysctl table 27121da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27131da177e4SLinus Torvalds * @buffer: the user buffer 27141da177e4SLinus Torvalds * @lenp: the size of the user buffer 27151da177e4SLinus Torvalds * @ppos: file position 27161da177e4SLinus Torvalds * 27171da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27181da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27191da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 27201da177e4SLinus Torvalds * jiffies. 27211da177e4SLinus Torvalds * 27221da177e4SLinus Torvalds * Returns 0 on success. 27231da177e4SLinus Torvalds */ 27248d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 27251da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27261da177e4SLinus Torvalds { 27278d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27281da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 27291da177e4SLinus Torvalds } 27301da177e4SLinus Torvalds 27311da177e4SLinus Torvalds /** 27321da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 27331da177e4SLinus Torvalds * @table: the sysctl table 27341da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27351da177e4SLinus Torvalds * @buffer: the user buffer 27361da177e4SLinus Torvalds * @lenp: the size of the user buffer 27371e5d5331SRandy Dunlap * @ppos: pointer to the file position 27381da177e4SLinus Torvalds * 27391da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27401da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27411da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 27421da177e4SLinus Torvalds * are converted into jiffies. 27431da177e4SLinus Torvalds * 27441da177e4SLinus Torvalds * Returns 0 on success. 27451da177e4SLinus Torvalds */ 27468d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 27471da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27481da177e4SLinus Torvalds { 27498d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27501da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 27511da177e4SLinus Torvalds } 27521da177e4SLinus Torvalds 27531da177e4SLinus Torvalds /** 27541da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 27551da177e4SLinus Torvalds * @table: the sysctl table 27561da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27571da177e4SLinus Torvalds * @buffer: the user buffer 27581da177e4SLinus Torvalds * @lenp: the size of the user buffer 275967be2dd1SMartin Waitz * @ppos: file position 276067be2dd1SMartin Waitz * @ppos: the current position in the file 27611da177e4SLinus Torvalds * 27621da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27631da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27641da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 27651da177e4SLinus Torvalds * are converted into jiffies. 27661da177e4SLinus Torvalds * 27671da177e4SLinus Torvalds * Returns 0 on success. 27681da177e4SLinus Torvalds */ 27698d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 27701da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27711da177e4SLinus Torvalds { 27728d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 27731da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 27741da177e4SLinus Torvalds } 27751da177e4SLinus Torvalds 27768d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 27779ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 27789ec52099SCedric Le Goater { 27799ec52099SCedric Le Goater struct pid *new_pid; 27809ec52099SCedric Le Goater pid_t tmp; 27819ec52099SCedric Le Goater int r; 27829ec52099SCedric Le Goater 27836c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 27849ec52099SCedric Le Goater 27858d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 27869ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 27879ec52099SCedric Le Goater if (r || !write) 27889ec52099SCedric Le Goater return r; 27899ec52099SCedric Le Goater 27909ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 27919ec52099SCedric Le Goater if (!new_pid) 27929ec52099SCedric Le Goater return -ESRCH; 27939ec52099SCedric Le Goater 27949ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 27959ec52099SCedric Le Goater return 0; 27969ec52099SCedric Le Goater } 27979ec52099SCedric Le Goater 27989f977fb7SOctavian Purdila /** 27999f977fb7SOctavian Purdila * proc_do_large_bitmap - read/write from/to a large bitmap 28009f977fb7SOctavian Purdila * @table: the sysctl table 28019f977fb7SOctavian Purdila * @write: %TRUE if this is a write to the sysctl file 28029f977fb7SOctavian Purdila * @buffer: the user buffer 28039f977fb7SOctavian Purdila * @lenp: the size of the user buffer 28049f977fb7SOctavian Purdila * @ppos: file position 28059f977fb7SOctavian Purdila * 28069f977fb7SOctavian Purdila * The bitmap is stored at table->data and the bitmap length (in bits) 28079f977fb7SOctavian Purdila * in table->maxlen. 28089f977fb7SOctavian Purdila * 28099f977fb7SOctavian Purdila * We use a range comma separated format (e.g. 1,3-4,10-10) so that 28109f977fb7SOctavian Purdila * large bitmaps may be represented in a compact manner. Writing into 28119f977fb7SOctavian Purdila * the file will clear the bitmap then update it with the given input. 28129f977fb7SOctavian Purdila * 28139f977fb7SOctavian Purdila * Returns 0 on success. 28149f977fb7SOctavian Purdila */ 28159f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write, 28169f977fb7SOctavian Purdila void __user *buffer, size_t *lenp, loff_t *ppos) 28179f977fb7SOctavian Purdila { 28189f977fb7SOctavian Purdila int err = 0; 28199f977fb7SOctavian Purdila bool first = 1; 28209f977fb7SOctavian Purdila size_t left = *lenp; 28219f977fb7SOctavian Purdila unsigned long bitmap_len = table->maxlen; 28229f977fb7SOctavian Purdila unsigned long *bitmap = (unsigned long *) table->data; 28239f977fb7SOctavian Purdila unsigned long *tmp_bitmap = NULL; 28249f977fb7SOctavian Purdila char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 28259f977fb7SOctavian Purdila 28269f977fb7SOctavian Purdila if (!bitmap_len || !left || (*ppos && !write)) { 28279f977fb7SOctavian Purdila *lenp = 0; 28289f977fb7SOctavian Purdila return 0; 28299f977fb7SOctavian Purdila } 28309f977fb7SOctavian Purdila 28319f977fb7SOctavian Purdila if (write) { 28329f977fb7SOctavian Purdila unsigned long page = 0; 28339f977fb7SOctavian Purdila char *kbuf; 28349f977fb7SOctavian Purdila 28359f977fb7SOctavian Purdila if (left > PAGE_SIZE - 1) 28369f977fb7SOctavian Purdila left = PAGE_SIZE - 1; 28379f977fb7SOctavian Purdila 28389f977fb7SOctavian Purdila page = __get_free_page(GFP_TEMPORARY); 28399f977fb7SOctavian Purdila kbuf = (char *) page; 28409f977fb7SOctavian Purdila if (!kbuf) 28419f977fb7SOctavian Purdila return -ENOMEM; 28429f977fb7SOctavian Purdila if (copy_from_user(kbuf, buffer, left)) { 28439f977fb7SOctavian Purdila free_page(page); 28449f977fb7SOctavian Purdila return -EFAULT; 28459f977fb7SOctavian Purdila } 28469f977fb7SOctavian Purdila kbuf[left] = 0; 28479f977fb7SOctavian Purdila 28489f977fb7SOctavian Purdila tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), 28499f977fb7SOctavian Purdila GFP_KERNEL); 28509f977fb7SOctavian Purdila if (!tmp_bitmap) { 28519f977fb7SOctavian Purdila free_page(page); 28529f977fb7SOctavian Purdila return -ENOMEM; 28539f977fb7SOctavian Purdila } 28549f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28559f977fb7SOctavian Purdila while (!err && left) { 28569f977fb7SOctavian Purdila unsigned long val_a, val_b; 28579f977fb7SOctavian Purdila bool neg; 28589f977fb7SOctavian Purdila 28599f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, 28609f977fb7SOctavian Purdila sizeof(tr_a), &c); 28619f977fb7SOctavian Purdila if (err) 28629f977fb7SOctavian Purdila break; 28639f977fb7SOctavian Purdila if (val_a >= bitmap_len || neg) { 28649f977fb7SOctavian Purdila err = -EINVAL; 28659f977fb7SOctavian Purdila break; 28669f977fb7SOctavian Purdila } 28679f977fb7SOctavian Purdila 28689f977fb7SOctavian Purdila val_b = val_a; 28699f977fb7SOctavian Purdila if (left) { 28709f977fb7SOctavian Purdila kbuf++; 28719f977fb7SOctavian Purdila left--; 28729f977fb7SOctavian Purdila } 28739f977fb7SOctavian Purdila 28749f977fb7SOctavian Purdila if (c == '-') { 28759f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_b, 28769f977fb7SOctavian Purdila &neg, tr_b, sizeof(tr_b), 28779f977fb7SOctavian Purdila &c); 28789f977fb7SOctavian Purdila if (err) 28799f977fb7SOctavian Purdila break; 28809f977fb7SOctavian Purdila if (val_b >= bitmap_len || neg || 28819f977fb7SOctavian Purdila val_a > val_b) { 28829f977fb7SOctavian Purdila err = -EINVAL; 28839f977fb7SOctavian Purdila break; 28849f977fb7SOctavian Purdila } 28859f977fb7SOctavian Purdila if (left) { 28869f977fb7SOctavian Purdila kbuf++; 28879f977fb7SOctavian Purdila left--; 28889f977fb7SOctavian Purdila } 28899f977fb7SOctavian Purdila } 28909f977fb7SOctavian Purdila 28919f977fb7SOctavian Purdila while (val_a <= val_b) 28929f977fb7SOctavian Purdila set_bit(val_a++, tmp_bitmap); 28939f977fb7SOctavian Purdila 28949f977fb7SOctavian Purdila first = 0; 28959f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28969f977fb7SOctavian Purdila } 28979f977fb7SOctavian Purdila free_page(page); 28989f977fb7SOctavian Purdila } else { 28999f977fb7SOctavian Purdila unsigned long bit_a, bit_b = 0; 29009f977fb7SOctavian Purdila 29019f977fb7SOctavian Purdila while (left) { 29029f977fb7SOctavian Purdila bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 29039f977fb7SOctavian Purdila if (bit_a >= bitmap_len) 29049f977fb7SOctavian Purdila break; 29059f977fb7SOctavian Purdila bit_b = find_next_zero_bit(bitmap, bitmap_len, 29069f977fb7SOctavian Purdila bit_a + 1) - 1; 29079f977fb7SOctavian Purdila 29089f977fb7SOctavian Purdila if (!first) { 29099f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, ','); 29109f977fb7SOctavian Purdila if (err) 29119f977fb7SOctavian Purdila break; 29129f977fb7SOctavian Purdila } 29139f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_a, false); 29149f977fb7SOctavian Purdila if (err) 29159f977fb7SOctavian Purdila break; 29169f977fb7SOctavian Purdila if (bit_a != bit_b) { 29179f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '-'); 29189f977fb7SOctavian Purdila if (err) 29199f977fb7SOctavian Purdila break; 29209f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_b, false); 29219f977fb7SOctavian Purdila if (err) 29229f977fb7SOctavian Purdila break; 29239f977fb7SOctavian Purdila } 29249f977fb7SOctavian Purdila 29259f977fb7SOctavian Purdila first = 0; bit_b++; 29269f977fb7SOctavian Purdila } 29279f977fb7SOctavian Purdila if (!err) 29289f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '\n'); 29299f977fb7SOctavian Purdila } 29309f977fb7SOctavian Purdila 29319f977fb7SOctavian Purdila if (!err) { 29329f977fb7SOctavian Purdila if (write) { 29339f977fb7SOctavian Purdila if (*ppos) 29349f977fb7SOctavian Purdila bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 29359f977fb7SOctavian Purdila else 29369f977fb7SOctavian Purdila memcpy(bitmap, tmp_bitmap, 29379f977fb7SOctavian Purdila BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long)); 29389f977fb7SOctavian Purdila } 29399f977fb7SOctavian Purdila kfree(tmp_bitmap); 29409f977fb7SOctavian Purdila *lenp -= left; 29419f977fb7SOctavian Purdila *ppos += *lenp; 29429f977fb7SOctavian Purdila return 0; 29439f977fb7SOctavian Purdila } else { 29449f977fb7SOctavian Purdila kfree(tmp_bitmap); 29459f977fb7SOctavian Purdila return err; 29469f977fb7SOctavian Purdila } 29479f977fb7SOctavian Purdila } 29489f977fb7SOctavian Purdila 294955610500SJovi Zhang #else /* CONFIG_PROC_SYSCTL */ 29501da177e4SLinus Torvalds 29518d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 29521da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29531da177e4SLinus Torvalds { 29541da177e4SLinus Torvalds return -ENOSYS; 29551da177e4SLinus Torvalds } 29561da177e4SLinus Torvalds 29578d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 29581da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29591da177e4SLinus Torvalds { 29601da177e4SLinus Torvalds return -ENOSYS; 29611da177e4SLinus Torvalds } 29621da177e4SLinus Torvalds 29638d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 29641da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29651da177e4SLinus Torvalds { 29661da177e4SLinus Torvalds return -ENOSYS; 29671da177e4SLinus Torvalds } 29681da177e4SLinus Torvalds 29698d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 29701da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29711da177e4SLinus Torvalds { 29721da177e4SLinus Torvalds return -ENOSYS; 29731da177e4SLinus Torvalds } 29741da177e4SLinus Torvalds 29758d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 29761da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29771da177e4SLinus Torvalds { 29781da177e4SLinus Torvalds return -ENOSYS; 29791da177e4SLinus Torvalds } 29801da177e4SLinus Torvalds 29818d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 29821da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29831da177e4SLinus Torvalds { 29841da177e4SLinus Torvalds return -ENOSYS; 29851da177e4SLinus Torvalds } 29861da177e4SLinus Torvalds 29878d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 29881da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29891da177e4SLinus Torvalds { 29901da177e4SLinus Torvalds return -ENOSYS; 29911da177e4SLinus Torvalds } 29921da177e4SLinus Torvalds 2993d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 29941da177e4SLinus Torvalds void __user *buffer, 29951da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 29961da177e4SLinus Torvalds { 29971da177e4SLinus Torvalds return -ENOSYS; 29981da177e4SLinus Torvalds } 29991da177e4SLinus Torvalds 30001da177e4SLinus Torvalds 300155610500SJovi Zhang #endif /* CONFIG_PROC_SYSCTL */ 30021da177e4SLinus Torvalds 30031da177e4SLinus Torvalds /* 30041da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 30051da177e4SLinus Torvalds * exception granted :-) 30061da177e4SLinus Torvalds */ 30071da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 30081da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 30091da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 30101da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 30111da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 30121da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 30131da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 30141da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 30151da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 301629e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 30171da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 3018