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> 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds #include <asm/uaccess.h> 621da177e4SLinus Torvalds #include <asm/processor.h> 631da177e4SLinus Torvalds 6429cbc78bSAndi Kleen #ifdef CONFIG_X86 6529cbc78bSAndi Kleen #include <asm/nmi.h> 660741f4d2SChuck Ebbert #include <asm/stacktrace.h> 676e7c4025SIngo Molnar #include <asm/io.h> 6829cbc78bSAndi Kleen #endif 69c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 70c55b7c3eSDave Young #include <linux/acct.h> 71c55b7c3eSDave Young #endif 724f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 734f0e056fSDave Young #include <linux/rtmutex.h> 744f0e056fSDave Young #endif 752edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 762edf5e49SDave Young #include <linux/lockdep.h> 772edf5e49SDave Young #endif 7815485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 7915485a46SDave Young #include <scsi/sg.h> 8015485a46SDave Young #endif 8129cbc78bSAndi Kleen 8258687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 83504d7cf1SDon Zickus #include <linux/nmi.h> 84504d7cf1SDon Zickus #endif 85504d7cf1SDon Zickus 867058cb02SEric W. Biederman 871da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 881da177e4SLinus Torvalds 891da177e4SLinus Torvalds /* External variables not in a header file. */ 901da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 911da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 921da177e4SLinus Torvalds extern int max_threads; 931da177e4SLinus Torvalds extern int core_uses_pid; 94d6e71144SAlan Cox extern int suid_dumpable; 951da177e4SLinus Torvalds extern char core_pattern[]; 96a293980cSNeil Horman extern unsigned int core_pipe_limit; 971da177e4SLinus Torvalds extern int pid_max; 981da177e4SLinus Torvalds extern int min_free_kbytes; 991da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 1009d0243bcSAndrew Morton extern int sysctl_drop_caches; 1018ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 102bebfa101SAndi Kleen extern int compat_log; 1039745512cSArjan van de Ven extern int latencytop_enabled; 104eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 105dd8632a1SPaul Mundt #ifndef CONFIG_MMU 106dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 107dd8632a1SPaul Mundt #endif 108cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 1095e605b64SJens Axboe extern int blk_iopoll_enabled; 110cb684b5bSJens Axboe #endif 1111da177e4SLinus Torvalds 112c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1132508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 114c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1159383d967SDimitri Sivanich static int neg_one = -1; 116c4f3b63fSRavikiran G Thirumalai #endif 117c4f3b63fSRavikiran G Thirumalai 118c4f3b63fSRavikiran G Thirumalai static int zero; 119cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 120cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 121cb16e95fSPetr Holasek static int __maybe_unused three = 3; 122fc3501d4SSven Wegener static unsigned long one_ul = 1; 123c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 124af91322eSDave Young #ifdef CONFIG_PRINTK 125af91322eSDave Young static int ten_thousand = 10000; 126af91322eSDave Young #endif 127c4f3b63fSRavikiran G Thirumalai 1289e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1299e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1309e4a5bdaSAndrea Righi 1311da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1321da177e4SLinus Torvalds static int maxolduid = 65535; 1331da177e4SLinus Torvalds static int minolduid; 1348ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1371da177e4SLinus Torvalds 138d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 139d14f1729SDave Young #include <linux/inotify.h> 140d14f1729SDave Young #endif 14172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 14217f04fbbSDavid S. Miller #include <asm/system.h> 1431da177e4SLinus Torvalds #endif 1441da177e4SLinus Torvalds 1450871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1460871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1470871420fSDavid S. Miller #endif 1480871420fSDavid S. Miller 1491da177e4SLinus Torvalds #ifdef __hppa__ 1501da177e4SLinus Torvalds extern int pwrsw_enabled; 1511da177e4SLinus Torvalds extern int unaligned_enabled; 1521da177e4SLinus Torvalds #endif 1531da177e4SLinus Torvalds 154347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1551da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1561da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1571da177e4SLinus Torvalds #endif 1581da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 159951f22d5SMartin Schwidefsky extern int spin_retry; 1601da177e4SLinus Torvalds #endif 1611da177e4SLinus Torvalds 162d2b176edSJes Sorensen #ifdef CONFIG_IA64 163d2b176edSJes Sorensen extern int no_unaligned_warning; 16488fc241fSDoug Chapman extern int unaligned_dump_stack; 165d2b176edSJes Sorensen #endif 166d2b176edSJes Sorensen 167d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1688d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1699ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1708d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 17134f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 172d6f8ff73SRandy Dunlap #endif 1739ec52099SCedric Le Goater 174bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 175bfdc0b49SRichard Weinberger static int proc_dmesg_restrict(struct ctl_table *table, int write, 176bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos); 177bfdc0b49SRichard Weinberger #endif 178bfdc0b49SRichard Weinberger 17997f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ 1808c6a98b2SAndy Whitcroft /* Note: sysrq code uses it's own private copy */ 1818c6a98b2SAndy Whitcroft static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; 18297f5f0cdSDmitry Torokhov 18397f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write, 18497f5f0cdSDmitry Torokhov void __user *buffer, size_t *lenp, 18597f5f0cdSDmitry Torokhov loff_t *ppos) 18697f5f0cdSDmitry Torokhov { 18797f5f0cdSDmitry Torokhov int error; 18897f5f0cdSDmitry Torokhov 18997f5f0cdSDmitry Torokhov error = proc_dointvec(table, write, buffer, lenp, ppos); 19097f5f0cdSDmitry Torokhov if (error) 19197f5f0cdSDmitry Torokhov return error; 19297f5f0cdSDmitry Torokhov 19397f5f0cdSDmitry Torokhov if (write) 19497f5f0cdSDmitry Torokhov sysrq_toggle_support(__sysrq_enabled); 19597f5f0cdSDmitry Torokhov 19697f5f0cdSDmitry Torokhov return 0; 19797f5f0cdSDmitry Torokhov } 19897f5f0cdSDmitry Torokhov 19997f5f0cdSDmitry Torokhov #endif 20097f5f0cdSDmitry Torokhov 201d8217f07SEric W. Biederman static struct ctl_table root_table[]; 202e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 203e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 204dfef6dcdSAl Viro {{.count = 1, 205e51b6ba0SEric W. Biederman .ctl_table = root_table, 206dfef6dcdSAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, 207e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 20873455092SAl Viro .set = &sysctl_table_root.default_set, 209e51b6ba0SEric W. Biederman }; 210e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 211e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 21273455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 213e51b6ba0SEric W. Biederman }; 2141da177e4SLinus Torvalds 215d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 216d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 217d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 218d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 219d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 220d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 2217ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 2227ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 2237ef9964eSDavide Libenzi #endif 2241da177e4SLinus Torvalds 2251da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2261da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2271da177e4SLinus Torvalds #endif 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds /* The default sysctl tables: */ 2301da177e4SLinus Torvalds 231d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2321da177e4SLinus Torvalds { 2331da177e4SLinus Torvalds .procname = "kernel", 2341da177e4SLinus Torvalds .mode = 0555, 2351da177e4SLinus Torvalds .child = kern_table, 2361da177e4SLinus Torvalds }, 2371da177e4SLinus Torvalds { 2381da177e4SLinus Torvalds .procname = "vm", 2391da177e4SLinus Torvalds .mode = 0555, 2401da177e4SLinus Torvalds .child = vm_table, 2411da177e4SLinus Torvalds }, 2421da177e4SLinus Torvalds { 2431da177e4SLinus Torvalds .procname = "fs", 2441da177e4SLinus Torvalds .mode = 0555, 2451da177e4SLinus Torvalds .child = fs_table, 2461da177e4SLinus Torvalds }, 2471da177e4SLinus Torvalds { 2481da177e4SLinus Torvalds .procname = "debug", 2491da177e4SLinus Torvalds .mode = 0555, 2501da177e4SLinus Torvalds .child = debug_table, 2511da177e4SLinus Torvalds }, 2521da177e4SLinus Torvalds { 2531da177e4SLinus Torvalds .procname = "dev", 2541da177e4SLinus Torvalds .mode = 0555, 2551da177e4SLinus Torvalds .child = dev_table, 2561da177e4SLinus Torvalds }, 2576fce56ecSEric W. Biederman { } 2581da177e4SLinus Torvalds }; 2591da177e4SLinus Torvalds 26077e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 26173c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 26273c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 26373c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 26473c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2651983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2661983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 26777e54a1fSIngo Molnar #endif 26877e54a1fSIngo Molnar 2695e771905SMel Gorman #ifdef CONFIG_COMPACTION 2705e771905SMel Gorman static int min_extfrag_threshold; 2715e771905SMel Gorman static int max_extfrag_threshold = 1000; 2725e771905SMel Gorman #endif 2735e771905SMel Gorman 274d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2752bba22c5SMike Galbraith { 2762bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2772bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2782bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2792bba22c5SMike Galbraith .mode = 0644, 2806d456111SEric W. Biederman .proc_handler = proc_dointvec, 2812bba22c5SMike Galbraith }, 28277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 28377e54a1fSIngo Molnar { 284b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 285b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 28677e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28777e54a1fSIngo Molnar .mode = 0644, 288702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 289b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 290b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 29177e54a1fSIngo Molnar }, 29277e54a1fSIngo Molnar { 29321805085SPeter Zijlstra .procname = "sched_latency_ns", 29421805085SPeter Zijlstra .data = &sysctl_sched_latency, 29521805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 29621805085SPeter Zijlstra .mode = 0644, 297702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 29821805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 29921805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 30021805085SPeter Zijlstra }, 30121805085SPeter Zijlstra { 30277e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 30377e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 30477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 30577e54a1fSIngo Molnar .mode = 0644, 306702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 30777e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 30877e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 30977e54a1fSIngo Molnar }, 31077e54a1fSIngo Molnar { 3111983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3121983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3131983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3141983a922SChristian Ehrhardt .mode = 0644, 315702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3161983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3171983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3182398f2c6SPeter Zijlstra }, 3192398f2c6SPeter Zijlstra { 320da84d961SIngo Molnar .procname = "sched_migration_cost", 321da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 322da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 323da84d961SIngo Molnar .mode = 0644, 3246d456111SEric W. Biederman .proc_handler = proc_dointvec, 325da84d961SIngo Molnar }, 326b82d9fddSPeter Zijlstra { 327b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 328b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 329b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 330fa85ae24SPeter Zijlstra .mode = 0644, 3316d456111SEric W. Biederman .proc_handler = proc_dointvec, 332fa85ae24SPeter Zijlstra }, 333cd1bb94bSArun R Bharadwaj { 334e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 335e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 336e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 337e9e9250bSPeter Zijlstra .mode = 0644, 3386d456111SEric W. Biederman .proc_handler = proc_dointvec, 339e9e9250bSPeter Zijlstra }, 340e9e9250bSPeter Zijlstra { 341a7a4f8a7SPaul Turner .procname = "sched_shares_window", 342a7a4f8a7SPaul Turner .data = &sysctl_sched_shares_window, 343a7a4f8a7SPaul Turner .maxlen = sizeof(unsigned int), 344a7a4f8a7SPaul Turner .mode = 0644, 345a7a4f8a7SPaul Turner .proc_handler = proc_dointvec, 346a7a4f8a7SPaul Turner }, 347a7a4f8a7SPaul Turner { 348cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 349cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 350cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 351cd1bb94bSArun R Bharadwaj .mode = 0644, 3526d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 353bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 354bfdb4d9fSArun R Bharadwaj .extra2 = &one, 355cd1bb94bSArun R Bharadwaj }, 3561fc84aaaSPeter Zijlstra #endif 3571799e35dSIngo Molnar { 3589f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3599f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3609f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3619f0c1e56SPeter Zijlstra .mode = 0644, 3626d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3639f0c1e56SPeter Zijlstra }, 3649f0c1e56SPeter Zijlstra { 3659f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3669f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3679f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3689f0c1e56SPeter Zijlstra .mode = 0644, 3696d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3709f0c1e56SPeter Zijlstra }, 3715091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 3725091faa4SMike Galbraith { 3735091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 3745091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 3755091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 3765091faa4SMike Galbraith .mode = 0644, 3771747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 3785091faa4SMike Galbraith .extra1 = &zero, 3795091faa4SMike Galbraith .extra2 = &one, 3805091faa4SMike Galbraith }, 3815091faa4SMike Galbraith #endif 382*ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 383*ec12cb7fSPaul Turner { 384*ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 385*ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 386*ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 387*ec12cb7fSPaul Turner .mode = 0644, 388*ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 389*ec12cb7fSPaul Turner .extra1 = &one, 390*ec12cb7fSPaul Turner }, 391*ec12cb7fSPaul Turner #endif 392f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 393f20786ffSPeter Zijlstra { 394f20786ffSPeter Zijlstra .procname = "prove_locking", 395f20786ffSPeter Zijlstra .data = &prove_locking, 396f20786ffSPeter Zijlstra .maxlen = sizeof(int), 397f20786ffSPeter Zijlstra .mode = 0644, 3986d456111SEric W. Biederman .proc_handler = proc_dointvec, 399f20786ffSPeter Zijlstra }, 400f20786ffSPeter Zijlstra #endif 401f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 402f20786ffSPeter Zijlstra { 403f20786ffSPeter Zijlstra .procname = "lock_stat", 404f20786ffSPeter Zijlstra .data = &lock_stat, 405f20786ffSPeter Zijlstra .maxlen = sizeof(int), 406f20786ffSPeter Zijlstra .mode = 0644, 4076d456111SEric W. Biederman .proc_handler = proc_dointvec, 408f20786ffSPeter Zijlstra }, 409f20786ffSPeter Zijlstra #endif 41077e54a1fSIngo Molnar { 4111da177e4SLinus Torvalds .procname = "panic", 4121da177e4SLinus Torvalds .data = &panic_timeout, 4131da177e4SLinus Torvalds .maxlen = sizeof(int), 4141da177e4SLinus Torvalds .mode = 0644, 4156d456111SEric W. Biederman .proc_handler = proc_dointvec, 4161da177e4SLinus Torvalds }, 4171da177e4SLinus Torvalds { 4181da177e4SLinus Torvalds .procname = "core_uses_pid", 4191da177e4SLinus Torvalds .data = &core_uses_pid, 4201da177e4SLinus Torvalds .maxlen = sizeof(int), 4211da177e4SLinus Torvalds .mode = 0644, 4226d456111SEric W. Biederman .proc_handler = proc_dointvec, 4231da177e4SLinus Torvalds }, 4241da177e4SLinus Torvalds { 4251da177e4SLinus Torvalds .procname = "core_pattern", 4261da177e4SLinus Torvalds .data = core_pattern, 42771ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4281da177e4SLinus Torvalds .mode = 0644, 4296d456111SEric W. Biederman .proc_handler = proc_dostring, 4301da177e4SLinus Torvalds }, 431a293980cSNeil Horman { 432a293980cSNeil Horman .procname = "core_pipe_limit", 433a293980cSNeil Horman .data = &core_pipe_limit, 434a293980cSNeil Horman .maxlen = sizeof(unsigned int), 435a293980cSNeil Horman .mode = 0644, 4366d456111SEric W. Biederman .proc_handler = proc_dointvec, 437a293980cSNeil Horman }, 43834f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4391da177e4SLinus Torvalds { 4401da177e4SLinus Torvalds .procname = "tainted", 44125ddbb18SAndi Kleen .maxlen = sizeof(long), 44234f5a398STheodore Ts'o .mode = 0644, 4436d456111SEric W. Biederman .proc_handler = proc_taint, 4441da177e4SLinus Torvalds }, 44534f5a398STheodore Ts'o #endif 4469745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4479745512cSArjan van de Ven { 4489745512cSArjan van de Ven .procname = "latencytop", 4499745512cSArjan van de Ven .data = &latencytop_enabled, 4509745512cSArjan van de Ven .maxlen = sizeof(int), 4519745512cSArjan van de Ven .mode = 0644, 4526d456111SEric W. Biederman .proc_handler = proc_dointvec, 4539745512cSArjan van de Ven }, 4549745512cSArjan van de Ven #endif 4551da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4561da177e4SLinus Torvalds { 4571da177e4SLinus Torvalds .procname = "real-root-dev", 4581da177e4SLinus Torvalds .data = &real_root_dev, 4591da177e4SLinus Torvalds .maxlen = sizeof(int), 4601da177e4SLinus Torvalds .mode = 0644, 4616d456111SEric W. Biederman .proc_handler = proc_dointvec, 4621da177e4SLinus Torvalds }, 4631da177e4SLinus Torvalds #endif 46445807a1dSIngo Molnar { 46545807a1dSIngo Molnar .procname = "print-fatal-signals", 46645807a1dSIngo Molnar .data = &print_fatal_signals, 46745807a1dSIngo Molnar .maxlen = sizeof(int), 46845807a1dSIngo Molnar .mode = 0644, 4696d456111SEric W. Biederman .proc_handler = proc_dointvec, 47045807a1dSIngo Molnar }, 47172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4721da177e4SLinus Torvalds { 4731da177e4SLinus Torvalds .procname = "reboot-cmd", 4741da177e4SLinus Torvalds .data = reboot_command, 4751da177e4SLinus Torvalds .maxlen = 256, 4761da177e4SLinus Torvalds .mode = 0644, 4776d456111SEric W. Biederman .proc_handler = proc_dostring, 4781da177e4SLinus Torvalds }, 4791da177e4SLinus Torvalds { 4801da177e4SLinus Torvalds .procname = "stop-a", 4811da177e4SLinus Torvalds .data = &stop_a_enabled, 4821da177e4SLinus Torvalds .maxlen = sizeof (int), 4831da177e4SLinus Torvalds .mode = 0644, 4846d456111SEric W. Biederman .proc_handler = proc_dointvec, 4851da177e4SLinus Torvalds }, 4861da177e4SLinus Torvalds { 4871da177e4SLinus Torvalds .procname = "scons-poweroff", 4881da177e4SLinus Torvalds .data = &scons_pwroff, 4891da177e4SLinus Torvalds .maxlen = sizeof (int), 4901da177e4SLinus Torvalds .mode = 0644, 4916d456111SEric W. Biederman .proc_handler = proc_dointvec, 4921da177e4SLinus Torvalds }, 4931da177e4SLinus Torvalds #endif 4940871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4950871420fSDavid S. Miller { 4960871420fSDavid S. Miller .procname = "tsb-ratio", 4970871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4980871420fSDavid S. Miller .maxlen = sizeof (int), 4990871420fSDavid S. Miller .mode = 0644, 5006d456111SEric W. Biederman .proc_handler = proc_dointvec, 5010871420fSDavid S. Miller }, 5020871420fSDavid S. Miller #endif 5031da177e4SLinus Torvalds #ifdef __hppa__ 5041da177e4SLinus Torvalds { 5051da177e4SLinus Torvalds .procname = "soft-power", 5061da177e4SLinus Torvalds .data = &pwrsw_enabled, 5071da177e4SLinus Torvalds .maxlen = sizeof (int), 5081da177e4SLinus Torvalds .mode = 0644, 5096d456111SEric W. Biederman .proc_handler = proc_dointvec, 5101da177e4SLinus Torvalds }, 5111da177e4SLinus Torvalds { 5121da177e4SLinus Torvalds .procname = "unaligned-trap", 5131da177e4SLinus Torvalds .data = &unaligned_enabled, 5141da177e4SLinus Torvalds .maxlen = sizeof (int), 5151da177e4SLinus Torvalds .mode = 0644, 5166d456111SEric W. Biederman .proc_handler = proc_dointvec, 5171da177e4SLinus Torvalds }, 5181da177e4SLinus Torvalds #endif 5191da177e4SLinus Torvalds { 5201da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5211da177e4SLinus Torvalds .data = &C_A_D, 5221da177e4SLinus Torvalds .maxlen = sizeof(int), 5231da177e4SLinus Torvalds .mode = 0644, 5246d456111SEric W. Biederman .proc_handler = proc_dointvec, 5251da177e4SLinus Torvalds }, 526606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 527b0fc494fSSteven Rostedt { 528b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 529b0fc494fSSteven Rostedt .data = &ftrace_enabled, 530b0fc494fSSteven Rostedt .maxlen = sizeof(int), 531b0fc494fSSteven Rostedt .mode = 0644, 5326d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 533b0fc494fSSteven Rostedt }, 534b0fc494fSSteven Rostedt #endif 535f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 536f38f1d2aSSteven Rostedt { 537f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 538f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 539f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 540f38f1d2aSSteven Rostedt .mode = 0644, 5416d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 542f38f1d2aSSteven Rostedt }, 543f38f1d2aSSteven Rostedt #endif 544944ac425SSteven Rostedt #ifdef CONFIG_TRACING 545944ac425SSteven Rostedt { 5463299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 547944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 548944ac425SSteven Rostedt .maxlen = sizeof(int), 549944ac425SSteven Rostedt .mode = 0644, 5506d456111SEric W. Biederman .proc_handler = proc_dointvec, 551944ac425SSteven Rostedt }, 552944ac425SSteven Rostedt #endif 553a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5541da177e4SLinus Torvalds { 5551da177e4SLinus Torvalds .procname = "modprobe", 5561da177e4SLinus Torvalds .data = &modprobe_path, 5571da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5581da177e4SLinus Torvalds .mode = 0644, 5596d456111SEric W. Biederman .proc_handler = proc_dostring, 5601da177e4SLinus Torvalds }, 5613d43321bSKees Cook { 5623d43321bSKees Cook .procname = "modules_disabled", 5633d43321bSKees Cook .data = &modules_disabled, 5643d43321bSKees Cook .maxlen = sizeof(int), 5653d43321bSKees Cook .mode = 0644, 5663d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5676d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5683d43321bSKees Cook .extra1 = &one, 5693d43321bSKees Cook .extra2 = &one, 5703d43321bSKees Cook }, 5711da177e4SLinus Torvalds #endif 57294f17cd7SIan Abbott #ifdef CONFIG_HOTPLUG 5731da177e4SLinus Torvalds { 5741da177e4SLinus Torvalds .procname = "hotplug", 575312c004dSKay Sievers .data = &uevent_helper, 576312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5771da177e4SLinus Torvalds .mode = 0644, 5786d456111SEric W. Biederman .proc_handler = proc_dostring, 5791da177e4SLinus Torvalds }, 5801da177e4SLinus Torvalds #endif 5811da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5821da177e4SLinus Torvalds { 5831da177e4SLinus Torvalds .procname = "sg-big-buff", 5841da177e4SLinus Torvalds .data = &sg_big_buff, 5851da177e4SLinus Torvalds .maxlen = sizeof (int), 5861da177e4SLinus Torvalds .mode = 0444, 5876d456111SEric W. Biederman .proc_handler = proc_dointvec, 5881da177e4SLinus Torvalds }, 5891da177e4SLinus Torvalds #endif 5901da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5911da177e4SLinus Torvalds { 5921da177e4SLinus Torvalds .procname = "acct", 5931da177e4SLinus Torvalds .data = &acct_parm, 5941da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5951da177e4SLinus Torvalds .mode = 0644, 5966d456111SEric W. Biederman .proc_handler = proc_dointvec, 5971da177e4SLinus Torvalds }, 5981da177e4SLinus Torvalds #endif 5991da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 6001da177e4SLinus Torvalds { 6011da177e4SLinus Torvalds .procname = "sysrq", 6025d6f647fSIngo Molnar .data = &__sysrq_enabled, 6031da177e4SLinus Torvalds .maxlen = sizeof (int), 6041da177e4SLinus Torvalds .mode = 0644, 60597f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 6061da177e4SLinus Torvalds }, 6071da177e4SLinus Torvalds #endif 608d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 6091da177e4SLinus Torvalds { 6101da177e4SLinus Torvalds .procname = "cad_pid", 6119ec52099SCedric Le Goater .data = NULL, 6121da177e4SLinus Torvalds .maxlen = sizeof (int), 6131da177e4SLinus Torvalds .mode = 0600, 6146d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 6151da177e4SLinus Torvalds }, 616d6f8ff73SRandy Dunlap #endif 6171da177e4SLinus Torvalds { 6181da177e4SLinus Torvalds .procname = "threads-max", 6191da177e4SLinus Torvalds .data = &max_threads, 6201da177e4SLinus Torvalds .maxlen = sizeof(int), 6211da177e4SLinus Torvalds .mode = 0644, 6226d456111SEric W. Biederman .proc_handler = proc_dointvec, 6231da177e4SLinus Torvalds }, 6241da177e4SLinus Torvalds { 6251da177e4SLinus Torvalds .procname = "random", 6261da177e4SLinus Torvalds .mode = 0555, 6271da177e4SLinus Torvalds .child = random_table, 6281da177e4SLinus Torvalds }, 6291da177e4SLinus Torvalds { 63017f60a7dSEric Paris .procname = "usermodehelper", 63117f60a7dSEric Paris .mode = 0555, 63217f60a7dSEric Paris .child = usermodehelper_table, 63317f60a7dSEric Paris }, 63417f60a7dSEric Paris { 6351da177e4SLinus Torvalds .procname = "overflowuid", 6361da177e4SLinus Torvalds .data = &overflowuid, 6371da177e4SLinus Torvalds .maxlen = sizeof(int), 6381da177e4SLinus Torvalds .mode = 0644, 6396d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6401da177e4SLinus Torvalds .extra1 = &minolduid, 6411da177e4SLinus Torvalds .extra2 = &maxolduid, 6421da177e4SLinus Torvalds }, 6431da177e4SLinus Torvalds { 6441da177e4SLinus Torvalds .procname = "overflowgid", 6451da177e4SLinus Torvalds .data = &overflowgid, 6461da177e4SLinus Torvalds .maxlen = sizeof(int), 6471da177e4SLinus Torvalds .mode = 0644, 6486d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6491da177e4SLinus Torvalds .extra1 = &minolduid, 6501da177e4SLinus Torvalds .extra2 = &maxolduid, 6511da177e4SLinus Torvalds }, 652347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6531da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6541da177e4SLinus Torvalds { 6551da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6561da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6571da177e4SLinus Torvalds .maxlen = sizeof(int), 6581da177e4SLinus Torvalds .mode = 0644, 6596d456111SEric W. Biederman .proc_handler = proc_dointvec, 6601da177e4SLinus Torvalds }, 6611da177e4SLinus Torvalds #endif 6621da177e4SLinus Torvalds { 6631da177e4SLinus Torvalds .procname = "userprocess_debug", 664ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 6651da177e4SLinus Torvalds .maxlen = sizeof(int), 6661da177e4SLinus Torvalds .mode = 0644, 6676d456111SEric W. Biederman .proc_handler = proc_dointvec, 6681da177e4SLinus Torvalds }, 6691da177e4SLinus Torvalds #endif 6701da177e4SLinus Torvalds { 6711da177e4SLinus Torvalds .procname = "pid_max", 6721da177e4SLinus Torvalds .data = &pid_max, 6731da177e4SLinus Torvalds .maxlen = sizeof (int), 6741da177e4SLinus Torvalds .mode = 0644, 6756d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6761da177e4SLinus Torvalds .extra1 = &pid_max_min, 6771da177e4SLinus Torvalds .extra2 = &pid_max_max, 6781da177e4SLinus Torvalds }, 6791da177e4SLinus Torvalds { 6801da177e4SLinus Torvalds .procname = "panic_on_oops", 6811da177e4SLinus Torvalds .data = &panic_on_oops, 6821da177e4SLinus Torvalds .maxlen = sizeof(int), 6831da177e4SLinus Torvalds .mode = 0644, 6846d456111SEric W. Biederman .proc_handler = proc_dointvec, 6851da177e4SLinus Torvalds }, 6867ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6877ef3d2fdSJoe Perches { 6887ef3d2fdSJoe Perches .procname = "printk", 6897ef3d2fdSJoe Perches .data = &console_loglevel, 6907ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6917ef3d2fdSJoe Perches .mode = 0644, 6926d456111SEric W. Biederman .proc_handler = proc_dointvec, 6937ef3d2fdSJoe Perches }, 6941da177e4SLinus Torvalds { 6951da177e4SLinus Torvalds .procname = "printk_ratelimit", 696717115e1SDave Young .data = &printk_ratelimit_state.interval, 6971da177e4SLinus Torvalds .maxlen = sizeof(int), 6981da177e4SLinus Torvalds .mode = 0644, 6996d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 7001da177e4SLinus Torvalds }, 7011da177e4SLinus Torvalds { 7021da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 703717115e1SDave Young .data = &printk_ratelimit_state.burst, 7041da177e4SLinus Torvalds .maxlen = sizeof(int), 7051da177e4SLinus Torvalds .mode = 0644, 7066d456111SEric W. Biederman .proc_handler = proc_dointvec, 7071da177e4SLinus Torvalds }, 708af91322eSDave Young { 709af91322eSDave Young .procname = "printk_delay", 710af91322eSDave Young .data = &printk_delay_msec, 711af91322eSDave Young .maxlen = sizeof(int), 712af91322eSDave Young .mode = 0644, 7136d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 714af91322eSDave Young .extra1 = &zero, 715af91322eSDave Young .extra2 = &ten_thousand, 716af91322eSDave Young }, 7171da177e4SLinus Torvalds { 718eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 719eaf06b24SDan Rosenberg .data = &dmesg_restrict, 720eaf06b24SDan Rosenberg .maxlen = sizeof(int), 721eaf06b24SDan Rosenberg .mode = 0644, 722eaf06b24SDan Rosenberg .proc_handler = proc_dointvec_minmax, 723eaf06b24SDan Rosenberg .extra1 = &zero, 724eaf06b24SDan Rosenberg .extra2 = &one, 725eaf06b24SDan Rosenberg }, 726455cd5abSDan Rosenberg { 727455cd5abSDan Rosenberg .procname = "kptr_restrict", 728455cd5abSDan Rosenberg .data = &kptr_restrict, 729455cd5abSDan Rosenberg .maxlen = sizeof(int), 730455cd5abSDan Rosenberg .mode = 0644, 731bfdc0b49SRichard Weinberger .proc_handler = proc_dmesg_restrict, 732455cd5abSDan Rosenberg .extra1 = &zero, 733455cd5abSDan Rosenberg .extra2 = &two, 734455cd5abSDan Rosenberg }, 735df6e61d4SJoe Perches #endif 736eaf06b24SDan Rosenberg { 7371da177e4SLinus Torvalds .procname = "ngroups_max", 7381da177e4SLinus Torvalds .data = &ngroups_max, 7391da177e4SLinus Torvalds .maxlen = sizeof (int), 7401da177e4SLinus Torvalds .mode = 0444, 7416d456111SEric W. Biederman .proc_handler = proc_dointvec, 7421da177e4SLinus Torvalds }, 74358687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 744504d7cf1SDon Zickus { 74558687acbSDon Zickus .procname = "watchdog", 74658687acbSDon Zickus .data = &watchdog_enabled, 747504d7cf1SDon Zickus .maxlen = sizeof (int), 748504d7cf1SDon Zickus .mode = 0644, 749586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 750586692a5SMandeep Singh Baines .extra1 = &zero, 751586692a5SMandeep Singh Baines .extra2 = &one, 75258687acbSDon Zickus }, 75358687acbSDon Zickus { 75458687acbSDon Zickus .procname = "watchdog_thresh", 755586692a5SMandeep Singh Baines .data = &watchdog_thresh, 75658687acbSDon Zickus .maxlen = sizeof(int), 75758687acbSDon Zickus .mode = 0644, 758586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 75958687acbSDon Zickus .extra1 = &neg_one, 76058687acbSDon Zickus .extra2 = &sixty, 761504d7cf1SDon Zickus }, 7622508ce18SDon Zickus { 7632508ce18SDon Zickus .procname = "softlockup_panic", 7642508ce18SDon Zickus .data = &softlockup_panic, 7652508ce18SDon Zickus .maxlen = sizeof(int), 7662508ce18SDon Zickus .mode = 0644, 7672508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 7682508ce18SDon Zickus .extra1 = &zero, 7692508ce18SDon Zickus .extra2 = &one, 7702508ce18SDon Zickus }, 7715dc30558SDon Zickus { 7725dc30558SDon Zickus .procname = "nmi_watchdog", 7735dc30558SDon Zickus .data = &watchdog_enabled, 7745dc30558SDon Zickus .maxlen = sizeof (int), 7755dc30558SDon Zickus .mode = 0644, 776586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 777586692a5SMandeep Singh Baines .extra1 = &zero, 778586692a5SMandeep Singh Baines .extra2 = &one, 7795dc30558SDon Zickus }, 7805dc30558SDon Zickus #endif 7815dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7825dc30558SDon Zickus { 7835dc30558SDon Zickus .procname = "unknown_nmi_panic", 7845dc30558SDon Zickus .data = &unknown_nmi_panic, 7855dc30558SDon Zickus .maxlen = sizeof (int), 7865dc30558SDon Zickus .mode = 0644, 7875dc30558SDon Zickus .proc_handler = proc_dointvec, 7885dc30558SDon Zickus }, 789504d7cf1SDon Zickus #endif 7901da177e4SLinus Torvalds #if defined(CONFIG_X86) 7911da177e4SLinus Torvalds { 7928da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7938da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7948da5addaSDon Zickus .maxlen = sizeof(int), 7958da5addaSDon Zickus .mode = 0644, 7966d456111SEric W. Biederman .proc_handler = proc_dointvec, 7978da5addaSDon Zickus }, 7988da5addaSDon Zickus { 7995211a242SKurt Garloff .procname = "panic_on_io_nmi", 8005211a242SKurt Garloff .data = &panic_on_io_nmi, 8015211a242SKurt Garloff .maxlen = sizeof(int), 8025211a242SKurt Garloff .mode = 0644, 8036d456111SEric W. Biederman .proc_handler = proc_dointvec, 8045211a242SKurt Garloff }, 8055211a242SKurt Garloff { 8061da177e4SLinus Torvalds .procname = "bootloader_type", 8071da177e4SLinus Torvalds .data = &bootloader_type, 8081da177e4SLinus Torvalds .maxlen = sizeof (int), 8091da177e4SLinus Torvalds .mode = 0444, 8106d456111SEric W. Biederman .proc_handler = proc_dointvec, 8111da177e4SLinus Torvalds }, 8120741f4d2SChuck Ebbert { 8135031296cSH. Peter Anvin .procname = "bootloader_version", 8145031296cSH. Peter Anvin .data = &bootloader_version, 8155031296cSH. Peter Anvin .maxlen = sizeof (int), 8165031296cSH. Peter Anvin .mode = 0444, 8176d456111SEric W. Biederman .proc_handler = proc_dointvec, 8185031296cSH. Peter Anvin }, 8195031296cSH. Peter Anvin { 8200741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 8210741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 8220741f4d2SChuck Ebbert .maxlen = sizeof(int), 8230741f4d2SChuck Ebbert .mode = 0644, 8246d456111SEric W. Biederman .proc_handler = proc_dointvec, 8250741f4d2SChuck Ebbert }, 8266e7c4025SIngo Molnar { 8276e7c4025SIngo Molnar .procname = "io_delay_type", 8286e7c4025SIngo Molnar .data = &io_delay_type, 8296e7c4025SIngo Molnar .maxlen = sizeof(int), 8306e7c4025SIngo Molnar .mode = 0644, 8316d456111SEric W. Biederman .proc_handler = proc_dointvec, 8326e7c4025SIngo Molnar }, 8331da177e4SLinus Torvalds #endif 8347a9166e3SLuke Yang #if defined(CONFIG_MMU) 8351da177e4SLinus Torvalds { 8361da177e4SLinus Torvalds .procname = "randomize_va_space", 8371da177e4SLinus Torvalds .data = &randomize_va_space, 8381da177e4SLinus Torvalds .maxlen = sizeof(int), 8391da177e4SLinus Torvalds .mode = 0644, 8406d456111SEric W. Biederman .proc_handler = proc_dointvec, 8411da177e4SLinus Torvalds }, 8427a9166e3SLuke Yang #endif 8430152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 844951f22d5SMartin Schwidefsky { 845951f22d5SMartin Schwidefsky .procname = "spin_retry", 846951f22d5SMartin Schwidefsky .data = &spin_retry, 847951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 848951f22d5SMartin Schwidefsky .mode = 0644, 8496d456111SEric W. Biederman .proc_handler = proc_dointvec, 850951f22d5SMartin Schwidefsky }, 851951f22d5SMartin Schwidefsky #endif 852673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 853c255d844SPavel Machek { 854c255d844SPavel Machek .procname = "acpi_video_flags", 85577afcf78SPavel Machek .data = &acpi_realmode_flags, 856c255d844SPavel Machek .maxlen = sizeof (unsigned long), 857c255d844SPavel Machek .mode = 0644, 8586d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 859c255d844SPavel Machek }, 860c255d844SPavel Machek #endif 861d2b176edSJes Sorensen #ifdef CONFIG_IA64 862d2b176edSJes Sorensen { 863d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 864d2b176edSJes Sorensen .data = &no_unaligned_warning, 865d2b176edSJes Sorensen .maxlen = sizeof (int), 866d2b176edSJes Sorensen .mode = 0644, 8676d456111SEric W. Biederman .proc_handler = proc_dointvec, 868d2b176edSJes Sorensen }, 86988fc241fSDoug Chapman { 87088fc241fSDoug Chapman .procname = "unaligned-dump-stack", 87188fc241fSDoug Chapman .data = &unaligned_dump_stack, 87288fc241fSDoug Chapman .maxlen = sizeof (int), 87388fc241fSDoug Chapman .mode = 0644, 8746d456111SEric W. Biederman .proc_handler = proc_dointvec, 87588fc241fSDoug Chapman }, 876d2b176edSJes Sorensen #endif 877e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 878e162b39aSMandeep Singh Baines { 879e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 880e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 881e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 882e162b39aSMandeep Singh Baines .mode = 0644, 8836d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 884e162b39aSMandeep Singh Baines .extra1 = &zero, 885e162b39aSMandeep Singh Baines .extra2 = &one, 886e162b39aSMandeep Singh Baines }, 88782a1fcb9SIngo Molnar { 88882a1fcb9SIngo Molnar .procname = "hung_task_check_count", 88982a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 89090739081SIngo Molnar .maxlen = sizeof(unsigned long), 89182a1fcb9SIngo Molnar .mode = 0644, 8926d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 89382a1fcb9SIngo Molnar }, 89482a1fcb9SIngo Molnar { 89582a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 89682a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 89790739081SIngo Molnar .maxlen = sizeof(unsigned long), 89882a1fcb9SIngo Molnar .mode = 0644, 8996d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 90082a1fcb9SIngo Molnar }, 90182a1fcb9SIngo Molnar { 90282a1fcb9SIngo Molnar .procname = "hung_task_warnings", 90382a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 90490739081SIngo Molnar .maxlen = sizeof(unsigned long), 90582a1fcb9SIngo Molnar .mode = 0644, 9066d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 90782a1fcb9SIngo Molnar }, 908c4f3b63fSRavikiran G Thirumalai #endif 909bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 910bebfa101SAndi Kleen { 911bebfa101SAndi Kleen .procname = "compat-log", 912bebfa101SAndi Kleen .data = &compat_log, 913bebfa101SAndi Kleen .maxlen = sizeof (int), 914bebfa101SAndi Kleen .mode = 0644, 9156d456111SEric W. Biederman .proc_handler = proc_dointvec, 916bebfa101SAndi Kleen }, 917bebfa101SAndi Kleen #endif 91823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 91923f78d4aSIngo Molnar { 92023f78d4aSIngo Molnar .procname = "max_lock_depth", 92123f78d4aSIngo Molnar .data = &max_lock_depth, 92223f78d4aSIngo Molnar .maxlen = sizeof(int), 92323f78d4aSIngo Molnar .mode = 0644, 9246d456111SEric W. Biederman .proc_handler = proc_dointvec, 92523f78d4aSIngo Molnar }, 92623f78d4aSIngo Molnar #endif 92710a0a8d4SJeremy Fitzhardinge { 92810a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 92910a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 93010a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 93110a0a8d4SJeremy Fitzhardinge .mode = 0644, 9326d456111SEric W. Biederman .proc_handler = proc_dostring, 93310a0a8d4SJeremy Fitzhardinge }, 9340b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9350b77f5bfSDavid Howells { 9360b77f5bfSDavid Howells .procname = "keys", 9370b77f5bfSDavid Howells .mode = 0555, 9380b77f5bfSDavid Howells .child = key_sysctls, 9390b77f5bfSDavid Howells }, 9400b77f5bfSDavid Howells #endif 94131a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 94231a72bceSPaul E. McKenney { 94331a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 94431a72bceSPaul E. McKenney .data = &rcutorture_runnable, 94531a72bceSPaul E. McKenney .maxlen = sizeof(int), 94631a72bceSPaul E. McKenney .mode = 0644, 9476d456111SEric W. Biederman .proc_handler = proc_dointvec, 94831a72bceSPaul E. McKenney }, 94931a72bceSPaul E. McKenney #endif 950cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 951aa4a2218SVince Weaver /* 952aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 953aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 954aa4a2218SVince Weaver * 955aa4a2218SVince Weaver * So it's an ABI, do not remove! 956aa4a2218SVince Weaver */ 9571ccd1549SPeter Zijlstra { 958cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 959cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 960cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9611ccd1549SPeter Zijlstra .mode = 0644, 9626d456111SEric W. Biederman .proc_handler = proc_dointvec, 9631ccd1549SPeter Zijlstra }, 964c5078f78SPeter Zijlstra { 965cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 966cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 967cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 968c5078f78SPeter Zijlstra .mode = 0644, 9696d456111SEric W. Biederman .proc_handler = proc_dointvec, 970c5078f78SPeter Zijlstra }, 971a78ac325SPeter Zijlstra { 972cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 973cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 974cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 975a78ac325SPeter Zijlstra .mode = 0644, 976163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 977a78ac325SPeter Zijlstra }, 9781ccd1549SPeter Zijlstra #endif 979dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 980dfec072eSVegard Nossum { 981dfec072eSVegard Nossum .procname = "kmemcheck", 982dfec072eSVegard Nossum .data = &kmemcheck_enabled, 983dfec072eSVegard Nossum .maxlen = sizeof(int), 984dfec072eSVegard Nossum .mode = 0644, 9856d456111SEric W. Biederman .proc_handler = proc_dointvec, 986dfec072eSVegard Nossum }, 987dfec072eSVegard Nossum #endif 988cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9895e605b64SJens Axboe { 9905e605b64SJens Axboe .procname = "blk_iopoll", 9915e605b64SJens Axboe .data = &blk_iopoll_enabled, 9925e605b64SJens Axboe .maxlen = sizeof(int), 9935e605b64SJens Axboe .mode = 0644, 9946d456111SEric W. Biederman .proc_handler = proc_dointvec, 9955e605b64SJens Axboe }, 996cb684b5bSJens Axboe #endif 9976fce56ecSEric W. Biederman { } 9981da177e4SLinus Torvalds }; 9991da177e4SLinus Torvalds 1000d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 10011da177e4SLinus Torvalds { 10021da177e4SLinus Torvalds .procname = "overcommit_memory", 10031da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 10041da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 10051da177e4SLinus Torvalds .mode = 0644, 1006cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1007cb16e95fSPetr Holasek .extra1 = &zero, 1008cb16e95fSPetr Holasek .extra2 = &two, 10091da177e4SLinus Torvalds }, 10101da177e4SLinus Torvalds { 1011fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1012fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1013fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1014fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1015cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1016cb16e95fSPetr Holasek .extra1 = &zero, 1017cb16e95fSPetr Holasek .extra2 = &two, 1018fadd8fbdSKAMEZAWA Hiroyuki }, 1019fadd8fbdSKAMEZAWA Hiroyuki { 1020fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1021fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1022fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1023fe071d7eSDavid Rientjes .mode = 0644, 10246d456111SEric W. Biederman .proc_handler = proc_dointvec, 1025fe071d7eSDavid Rientjes }, 1026fe071d7eSDavid Rientjes { 1027fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1028fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1029fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1030fef1bdd6SDavid Rientjes .mode = 0644, 10316d456111SEric W. Biederman .proc_handler = proc_dointvec, 1032fef1bdd6SDavid Rientjes }, 1033fef1bdd6SDavid Rientjes { 10341da177e4SLinus Torvalds .procname = "overcommit_ratio", 10351da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10361da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10371da177e4SLinus Torvalds .mode = 0644, 10386d456111SEric W. Biederman .proc_handler = proc_dointvec, 10391da177e4SLinus Torvalds }, 10401da177e4SLinus Torvalds { 10411da177e4SLinus Torvalds .procname = "page-cluster", 10421da177e4SLinus Torvalds .data = &page_cluster, 10431da177e4SLinus Torvalds .maxlen = sizeof(int), 10441da177e4SLinus Torvalds .mode = 0644, 1045cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1046cb16e95fSPetr Holasek .extra1 = &zero, 10471da177e4SLinus Torvalds }, 10481da177e4SLinus Torvalds { 10491da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10501da177e4SLinus Torvalds .data = &dirty_background_ratio, 10511da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10521da177e4SLinus Torvalds .mode = 0644, 10536d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 10541da177e4SLinus Torvalds .extra1 = &zero, 10551da177e4SLinus Torvalds .extra2 = &one_hundred, 10561da177e4SLinus Torvalds }, 10571da177e4SLinus Torvalds { 10582da02997SDavid Rientjes .procname = "dirty_background_bytes", 10592da02997SDavid Rientjes .data = &dirty_background_bytes, 10602da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10612da02997SDavid Rientjes .mode = 0644, 10626d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1063fc3501d4SSven Wegener .extra1 = &one_ul, 10642da02997SDavid Rientjes }, 10652da02997SDavid Rientjes { 10661da177e4SLinus Torvalds .procname = "dirty_ratio", 10671da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10681da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10691da177e4SLinus Torvalds .mode = 0644, 10706d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10711da177e4SLinus Torvalds .extra1 = &zero, 10721da177e4SLinus Torvalds .extra2 = &one_hundred, 10731da177e4SLinus Torvalds }, 10741da177e4SLinus Torvalds { 10752da02997SDavid Rientjes .procname = "dirty_bytes", 10762da02997SDavid Rientjes .data = &vm_dirty_bytes, 10772da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10782da02997SDavid Rientjes .mode = 0644, 10796d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10809e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10812da02997SDavid Rientjes }, 10822da02997SDavid Rientjes { 10831da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1084f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1085f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10861da177e4SLinus Torvalds .mode = 0644, 10876d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10881da177e4SLinus Torvalds }, 10891da177e4SLinus Torvalds { 10901da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1091f6ef9438SBart Samwel .data = &dirty_expire_interval, 1092f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10931da177e4SLinus Torvalds .mode = 0644, 1094cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1095cb16e95fSPetr Holasek .extra1 = &zero, 10961da177e4SLinus Torvalds }, 10971da177e4SLinus Torvalds { 10981da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10991da177e4SLinus Torvalds .data = &nr_pdflush_threads, 11001da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 11011da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 11026d456111SEric W. Biederman .proc_handler = proc_dointvec, 11031da177e4SLinus Torvalds }, 11041da177e4SLinus Torvalds { 11051da177e4SLinus Torvalds .procname = "swappiness", 11061da177e4SLinus Torvalds .data = &vm_swappiness, 11071da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 11081da177e4SLinus Torvalds .mode = 0644, 11096d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 11101da177e4SLinus Torvalds .extra1 = &zero, 11111da177e4SLinus Torvalds .extra2 = &one_hundred, 11121da177e4SLinus Torvalds }, 11131da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11141da177e4SLinus Torvalds { 11151da177e4SLinus Torvalds .procname = "nr_hugepages", 1116e5ff2159SAndi Kleen .data = NULL, 11171da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11181da177e4SLinus Torvalds .mode = 0644, 11196d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 11201da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11211da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11221da177e4SLinus Torvalds }, 112306808b08SLee Schermerhorn #ifdef CONFIG_NUMA 112406808b08SLee Schermerhorn { 112506808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 112606808b08SLee Schermerhorn .data = NULL, 112706808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 112806808b08SLee Schermerhorn .mode = 0644, 112906808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 113006808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 113106808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 113206808b08SLee Schermerhorn }, 113306808b08SLee Schermerhorn #endif 11341da177e4SLinus Torvalds { 11351da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11361da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11371da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11381da177e4SLinus Torvalds .mode = 0644, 11396d456111SEric W. Biederman .proc_handler = proc_dointvec, 11401da177e4SLinus Torvalds }, 1141396faf03SMel Gorman { 1142396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1143396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1144396faf03SMel Gorman .maxlen = sizeof(int), 1145396faf03SMel Gorman .mode = 0644, 11466d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1147396faf03SMel Gorman }, 114854f9f80dSAdam Litke { 1149d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1150e5ff2159SAndi Kleen .data = NULL, 1151e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1152d1c3fb1fSNishanth Aravamudan .mode = 0644, 11536d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1154e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1155e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1156d1c3fb1fSNishanth Aravamudan }, 11571da177e4SLinus Torvalds #endif 11581da177e4SLinus Torvalds { 11591da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11601da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11611da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11621da177e4SLinus Torvalds .mode = 0644, 11636d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11641da177e4SLinus Torvalds }, 11651da177e4SLinus Torvalds { 11669d0243bcSAndrew Morton .procname = "drop_caches", 11679d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11689d0243bcSAndrew Morton .maxlen = sizeof(int), 11699d0243bcSAndrew Morton .mode = 0644, 11709d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 1171cb16e95fSPetr Holasek .extra1 = &one, 1172cb16e95fSPetr Holasek .extra2 = &three, 11739d0243bcSAndrew Morton }, 117476ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 117576ab0f53SMel Gorman { 117676ab0f53SMel Gorman .procname = "compact_memory", 117776ab0f53SMel Gorman .data = &sysctl_compact_memory, 117876ab0f53SMel Gorman .maxlen = sizeof(int), 117976ab0f53SMel Gorman .mode = 0200, 118076ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 118176ab0f53SMel Gorman }, 11825e771905SMel Gorman { 11835e771905SMel Gorman .procname = "extfrag_threshold", 11845e771905SMel Gorman .data = &sysctl_extfrag_threshold, 11855e771905SMel Gorman .maxlen = sizeof(int), 11865e771905SMel Gorman .mode = 0644, 11875e771905SMel Gorman .proc_handler = sysctl_extfrag_handler, 11885e771905SMel Gorman .extra1 = &min_extfrag_threshold, 11895e771905SMel Gorman .extra2 = &max_extfrag_threshold, 11905e771905SMel Gorman }, 11915e771905SMel Gorman 119276ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 11939d0243bcSAndrew Morton { 11941da177e4SLinus Torvalds .procname = "min_free_kbytes", 11951da177e4SLinus Torvalds .data = &min_free_kbytes, 11961da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11971da177e4SLinus Torvalds .mode = 0644, 11986d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 11991da177e4SLinus Torvalds .extra1 = &zero, 12001da177e4SLinus Torvalds }, 12018ad4b1fbSRohit Seth { 12028ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 12038ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 12048ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 12058ad4b1fbSRohit Seth .mode = 0644, 12066d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 12078ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 12088ad4b1fbSRohit Seth }, 12091da177e4SLinus Torvalds #ifdef CONFIG_MMU 12101da177e4SLinus Torvalds { 12111da177e4SLinus Torvalds .procname = "max_map_count", 12121da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12131da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12141da177e4SLinus Torvalds .mode = 0644, 12153e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 121670da2340SAmerigo Wang .extra1 = &zero, 12171da177e4SLinus Torvalds }, 1218dd8632a1SPaul Mundt #else 1219dd8632a1SPaul Mundt { 1220dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1221dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1222dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1223dd8632a1SPaul Mundt .mode = 0644, 12246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1225dd8632a1SPaul Mundt .extra1 = &zero, 1226dd8632a1SPaul Mundt }, 12271da177e4SLinus Torvalds #endif 12281da177e4SLinus Torvalds { 12291da177e4SLinus Torvalds .procname = "laptop_mode", 12301da177e4SLinus Torvalds .data = &laptop_mode, 12311da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12321da177e4SLinus Torvalds .mode = 0644, 12336d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 12341da177e4SLinus Torvalds }, 12351da177e4SLinus Torvalds { 12361da177e4SLinus Torvalds .procname = "block_dump", 12371da177e4SLinus Torvalds .data = &block_dump, 12381da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12391da177e4SLinus Torvalds .mode = 0644, 12406d456111SEric W. Biederman .proc_handler = proc_dointvec, 12411da177e4SLinus Torvalds .extra1 = &zero, 12421da177e4SLinus Torvalds }, 12431da177e4SLinus Torvalds { 12441da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12451da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12461da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12471da177e4SLinus Torvalds .mode = 0644, 12486d456111SEric W. Biederman .proc_handler = proc_dointvec, 12491da177e4SLinus Torvalds .extra1 = &zero, 12501da177e4SLinus Torvalds }, 12511da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12521da177e4SLinus Torvalds { 12531da177e4SLinus Torvalds .procname = "legacy_va_layout", 12541da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12551da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12561da177e4SLinus Torvalds .mode = 0644, 12576d456111SEric W. Biederman .proc_handler = proc_dointvec, 12581da177e4SLinus Torvalds .extra1 = &zero, 12591da177e4SLinus Torvalds }, 12601da177e4SLinus Torvalds #endif 12611743660bSChristoph Lameter #ifdef CONFIG_NUMA 12621743660bSChristoph Lameter { 12631743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12641743660bSChristoph Lameter .data = &zone_reclaim_mode, 12651743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12661743660bSChristoph Lameter .mode = 0644, 12676d456111SEric W. Biederman .proc_handler = proc_dointvec, 1268c84db23cSChristoph Lameter .extra1 = &zero, 12691743660bSChristoph Lameter }, 12709614634fSChristoph Lameter { 12719614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12729614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12739614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12749614634fSChristoph Lameter .mode = 0644, 12756d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 12769614634fSChristoph Lameter .extra1 = &zero, 12779614634fSChristoph Lameter .extra2 = &one_hundred, 12789614634fSChristoph Lameter }, 12790ff38490SChristoph Lameter { 12800ff38490SChristoph Lameter .procname = "min_slab_ratio", 12810ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12820ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12830ff38490SChristoph Lameter .mode = 0644, 12846d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12850ff38490SChristoph Lameter .extra1 = &zero, 12860ff38490SChristoph Lameter .extra2 = &one_hundred, 12870ff38490SChristoph Lameter }, 12881743660bSChristoph Lameter #endif 128977461ab3SChristoph Lameter #ifdef CONFIG_SMP 129077461ab3SChristoph Lameter { 129177461ab3SChristoph Lameter .procname = "stat_interval", 129277461ab3SChristoph Lameter .data = &sysctl_stat_interval, 129377461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 129477461ab3SChristoph Lameter .mode = 0644, 12956d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 129677461ab3SChristoph Lameter }, 129777461ab3SChristoph Lameter #endif 12986e141546SDavid Howells #ifdef CONFIG_MMU 1299ed032189SEric Paris { 1300ed032189SEric Paris .procname = "mmap_min_addr", 1301788084abSEric Paris .data = &dac_mmap_min_addr, 1302ed032189SEric Paris .maxlen = sizeof(unsigned long), 1303ed032189SEric Paris .mode = 0644, 13046d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1305ed032189SEric Paris }, 13066e141546SDavid Howells #endif 1307f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1308f0c0b2b8SKAMEZAWA Hiroyuki { 1309f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1310f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1311f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1312f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 13136d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1314f0c0b2b8SKAMEZAWA Hiroyuki }, 1315f0c0b2b8SKAMEZAWA Hiroyuki #endif 13162b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13175c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1318e6e5494cSIngo Molnar { 1319e6e5494cSIngo Molnar .procname = "vdso_enabled", 1320e6e5494cSIngo Molnar .data = &vdso_enabled, 1321e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1322e6e5494cSIngo Molnar .mode = 0644, 13236d456111SEric W. Biederman .proc_handler = proc_dointvec, 1324e6e5494cSIngo Molnar .extra1 = &zero, 1325e6e5494cSIngo Molnar }, 1326e6e5494cSIngo Molnar #endif 1327195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1328195cf453SBron Gondwana { 1329195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1330195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1331195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1332195cf453SBron Gondwana .mode = 0644, 13336d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1334195cf453SBron Gondwana .extra1 = &zero, 1335195cf453SBron Gondwana .extra2 = &one, 1336195cf453SBron Gondwana }, 1337195cf453SBron Gondwana #endif 13384be6f6bbSPeter Zijlstra { 13394be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13404be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13414be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13424be6f6bbSPeter Zijlstra .mode = 0644, 13436d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 13444be6f6bbSPeter Zijlstra }, 13456a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 13466a46079cSAndi Kleen { 13476a46079cSAndi Kleen .procname = "memory_failure_early_kill", 13486a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 13496a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 13506a46079cSAndi Kleen .mode = 0644, 13516d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13526a46079cSAndi Kleen .extra1 = &zero, 13536a46079cSAndi Kleen .extra2 = &one, 13546a46079cSAndi Kleen }, 13556a46079cSAndi Kleen { 13566a46079cSAndi Kleen .procname = "memory_failure_recovery", 13576a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 13586a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 13596a46079cSAndi Kleen .mode = 0644, 13606d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13616a46079cSAndi Kleen .extra1 = &zero, 13626a46079cSAndi Kleen .extra2 = &one, 13636a46079cSAndi Kleen }, 13646a46079cSAndi Kleen #endif 13656fce56ecSEric W. Biederman { } 13661da177e4SLinus Torvalds }; 13671da177e4SLinus Torvalds 13682abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1369d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13706fce56ecSEric W. Biederman { } 13712abc26fcSEric W. Biederman }; 13722abc26fcSEric W. Biederman #endif 13732abc26fcSEric W. Biederman 1374d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13751da177e4SLinus Torvalds { 13761da177e4SLinus Torvalds .procname = "inode-nr", 13771da177e4SLinus Torvalds .data = &inodes_stat, 13781da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13791da177e4SLinus Torvalds .mode = 0444, 1380cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13811da177e4SLinus Torvalds }, 13821da177e4SLinus Torvalds { 13831da177e4SLinus Torvalds .procname = "inode-state", 13841da177e4SLinus Torvalds .data = &inodes_stat, 13851da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13861da177e4SLinus Torvalds .mode = 0444, 1387cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13881da177e4SLinus Torvalds }, 13891da177e4SLinus Torvalds { 13901da177e4SLinus Torvalds .procname = "file-nr", 13911da177e4SLinus Torvalds .data = &files_stat, 1392518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 13931da177e4SLinus Torvalds .mode = 0444, 13946d456111SEric W. Biederman .proc_handler = proc_nr_files, 13951da177e4SLinus Torvalds }, 13961da177e4SLinus Torvalds { 13971da177e4SLinus Torvalds .procname = "file-max", 13981da177e4SLinus Torvalds .data = &files_stat.max_files, 1399518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 14001da177e4SLinus Torvalds .mode = 0644, 1401518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 14021da177e4SLinus Torvalds }, 14031da177e4SLinus Torvalds { 14049cfe015aSEric Dumazet .procname = "nr_open", 14059cfe015aSEric Dumazet .data = &sysctl_nr_open, 14069cfe015aSEric Dumazet .maxlen = sizeof(int), 14079cfe015aSEric Dumazet .mode = 0644, 14086d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1409eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1410eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14119cfe015aSEric Dumazet }, 14129cfe015aSEric Dumazet { 14131da177e4SLinus Torvalds .procname = "dentry-state", 14141da177e4SLinus Torvalds .data = &dentry_stat, 14151da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14161da177e4SLinus Torvalds .mode = 0444, 1417312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 14181da177e4SLinus Torvalds }, 14191da177e4SLinus Torvalds { 14201da177e4SLinus Torvalds .procname = "overflowuid", 14211da177e4SLinus Torvalds .data = &fs_overflowuid, 14221da177e4SLinus Torvalds .maxlen = sizeof(int), 14231da177e4SLinus Torvalds .mode = 0644, 14246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14251da177e4SLinus Torvalds .extra1 = &minolduid, 14261da177e4SLinus Torvalds .extra2 = &maxolduid, 14271da177e4SLinus Torvalds }, 14281da177e4SLinus Torvalds { 14291da177e4SLinus Torvalds .procname = "overflowgid", 14301da177e4SLinus Torvalds .data = &fs_overflowgid, 14311da177e4SLinus Torvalds .maxlen = sizeof(int), 14321da177e4SLinus Torvalds .mode = 0644, 14336d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14341da177e4SLinus Torvalds .extra1 = &minolduid, 14351da177e4SLinus Torvalds .extra2 = &maxolduid, 14361da177e4SLinus Torvalds }, 1437bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14381da177e4SLinus Torvalds { 14391da177e4SLinus Torvalds .procname = "leases-enable", 14401da177e4SLinus Torvalds .data = &leases_enable, 14411da177e4SLinus Torvalds .maxlen = sizeof(int), 14421da177e4SLinus Torvalds .mode = 0644, 14436d456111SEric W. Biederman .proc_handler = proc_dointvec, 14441da177e4SLinus Torvalds }, 1445bfcd17a6SThomas Petazzoni #endif 14461da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14471da177e4SLinus Torvalds { 14481da177e4SLinus Torvalds .procname = "dir-notify-enable", 14491da177e4SLinus Torvalds .data = &dir_notify_enable, 14501da177e4SLinus Torvalds .maxlen = sizeof(int), 14511da177e4SLinus Torvalds .mode = 0644, 14526d456111SEric W. Biederman .proc_handler = proc_dointvec, 14531da177e4SLinus Torvalds }, 14541da177e4SLinus Torvalds #endif 14551da177e4SLinus Torvalds #ifdef CONFIG_MMU 1456bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14571da177e4SLinus Torvalds { 14581da177e4SLinus Torvalds .procname = "lease-break-time", 14591da177e4SLinus Torvalds .data = &lease_break_time, 14601da177e4SLinus Torvalds .maxlen = sizeof(int), 14611da177e4SLinus Torvalds .mode = 0644, 14626d456111SEric W. Biederman .proc_handler = proc_dointvec, 14631da177e4SLinus Torvalds }, 1464bfcd17a6SThomas Petazzoni #endif 1465ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14661da177e4SLinus Torvalds { 14671da177e4SLinus Torvalds .procname = "aio-nr", 14681da177e4SLinus Torvalds .data = &aio_nr, 14691da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14701da177e4SLinus Torvalds .mode = 0444, 14716d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14721da177e4SLinus Torvalds }, 14731da177e4SLinus Torvalds { 14741da177e4SLinus Torvalds .procname = "aio-max-nr", 14751da177e4SLinus Torvalds .data = &aio_max_nr, 14761da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14771da177e4SLinus Torvalds .mode = 0644, 14786d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14791da177e4SLinus Torvalds }, 1480ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14812d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14820399cb08SRobert Love { 14830399cb08SRobert Love .procname = "inotify", 14840399cb08SRobert Love .mode = 0555, 14850399cb08SRobert Love .child = inotify_table, 14860399cb08SRobert Love }, 14870399cb08SRobert Love #endif 14887ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14897ef9964eSDavide Libenzi { 14907ef9964eSDavide Libenzi .procname = "epoll", 14917ef9964eSDavide Libenzi .mode = 0555, 14927ef9964eSDavide Libenzi .child = epoll_table, 14937ef9964eSDavide Libenzi }, 14947ef9964eSDavide Libenzi #endif 14951da177e4SLinus Torvalds #endif 1496d6e71144SAlan Cox { 1497d6e71144SAlan Cox .procname = "suid_dumpable", 1498d6e71144SAlan Cox .data = &suid_dumpable, 1499d6e71144SAlan Cox .maxlen = sizeof(int), 1500d6e71144SAlan Cox .mode = 0644, 15016d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 15028e654fbaSMatthew Wilcox .extra1 = &zero, 15038e654fbaSMatthew Wilcox .extra2 = &two, 1504d6e71144SAlan Cox }, 15052abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 15062abc26fcSEric W. Biederman { 15072abc26fcSEric W. Biederman .procname = "binfmt_misc", 15082abc26fcSEric W. Biederman .mode = 0555, 15092abc26fcSEric W. Biederman .child = binfmt_misc_table, 15102abc26fcSEric W. Biederman }, 15112abc26fcSEric W. Biederman #endif 1512b492e95bSJens Axboe { 1513ff9da691SJens Axboe .procname = "pipe-max-size", 1514ff9da691SJens Axboe .data = &pipe_max_size, 1515b492e95bSJens Axboe .maxlen = sizeof(int), 1516b492e95bSJens Axboe .mode = 0644, 1517ff9da691SJens Axboe .proc_handler = &pipe_proc_fn, 1518ff9da691SJens Axboe .extra1 = &pipe_min_size, 1519b492e95bSJens Axboe }, 15206fce56ecSEric W. Biederman { } 15211da177e4SLinus Torvalds }; 15221da177e4SLinus Torvalds 1523d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1524ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ 1525571d76acSChris Metcalf defined(CONFIG_S390) || defined(CONFIG_TILE) 1526abd4f750SMasoud Asgharifard Sharbiani { 1527abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1528abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1529abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1530abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1531abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1532abd4f750SMasoud Asgharifard Sharbiani }, 1533abd4f750SMasoud Asgharifard Sharbiani #endif 1534b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1535b2be84dfSMasami Hiramatsu { 1536b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1537b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1538b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1539b2be84dfSMasami Hiramatsu .mode = 0644, 1540b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1541b2be84dfSMasami Hiramatsu .extra1 = &zero, 1542b2be84dfSMasami Hiramatsu .extra2 = &one, 1543b2be84dfSMasami Hiramatsu }, 1544b2be84dfSMasami Hiramatsu #endif 15456fce56ecSEric W. Biederman { } 15461da177e4SLinus Torvalds }; 15471da177e4SLinus Torvalds 1548d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15496fce56ecSEric W. Biederman { } 15501da177e4SLinus Torvalds }; 15511da177e4SLinus Torvalds 1552330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1553330d57fbSAl Viro 1554330d57fbSAl Viro /* called under sysctl_lock */ 1555330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1556330d57fbSAl Viro { 1557330d57fbSAl Viro if (unlikely(p->unregistering)) 1558330d57fbSAl Viro return 0; 1559330d57fbSAl Viro p->used++; 1560330d57fbSAl Viro return 1; 1561330d57fbSAl Viro } 1562330d57fbSAl Viro 1563330d57fbSAl Viro /* called under sysctl_lock */ 1564330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1565330d57fbSAl Viro { 1566330d57fbSAl Viro if (!--p->used) 1567330d57fbSAl Viro if (unlikely(p->unregistering)) 1568330d57fbSAl Viro complete(p->unregistering); 1569330d57fbSAl Viro } 1570330d57fbSAl Viro 1571330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1572330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1573330d57fbSAl Viro { 1574330d57fbSAl Viro /* 1575330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1576330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1577330d57fbSAl Viro */ 1578330d57fbSAl Viro if (unlikely(p->used)) { 1579330d57fbSAl Viro struct completion wait; 1580330d57fbSAl Viro init_completion(&wait); 1581330d57fbSAl Viro p->unregistering = &wait; 1582330d57fbSAl Viro spin_unlock(&sysctl_lock); 1583330d57fbSAl Viro wait_for_completion(&wait); 1584330d57fbSAl Viro spin_lock(&sysctl_lock); 1585f7e6ced4SAl Viro } else { 1586f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1587f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1588330d57fbSAl Viro } 1589330d57fbSAl Viro /* 1590330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1591330d57fbSAl Viro * list in do_sysctl() relies on that. 1592330d57fbSAl Viro */ 1593330d57fbSAl Viro list_del_init(&p->ctl_entry); 1594330d57fbSAl Viro } 1595330d57fbSAl Viro 1596f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1597f7e6ced4SAl Viro { 1598f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1599f7e6ced4SAl Viro head->count++; 1600f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1601f7e6ced4SAl Viro } 1602f7e6ced4SAl Viro 1603f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1604f7e6ced4SAl Viro { 1605f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1606f7e6ced4SAl Viro if (!--head->count) 1607a95cded3SPaul E. McKenney kfree_rcu(head, rcu); 1608f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1609f7e6ced4SAl Viro } 1610f7e6ced4SAl Viro 1611f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1612f7e6ced4SAl Viro { 1613f7e6ced4SAl Viro if (!head) 1614f7e6ced4SAl Viro BUG(); 1615f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1616f7e6ced4SAl Viro if (!use_table(head)) 1617f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1618f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1619f7e6ced4SAl Viro return head; 1620f7e6ced4SAl Viro } 1621f7e6ced4SAl Viro 1622805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1623805b5d5eSEric W. Biederman { 1624805b5d5eSEric W. Biederman if (!head) 1625805b5d5eSEric W. Biederman return; 1626805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1627805b5d5eSEric W. Biederman unuse_table(head); 1628805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1629805b5d5eSEric W. Biederman } 1630805b5d5eSEric W. Biederman 163173455092SAl Viro static struct ctl_table_set * 163273455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 163373455092SAl Viro { 163473455092SAl Viro struct ctl_table_set *set = &root->default_set; 163573455092SAl Viro if (root->lookup) 163673455092SAl Viro set = root->lookup(root, namespaces); 163773455092SAl Viro return set; 163873455092SAl Viro } 163973455092SAl Viro 1640e51b6ba0SEric W. Biederman static struct list_head * 1641e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1642805b5d5eSEric W. Biederman { 164373455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 164473455092SAl Viro return &set->list; 1645e51b6ba0SEric W. Biederman } 1646e51b6ba0SEric W. Biederman 1647e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1648e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1649e51b6ba0SEric W. Biederman { 1650e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1651e51b6ba0SEric W. Biederman struct list_head *header_list; 1652805b5d5eSEric W. Biederman struct ctl_table_header *head; 1653805b5d5eSEric W. Biederman struct list_head *tmp; 1654e51b6ba0SEric W. Biederman 1655805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1656805b5d5eSEric W. Biederman if (prev) { 1657e51b6ba0SEric W. Biederman head = prev; 1658805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1659805b5d5eSEric W. Biederman unuse_table(prev); 1660805b5d5eSEric W. Biederman goto next; 1661805b5d5eSEric W. Biederman } 1662805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1663805b5d5eSEric W. Biederman for (;;) { 1664805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1665805b5d5eSEric W. Biederman 1666805b5d5eSEric W. Biederman if (!use_table(head)) 1667805b5d5eSEric W. Biederman goto next; 1668805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1669805b5d5eSEric W. Biederman return head; 1670805b5d5eSEric W. Biederman next: 1671e51b6ba0SEric W. Biederman root = head->root; 1672805b5d5eSEric W. Biederman tmp = tmp->next; 1673e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1674e51b6ba0SEric W. Biederman if (tmp != header_list) 1675e51b6ba0SEric W. Biederman continue; 1676e51b6ba0SEric W. Biederman 1677e51b6ba0SEric W. Biederman do { 1678e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1679e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1680e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1681e51b6ba0SEric W. Biederman goto out; 1682e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1683e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1684e51b6ba0SEric W. Biederman tmp = header_list->next; 1685805b5d5eSEric W. Biederman } 1686e51b6ba0SEric W. Biederman out: 1687805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1688805b5d5eSEric W. Biederman return NULL; 1689805b5d5eSEric W. Biederman } 1690805b5d5eSEric W. Biederman 1691e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1692e51b6ba0SEric W. Biederman { 1693e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1694e51b6ba0SEric W. Biederman } 1695e51b6ba0SEric W. Biederman 1696e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1697e51b6ba0SEric W. Biederman { 1698e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1699e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1700e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1701e51b6ba0SEric W. Biederman } 1702e51b6ba0SEric W. Biederman 17031da177e4SLinus Torvalds /* 17041ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 17051da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 17061da177e4SLinus Torvalds */ 17071da177e4SLinus Torvalds 17081da177e4SLinus Torvalds static int test_perm(int mode, int op) 17091da177e4SLinus Torvalds { 171076aac0e9SDavid Howells if (!current_euid()) 17111da177e4SLinus Torvalds mode >>= 6; 17121da177e4SLinus Torvalds else if (in_egroup_p(0)) 17131da177e4SLinus Torvalds mode >>= 3; 1714e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 17151da177e4SLinus Torvalds return 0; 17161da177e4SLinus Torvalds return -EACCES; 17171da177e4SLinus Torvalds } 17181da177e4SLinus Torvalds 1719d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 17201da177e4SLinus Torvalds { 1721d7321cd6SPavel Emelyanov int mode; 1722d7321cd6SPavel Emelyanov 1723d7321cd6SPavel Emelyanov if (root->permissions) 1724d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1725d7321cd6SPavel Emelyanov else 1726d7321cd6SPavel Emelyanov mode = table->mode; 1727d7321cd6SPavel Emelyanov 1728d7321cd6SPavel Emelyanov return test_perm(mode, op); 17291da177e4SLinus Torvalds } 17301da177e4SLinus Torvalds 1731d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1732d912b0ccSEric W. Biederman { 17332315ffa0SEric W. Biederman for (; table->procname; table++) { 1734d912b0ccSEric W. Biederman table->parent = parent; 1735d912b0ccSEric W. Biederman if (table->child) 1736d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1737d912b0ccSEric W. Biederman } 1738d912b0ccSEric W. Biederman } 1739d912b0ccSEric W. Biederman 1740d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1741d912b0ccSEric W. Biederman { 1742d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 174388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1744b3bd3de6SAndi Kleen sysctl_check_table(current->nsproxy, root_table); 174588f458e4SHolger Schurig #endif 1746d912b0ccSEric W. Biederman return 0; 1747d912b0ccSEric W. Biederman } 1748d912b0ccSEric W. Biederman 1749d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1750d912b0ccSEric W. Biederman 1751bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1752bfbcf034SAl Viro struct ctl_table *table) 1753ae7edeccSAl Viro { 1754ae7edeccSAl Viro struct ctl_table *p; 1755ae7edeccSAl Viro const char *s = branch->procname; 1756ae7edeccSAl Viro 1757ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1758ae7edeccSAl Viro if (!s || !branch->child) 1759bfbcf034SAl Viro return NULL; 1760ae7edeccSAl Viro 1761ae7edeccSAl Viro /* ... and nothing else */ 17622315ffa0SEric W. Biederman if (branch[1].procname) 1763bfbcf034SAl Viro return NULL; 1764ae7edeccSAl Viro 1765ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 17662315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1767ae7edeccSAl Viro if (!p->child) 1768ae7edeccSAl Viro continue; 1769ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1770bfbcf034SAl Viro return p; 1771ae7edeccSAl Viro } 1772bfbcf034SAl Viro return NULL; 1773ae7edeccSAl Viro } 1774ae7edeccSAl Viro 1775ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1776ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1777ae7edeccSAl Viro { 1778ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1779bfbcf034SAl Viro struct ctl_table *next; 1780ae7edeccSAl Viro int is_better = 0; 1781ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1782ae7edeccSAl Viro 1783bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1784ae7edeccSAl Viro if (by == q->attached_by) 1785ae7edeccSAl Viro is_better = 1; 1786ae7edeccSAl Viro if (to == p->attached_by) 1787ae7edeccSAl Viro not_in_parent = 1; 1788ae7edeccSAl Viro by = by->child; 1789bfbcf034SAl Viro to = next->child; 1790ae7edeccSAl Viro } 1791ae7edeccSAl Viro 1792ae7edeccSAl Viro if (is_better && not_in_parent) { 1793ae7edeccSAl Viro q->attached_by = by; 1794ae7edeccSAl Viro q->attached_to = to; 1795ae7edeccSAl Viro q->parent = p; 1796ae7edeccSAl Viro } 1797ae7edeccSAl Viro } 1798ae7edeccSAl Viro 17991da177e4SLinus Torvalds /** 1800e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1801e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1802e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 180329e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 18041da177e4SLinus Torvalds * @table: the top-level table structure 18051da177e4SLinus Torvalds * 18061da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 180729e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 18081da177e4SLinus Torvalds * 1809d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 18101da177e4SLinus Torvalds * 18111da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 18121da177e4SLinus Torvalds * enter a sysctl file 18131da177e4SLinus Torvalds * 18141da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 18151da177e4SLinus Torvalds * 18161da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 18171da177e4SLinus Torvalds * 18181da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 18191da177e4SLinus Torvalds * 18201da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 18211da177e4SLinus Torvalds * %NULL. 18221da177e4SLinus Torvalds * 18231da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 18241da177e4SLinus Torvalds * 18251da177e4SLinus Torvalds * de - for internal use by the sysctl routines 18261da177e4SLinus Torvalds * 18271da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 18281da177e4SLinus Torvalds * 18291da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 18301da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 18311da177e4SLinus Torvalds * 18321da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 18331da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 18341da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 18351da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 18361da177e4SLinus Torvalds * 18371da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 18381da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 18391da177e4SLinus Torvalds * directory handler). Several default handlers are available to 18401da177e4SLinus Torvalds * cover common cases - 18411da177e4SLinus Torvalds * 18421da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 18431da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 18441da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 18451da177e4SLinus Torvalds * 18461da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 18471da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 18481da177e4SLinus Torvalds * 18491da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 18501da177e4SLinus Torvalds * to the table header on success. 18511da177e4SLinus Torvalds */ 1852e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1853e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1854e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1855e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 18561da177e4SLinus Torvalds { 185729e796fdSEric W. Biederman struct ctl_table_header *header; 185829e796fdSEric W. Biederman struct ctl_table *new, **prevp; 185929e796fdSEric W. Biederman unsigned int n, npath; 1860ae7edeccSAl Viro struct ctl_table_set *set; 186129e796fdSEric W. Biederman 186229e796fdSEric W. Biederman /* Count the path components */ 18632315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 186429e796fdSEric W. Biederman ; 186529e796fdSEric W. Biederman 186629e796fdSEric W. Biederman /* 186729e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 186829e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 18692315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 187029e796fdSEric W. Biederman * 187129e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 187229e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 187329e796fdSEric W. Biederman */ 187429e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 187529e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 187629e796fdSEric W. Biederman if (!header) 18771da177e4SLinus Torvalds return NULL; 187829e796fdSEric W. Biederman 187929e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 188029e796fdSEric W. Biederman 188129e796fdSEric W. Biederman /* Now connect the dots */ 188229e796fdSEric W. Biederman prevp = &header->ctl_table; 188329e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 188429e796fdSEric W. Biederman /* Copy the procname */ 188529e796fdSEric W. Biederman new->procname = path->procname; 188629e796fdSEric W. Biederman new->mode = 0555; 188729e796fdSEric W. Biederman 188829e796fdSEric W. Biederman *prevp = new; 188929e796fdSEric W. Biederman prevp = &new->child; 189029e796fdSEric W. Biederman 189129e796fdSEric W. Biederman new += 2; 189229e796fdSEric W. Biederman } 189329e796fdSEric W. Biederman *prevp = table; 189423eb06deSEric W. Biederman header->ctl_table_arg = table; 189529e796fdSEric W. Biederman 189629e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 189729e796fdSEric W. Biederman header->used = 0; 189829e796fdSEric W. Biederman header->unregistering = NULL; 1899e51b6ba0SEric W. Biederman header->root = root; 190029e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1901f7e6ced4SAl Viro header->count = 1; 190288f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1903e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 190429e796fdSEric W. Biederman kfree(header); 1905fc6cd25bSEric W. Biederman return NULL; 1906fc6cd25bSEric W. Biederman } 190788f458e4SHolger Schurig #endif 1908330d57fbSAl Viro spin_lock(&sysctl_lock); 190973455092SAl Viro header->set = lookup_header_set(root, namespaces); 1910ae7edeccSAl Viro header->attached_by = header->ctl_table; 1911ae7edeccSAl Viro header->attached_to = root_table; 1912ae7edeccSAl Viro header->parent = &root_table_header; 1913ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1914ae7edeccSAl Viro struct ctl_table_header *p; 1915ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1916ae7edeccSAl Viro if (p->unregistering) 1917ae7edeccSAl Viro continue; 1918ae7edeccSAl Viro try_attach(p, header); 1919ae7edeccSAl Viro } 1920ae7edeccSAl Viro } 1921ae7edeccSAl Viro header->parent->count++; 192273455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1923330d57fbSAl Viro spin_unlock(&sysctl_lock); 192429e796fdSEric W. Biederman 192529e796fdSEric W. Biederman return header; 192629e796fdSEric W. Biederman } 192729e796fdSEric W. Biederman 192829e796fdSEric W. Biederman /** 1929e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1930e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1931e51b6ba0SEric W. Biederman * @table: the top-level table structure 1932e51b6ba0SEric W. Biederman * 1933e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1934e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1935e51b6ba0SEric W. Biederman * 1936e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1937e51b6ba0SEric W. Biederman */ 1938e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1939e51b6ba0SEric W. Biederman struct ctl_table *table) 1940e51b6ba0SEric W. Biederman { 1941e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1942e51b6ba0SEric W. Biederman path, table); 1943e51b6ba0SEric W. Biederman } 1944e51b6ba0SEric W. Biederman 1945e51b6ba0SEric W. Biederman /** 194629e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 194729e796fdSEric W. Biederman * @table: the top-level table structure 194829e796fdSEric W. Biederman * 194929e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 195029e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 195129e796fdSEric W. Biederman * 195229e796fdSEric W. Biederman * See register_sysctl_paths for more details. 195329e796fdSEric W. Biederman */ 195429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 195529e796fdSEric W. Biederman { 195629e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 195729e796fdSEric W. Biederman 195829e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 19591da177e4SLinus Torvalds } 19601da177e4SLinus Torvalds 19611da177e4SLinus Torvalds /** 19621da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 19631da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 19641da177e4SLinus Torvalds * 19651da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 19661da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 19671da177e4SLinus Torvalds */ 19681da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 19691da177e4SLinus Torvalds { 1970330d57fbSAl Viro might_sleep(); 1971f1dad166SPavel Emelyanov 1972f1dad166SPavel Emelyanov if (header == NULL) 1973f1dad166SPavel Emelyanov return; 1974f1dad166SPavel Emelyanov 1975330d57fbSAl Viro spin_lock(&sysctl_lock); 1976330d57fbSAl Viro start_unregistering(header); 1977ae7edeccSAl Viro if (!--header->parent->count) { 1978ae7edeccSAl Viro WARN_ON(1); 1979a95cded3SPaul E. McKenney kfree_rcu(header->parent, rcu); 1980ae7edeccSAl Viro } 1981f7e6ced4SAl Viro if (!--header->count) 1982a95cded3SPaul E. McKenney kfree_rcu(header, rcu); 1983f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19841da177e4SLinus Torvalds } 19851da177e4SLinus Torvalds 19869043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19879043476fSAl Viro { 19889043476fSAl Viro struct ctl_table_set *set = p->set; 19899043476fSAl Viro int res; 19909043476fSAl Viro spin_lock(&sysctl_lock); 19919043476fSAl Viro if (p->unregistering) 19929043476fSAl Viro res = 0; 19939043476fSAl Viro else if (!set->is_seen) 19949043476fSAl Viro res = 1; 19959043476fSAl Viro else 19969043476fSAl Viro res = set->is_seen(set); 19979043476fSAl Viro spin_unlock(&sysctl_lock); 19989043476fSAl Viro return res; 19999043476fSAl Viro } 20009043476fSAl Viro 200173455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 200273455092SAl Viro struct ctl_table_set *parent, 200373455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 200473455092SAl Viro { 200573455092SAl Viro INIT_LIST_HEAD(&p->list); 200673455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 200773455092SAl Viro p->is_seen = is_seen; 200873455092SAl Viro } 200973455092SAl Viro 2010b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 2011d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 2012b89a8171SEric W. Biederman { 2013b89a8171SEric W. Biederman return NULL; 2014b89a8171SEric W. Biederman } 2015b89a8171SEric W. Biederman 201629e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 201729e796fdSEric W. Biederman struct ctl_table *table) 201829e796fdSEric W. Biederman { 201929e796fdSEric W. Biederman return NULL; 202029e796fdSEric W. Biederman } 202129e796fdSEric W. Biederman 2022b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2023b89a8171SEric W. Biederman { 2024b89a8171SEric W. Biederman } 2025b89a8171SEric W. Biederman 202673455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 202773455092SAl Viro struct ctl_table_set *parent, 202873455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 202973455092SAl Viro { 203073455092SAl Viro } 203173455092SAl Viro 2032f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2033f7e6ced4SAl Viro { 2034f7e6ced4SAl Viro } 2035f7e6ced4SAl Viro 2036b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2037b89a8171SEric W. Biederman 20381da177e4SLinus Torvalds /* 20391da177e4SLinus Torvalds * /proc/sys support 20401da177e4SLinus Torvalds */ 20411da177e4SLinus Torvalds 2042b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 20431da177e4SLinus Torvalds 2044b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 20458d65af78SAlexey Dobriyan void __user *buffer, 2046b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2047f5dd3d6fSSam Vilain { 2048f5dd3d6fSSam Vilain size_t len; 2049f5dd3d6fSSam Vilain char __user *p; 2050f5dd3d6fSSam Vilain char c; 2051f5dd3d6fSSam Vilain 20528d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2053f5dd3d6fSSam Vilain *lenp = 0; 2054f5dd3d6fSSam Vilain return 0; 2055f5dd3d6fSSam Vilain } 2056f5dd3d6fSSam Vilain 2057f5dd3d6fSSam Vilain if (write) { 2058f5dd3d6fSSam Vilain len = 0; 2059f5dd3d6fSSam Vilain p = buffer; 2060f5dd3d6fSSam Vilain while (len < *lenp) { 2061f5dd3d6fSSam Vilain if (get_user(c, p++)) 2062f5dd3d6fSSam Vilain return -EFAULT; 2063f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2064f5dd3d6fSSam Vilain break; 2065f5dd3d6fSSam Vilain len++; 2066f5dd3d6fSSam Vilain } 2067f5dd3d6fSSam Vilain if (len >= maxlen) 2068f5dd3d6fSSam Vilain len = maxlen-1; 2069f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2070f5dd3d6fSSam Vilain return -EFAULT; 2071f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2072f5dd3d6fSSam Vilain *ppos += *lenp; 2073f5dd3d6fSSam Vilain } else { 2074f5dd3d6fSSam Vilain len = strlen(data); 2075f5dd3d6fSSam Vilain if (len > maxlen) 2076f5dd3d6fSSam Vilain len = maxlen; 20778d060877SOleg Nesterov 20788d060877SOleg Nesterov if (*ppos > len) { 20798d060877SOleg Nesterov *lenp = 0; 20808d060877SOleg Nesterov return 0; 20818d060877SOleg Nesterov } 20828d060877SOleg Nesterov 20838d060877SOleg Nesterov data += *ppos; 20848d060877SOleg Nesterov len -= *ppos; 20858d060877SOleg Nesterov 2086f5dd3d6fSSam Vilain if (len > *lenp) 2087f5dd3d6fSSam Vilain len = *lenp; 2088f5dd3d6fSSam Vilain if (len) 2089f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2090f5dd3d6fSSam Vilain return -EFAULT; 2091f5dd3d6fSSam Vilain if (len < *lenp) { 2092f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2093f5dd3d6fSSam Vilain return -EFAULT; 2094f5dd3d6fSSam Vilain len++; 2095f5dd3d6fSSam Vilain } 2096f5dd3d6fSSam Vilain *lenp = len; 2097f5dd3d6fSSam Vilain *ppos += len; 2098f5dd3d6fSSam Vilain } 2099f5dd3d6fSSam Vilain return 0; 2100f5dd3d6fSSam Vilain } 2101f5dd3d6fSSam Vilain 21021da177e4SLinus Torvalds /** 21031da177e4SLinus Torvalds * proc_dostring - read a string sysctl 21041da177e4SLinus Torvalds * @table: the sysctl table 21051da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21061da177e4SLinus Torvalds * @buffer: the user buffer 21071da177e4SLinus Torvalds * @lenp: the size of the user buffer 21081da177e4SLinus Torvalds * @ppos: file position 21091da177e4SLinus Torvalds * 21101da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 21111da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 21121da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 21131da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 21141da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 21151da177e4SLinus Torvalds * not large enough. 21161da177e4SLinus Torvalds * 21171da177e4SLinus Torvalds * Returns 0 on success. 21181da177e4SLinus Torvalds */ 21198d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 21201da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21211da177e4SLinus Torvalds { 21228d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2123f5dd3d6fSSam Vilain buffer, lenp, ppos); 21241da177e4SLinus Torvalds } 21251da177e4SLinus Torvalds 212600b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 212700b7c339SAmerigo Wang { 212800b7c339SAmerigo Wang size_t ret; 212900b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 213000b7c339SAmerigo Wang ret = tmp - *buf; 213100b7c339SAmerigo Wang *buf = tmp; 213200b7c339SAmerigo Wang return ret; 213300b7c339SAmerigo Wang } 21341da177e4SLinus Torvalds 21359f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v) 21369f977fb7SOctavian Purdila { 21379f977fb7SOctavian Purdila while (*size) { 21389f977fb7SOctavian Purdila if (**buf != v) 21399f977fb7SOctavian Purdila break; 21409f977fb7SOctavian Purdila (*size)--; 21419f977fb7SOctavian Purdila (*buf)++; 21429f977fb7SOctavian Purdila } 21439f977fb7SOctavian Purdila } 21449f977fb7SOctavian Purdila 214500b7c339SAmerigo Wang #define TMPBUFLEN 22 214600b7c339SAmerigo Wang /** 21470fc377bdSRandy Dunlap * proc_get_long - reads an ASCII formatted integer from a user buffer 214800b7c339SAmerigo Wang * 21490fc377bdSRandy Dunlap * @buf: a kernel buffer 21500fc377bdSRandy Dunlap * @size: size of the kernel buffer 21510fc377bdSRandy Dunlap * @val: this is where the number will be stored 21520fc377bdSRandy Dunlap * @neg: set to %TRUE if number is negative 21530fc377bdSRandy Dunlap * @perm_tr: a vector which contains the allowed trailers 21540fc377bdSRandy Dunlap * @perm_tr_len: size of the perm_tr vector 21550fc377bdSRandy Dunlap * @tr: pointer to store the trailer character 215600b7c339SAmerigo Wang * 21570fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 21580fc377bdSRandy Dunlap * the amount of bytes read. If @tr is non-NULL and a trailing 21590fc377bdSRandy Dunlap * character exists (size is non-zero after returning from this 21600fc377bdSRandy Dunlap * function), @tr is updated with the trailing character. 216100b7c339SAmerigo Wang */ 216200b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 216300b7c339SAmerigo Wang unsigned long *val, bool *neg, 216400b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 216500b7c339SAmerigo Wang { 216600b7c339SAmerigo Wang int len; 216700b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 216800b7c339SAmerigo Wang 216900b7c339SAmerigo Wang if (!*size) 217000b7c339SAmerigo Wang return -EINVAL; 217100b7c339SAmerigo Wang 217200b7c339SAmerigo Wang len = *size; 217300b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 217400b7c339SAmerigo Wang len = TMPBUFLEN - 1; 217500b7c339SAmerigo Wang 217600b7c339SAmerigo Wang memcpy(tmp, *buf, len); 217700b7c339SAmerigo Wang 217800b7c339SAmerigo Wang tmp[len] = 0; 217900b7c339SAmerigo Wang p = tmp; 218000b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 218100b7c339SAmerigo Wang *neg = true; 218200b7c339SAmerigo Wang p++; 218300b7c339SAmerigo Wang } else 218400b7c339SAmerigo Wang *neg = false; 218500b7c339SAmerigo Wang if (!isdigit(*p)) 218600b7c339SAmerigo Wang return -EINVAL; 218700b7c339SAmerigo Wang 218800b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 218900b7c339SAmerigo Wang 219000b7c339SAmerigo Wang len = p - tmp; 219100b7c339SAmerigo Wang 219200b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 219300b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 219400b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 219500b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 219600b7c339SAmerigo Wang return -EINVAL; 219700b7c339SAmerigo Wang 219800b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 219900b7c339SAmerigo Wang return -EINVAL; 220000b7c339SAmerigo Wang 220100b7c339SAmerigo Wang if (tr && (len < *size)) 220200b7c339SAmerigo Wang *tr = *p; 220300b7c339SAmerigo Wang 220400b7c339SAmerigo Wang *buf += len; 220500b7c339SAmerigo Wang *size -= len; 220600b7c339SAmerigo Wang 220700b7c339SAmerigo Wang return 0; 220800b7c339SAmerigo Wang } 220900b7c339SAmerigo Wang 221000b7c339SAmerigo Wang /** 22110fc377bdSRandy Dunlap * proc_put_long - converts an integer to a decimal ASCII formatted string 221200b7c339SAmerigo Wang * 22130fc377bdSRandy Dunlap * @buf: the user buffer 22140fc377bdSRandy Dunlap * @size: the size of the user buffer 22150fc377bdSRandy Dunlap * @val: the integer to be converted 22160fc377bdSRandy Dunlap * @neg: sign of the number, %TRUE for negative 221700b7c339SAmerigo Wang * 22180fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 22190fc377bdSRandy Dunlap * the amount of bytes written. 222000b7c339SAmerigo Wang */ 222100b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 222200b7c339SAmerigo Wang bool neg) 222300b7c339SAmerigo Wang { 222400b7c339SAmerigo Wang int len; 222500b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 222600b7c339SAmerigo Wang 222700b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 222800b7c339SAmerigo Wang len = strlen(tmp); 222900b7c339SAmerigo Wang if (len > *size) 223000b7c339SAmerigo Wang len = *size; 223100b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 223200b7c339SAmerigo Wang return -EFAULT; 223300b7c339SAmerigo Wang *size -= len; 223400b7c339SAmerigo Wang *buf += len; 223500b7c339SAmerigo Wang return 0; 223600b7c339SAmerigo Wang } 223700b7c339SAmerigo Wang #undef TMPBUFLEN 223800b7c339SAmerigo Wang 223900b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 224000b7c339SAmerigo Wang { 224100b7c339SAmerigo Wang if (*size) { 224200b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 224300b7c339SAmerigo Wang if (put_user(c, *buffer)) 224400b7c339SAmerigo Wang return -EFAULT; 224500b7c339SAmerigo Wang (*size)--, (*buffer)++; 224600b7c339SAmerigo Wang *buf = *buffer; 224700b7c339SAmerigo Wang } 224800b7c339SAmerigo Wang return 0; 224900b7c339SAmerigo Wang } 225000b7c339SAmerigo Wang 225100b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 22521da177e4SLinus Torvalds int *valp, 22531da177e4SLinus Torvalds int write, void *data) 22541da177e4SLinus Torvalds { 22551da177e4SLinus Torvalds if (write) { 22561da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 22571da177e4SLinus Torvalds } else { 22581da177e4SLinus Torvalds int val = *valp; 22591da177e4SLinus Torvalds if (val < 0) { 226000b7c339SAmerigo Wang *negp = true; 22611da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22621da177e4SLinus Torvalds } else { 226300b7c339SAmerigo Wang *negp = false; 22641da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22651da177e4SLinus Torvalds } 22661da177e4SLinus Torvalds } 22671da177e4SLinus Torvalds return 0; 22681da177e4SLinus Torvalds } 22691da177e4SLinus Torvalds 227000b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 227100b7c339SAmerigo Wang 2272d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 22738d65af78SAlexey Dobriyan int write, void __user *buffer, 2274fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 227500b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 22761da177e4SLinus Torvalds int write, void *data), 22771da177e4SLinus Torvalds void *data) 22781da177e4SLinus Torvalds { 227900b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 228000b7c339SAmerigo Wang unsigned long page = 0; 228100b7c339SAmerigo Wang size_t left; 228200b7c339SAmerigo Wang char *kbuf; 22831da177e4SLinus Torvalds 228400b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 22851da177e4SLinus Torvalds *lenp = 0; 22861da177e4SLinus Torvalds return 0; 22871da177e4SLinus Torvalds } 22881da177e4SLinus Torvalds 2289fcfbd547SKirill Korotaev i = (int *) tbl_data; 22901da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 22911da177e4SLinus Torvalds left = *lenp; 22921da177e4SLinus Torvalds 22931da177e4SLinus Torvalds if (!conv) 22941da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 22951da177e4SLinus Torvalds 229600b7c339SAmerigo Wang if (write) { 229700b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 229800b7c339SAmerigo Wang left = PAGE_SIZE - 1; 229900b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 230000b7c339SAmerigo Wang kbuf = (char *) page; 230100b7c339SAmerigo Wang if (!kbuf) 230200b7c339SAmerigo Wang return -ENOMEM; 230300b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 230400b7c339SAmerigo Wang err = -EFAULT; 230500b7c339SAmerigo Wang goto free; 230600b7c339SAmerigo Wang } 230700b7c339SAmerigo Wang kbuf[left] = 0; 230800b7c339SAmerigo Wang } 230900b7c339SAmerigo Wang 23101da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 231100b7c339SAmerigo Wang unsigned long lval; 231200b7c339SAmerigo Wang bool neg; 231300b7c339SAmerigo Wang 23141da177e4SLinus Torvalds if (write) { 231500b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 231600b7c339SAmerigo Wang 2317563b0467SJ. R. Okajima if (!left) 2318563b0467SJ. R. Okajima break; 231900b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 232000b7c339SAmerigo Wang proc_wspace_sep, 232100b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 232200b7c339SAmerigo Wang if (err) 23231da177e4SLinus Torvalds break; 232400b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 232500b7c339SAmerigo Wang err = -EINVAL; 232600b7c339SAmerigo Wang break; 23271da177e4SLinus Torvalds } 23281da177e4SLinus Torvalds } else { 232900b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 233000b7c339SAmerigo Wang err = -EINVAL; 233100b7c339SAmerigo Wang break; 233200b7c339SAmerigo Wang } 23331da177e4SLinus Torvalds if (!first) 233400b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 233500b7c339SAmerigo Wang if (err) 23361da177e4SLinus Torvalds break; 233700b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 233800b7c339SAmerigo Wang if (err) 233900b7c339SAmerigo Wang break; 23401da177e4SLinus Torvalds } 23411da177e4SLinus Torvalds } 23421da177e4SLinus Torvalds 234300b7c339SAmerigo Wang if (!write && !first && left && !err) 234400b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 2345563b0467SJ. R. Okajima if (write && !err && left) 234600b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 234700b7c339SAmerigo Wang free: 23481da177e4SLinus Torvalds if (write) { 234900b7c339SAmerigo Wang free_page(page); 235000b7c339SAmerigo Wang if (first) 235100b7c339SAmerigo Wang return err ? : -EINVAL; 23521da177e4SLinus Torvalds } 23531da177e4SLinus Torvalds *lenp -= left; 23541da177e4SLinus Torvalds *ppos += *lenp; 235500b7c339SAmerigo Wang return err; 23561da177e4SLinus Torvalds } 23571da177e4SLinus Torvalds 23588d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2359fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 236000b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 2361fcfbd547SKirill Korotaev int write, void *data), 2362fcfbd547SKirill Korotaev void *data) 2363fcfbd547SKirill Korotaev { 23648d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2365fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2366fcfbd547SKirill Korotaev } 2367fcfbd547SKirill Korotaev 23681da177e4SLinus Torvalds /** 23691da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 23701da177e4SLinus Torvalds * @table: the sysctl table 23711da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23721da177e4SLinus Torvalds * @buffer: the user buffer 23731da177e4SLinus Torvalds * @lenp: the size of the user buffer 23741da177e4SLinus Torvalds * @ppos: file position 23751da177e4SLinus Torvalds * 23761da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23771da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23781da177e4SLinus Torvalds * 23791da177e4SLinus Torvalds * Returns 0 on success. 23801da177e4SLinus Torvalds */ 23818d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 23821da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23831da177e4SLinus Torvalds { 23848d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 23851da177e4SLinus Torvalds NULL,NULL); 23861da177e4SLinus Torvalds } 23871da177e4SLinus Torvalds 238834f5a398STheodore Ts'o /* 238934f5a398STheodore Ts'o * Taint values can only be increased 239025ddbb18SAndi Kleen * This means we can safely use a temporary. 239134f5a398STheodore Ts'o */ 23928d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 239334f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 239434f5a398STheodore Ts'o { 239525ddbb18SAndi Kleen struct ctl_table t; 239625ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 239725ddbb18SAndi Kleen int err; 239834f5a398STheodore Ts'o 239991fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 240034f5a398STheodore Ts'o return -EPERM; 240134f5a398STheodore Ts'o 240225ddbb18SAndi Kleen t = *table; 240325ddbb18SAndi Kleen t.data = &tmptaint; 24048d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 240525ddbb18SAndi Kleen if (err < 0) 240625ddbb18SAndi Kleen return err; 240725ddbb18SAndi Kleen 240825ddbb18SAndi Kleen if (write) { 240925ddbb18SAndi Kleen /* 241025ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 241125ddbb18SAndi Kleen * to everyone's atomic.h for this 241225ddbb18SAndi Kleen */ 241325ddbb18SAndi Kleen int i; 241425ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 241525ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 241625ddbb18SAndi Kleen add_taint(i); 241725ddbb18SAndi Kleen } 241825ddbb18SAndi Kleen } 241925ddbb18SAndi Kleen 242025ddbb18SAndi Kleen return err; 242134f5a398STheodore Ts'o } 242234f5a398STheodore Ts'o 2423bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 2424bfdc0b49SRichard Weinberger static int proc_dmesg_restrict(struct ctl_table *table, int write, 2425bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos) 2426bfdc0b49SRichard Weinberger { 2427bfdc0b49SRichard Weinberger if (write && !capable(CAP_SYS_ADMIN)) 2428bfdc0b49SRichard Weinberger return -EPERM; 2429bfdc0b49SRichard Weinberger 2430bfdc0b49SRichard Weinberger return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 2431bfdc0b49SRichard Weinberger } 2432bfdc0b49SRichard Weinberger #endif 2433bfdc0b49SRichard Weinberger 24341da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 24351da177e4SLinus Torvalds int *min; 24361da177e4SLinus Torvalds int *max; 24371da177e4SLinus Torvalds }; 24381da177e4SLinus Torvalds 243900b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 24401da177e4SLinus Torvalds int *valp, 24411da177e4SLinus Torvalds int write, void *data) 24421da177e4SLinus Torvalds { 24431da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 24441da177e4SLinus Torvalds if (write) { 24451da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 24461da177e4SLinus Torvalds if ((param->min && *param->min > val) || 24471da177e4SLinus Torvalds (param->max && *param->max < val)) 24481da177e4SLinus Torvalds return -EINVAL; 24491da177e4SLinus Torvalds *valp = val; 24501da177e4SLinus Torvalds } else { 24511da177e4SLinus Torvalds int val = *valp; 24521da177e4SLinus Torvalds if (val < 0) { 245300b7c339SAmerigo Wang *negp = true; 24541da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 24551da177e4SLinus Torvalds } else { 245600b7c339SAmerigo Wang *negp = false; 24571da177e4SLinus Torvalds *lvalp = (unsigned long)val; 24581da177e4SLinus Torvalds } 24591da177e4SLinus Torvalds } 24601da177e4SLinus Torvalds return 0; 24611da177e4SLinus Torvalds } 24621da177e4SLinus Torvalds 24631da177e4SLinus Torvalds /** 24641da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 24651da177e4SLinus Torvalds * @table: the sysctl table 24661da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24671da177e4SLinus Torvalds * @buffer: the user buffer 24681da177e4SLinus Torvalds * @lenp: the size of the user buffer 24691da177e4SLinus Torvalds * @ppos: file position 24701da177e4SLinus Torvalds * 24711da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24721da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24731da177e4SLinus Torvalds * 24741da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24751da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24761da177e4SLinus Torvalds * 24771da177e4SLinus Torvalds * Returns 0 on success. 24781da177e4SLinus Torvalds */ 24798d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 24801da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24811da177e4SLinus Torvalds { 24821da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 24831da177e4SLinus Torvalds .min = (int *) table->extra1, 24841da177e4SLinus Torvalds .max = (int *) table->extra2, 24851da177e4SLinus Torvalds }; 24868d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 24871da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 24881da177e4SLinus Torvalds } 24891da177e4SLinus Torvalds 2490d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 24911da177e4SLinus Torvalds void __user *buffer, 24921da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 24931da177e4SLinus Torvalds unsigned long convmul, 24941da177e4SLinus Torvalds unsigned long convdiv) 24951da177e4SLinus Torvalds { 249600b7c339SAmerigo Wang unsigned long *i, *min, *max; 249700b7c339SAmerigo Wang int vleft, first = 1, err = 0; 249800b7c339SAmerigo Wang unsigned long page = 0; 249900b7c339SAmerigo Wang size_t left; 250000b7c339SAmerigo Wang char *kbuf; 25011da177e4SLinus Torvalds 250200b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 25031da177e4SLinus Torvalds *lenp = 0; 25041da177e4SLinus Torvalds return 0; 25051da177e4SLinus Torvalds } 25061da177e4SLinus Torvalds 2507fcfbd547SKirill Korotaev i = (unsigned long *) data; 25081da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 25091da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 25101da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 25111da177e4SLinus Torvalds left = *lenp; 25121da177e4SLinus Torvalds 25131da177e4SLinus Torvalds if (write) { 251400b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 251500b7c339SAmerigo Wang left = PAGE_SIZE - 1; 251600b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 251700b7c339SAmerigo Wang kbuf = (char *) page; 251800b7c339SAmerigo Wang if (!kbuf) 251900b7c339SAmerigo Wang return -ENOMEM; 252000b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 252100b7c339SAmerigo Wang err = -EFAULT; 252200b7c339SAmerigo Wang goto free; 25231da177e4SLinus Torvalds } 252400b7c339SAmerigo Wang kbuf[left] = 0; 25251da177e4SLinus Torvalds } 25261da177e4SLinus Torvalds 252727b3d80aSEric Dumazet for (; left && vleft--; i++, first = 0) { 252800b7c339SAmerigo Wang unsigned long val; 252900b7c339SAmerigo Wang 253000b7c339SAmerigo Wang if (write) { 253100b7c339SAmerigo Wang bool neg; 253200b7c339SAmerigo Wang 253300b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 253400b7c339SAmerigo Wang 253500b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 253600b7c339SAmerigo Wang proc_wspace_sep, 253700b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 253800b7c339SAmerigo Wang if (err) 253900b7c339SAmerigo Wang break; 25401da177e4SLinus Torvalds if (neg) 25411da177e4SLinus Torvalds continue; 25421da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 25431da177e4SLinus Torvalds continue; 25441da177e4SLinus Torvalds *i = val; 25451da177e4SLinus Torvalds } else { 254600b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 25471da177e4SLinus Torvalds if (!first) 254800b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 254900b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 255000b7c339SAmerigo Wang if (err) 255100b7c339SAmerigo Wang break; 25521da177e4SLinus Torvalds } 25531da177e4SLinus Torvalds } 25541da177e4SLinus Torvalds 255500b7c339SAmerigo Wang if (!write && !first && left && !err) 255600b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 255700b7c339SAmerigo Wang if (write && !err) 255800b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 255900b7c339SAmerigo Wang free: 25601da177e4SLinus Torvalds if (write) { 256100b7c339SAmerigo Wang free_page(page); 256200b7c339SAmerigo Wang if (first) 256300b7c339SAmerigo Wang return err ? : -EINVAL; 25641da177e4SLinus Torvalds } 25651da177e4SLinus Torvalds *lenp -= left; 25661da177e4SLinus Torvalds *ppos += *lenp; 256700b7c339SAmerigo Wang return err; 25681da177e4SLinus Torvalds } 25691da177e4SLinus Torvalds 2570d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2571fcfbd547SKirill Korotaev void __user *buffer, 2572fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2573fcfbd547SKirill Korotaev unsigned long convmul, 2574fcfbd547SKirill Korotaev unsigned long convdiv) 2575fcfbd547SKirill Korotaev { 2576fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 25778d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2578fcfbd547SKirill Korotaev } 2579fcfbd547SKirill Korotaev 25801da177e4SLinus Torvalds /** 25811da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 25821da177e4SLinus Torvalds * @table: the sysctl table 25831da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25841da177e4SLinus Torvalds * @buffer: the user buffer 25851da177e4SLinus Torvalds * @lenp: the size of the user buffer 25861da177e4SLinus Torvalds * @ppos: file position 25871da177e4SLinus Torvalds * 25881da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 25891da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25901da177e4SLinus Torvalds * 25911da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25921da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25931da177e4SLinus Torvalds * 25941da177e4SLinus Torvalds * Returns 0 on success. 25951da177e4SLinus Torvalds */ 25968d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 25971da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25981da177e4SLinus Torvalds { 25998d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 26001da177e4SLinus Torvalds } 26011da177e4SLinus Torvalds 26021da177e4SLinus Torvalds /** 26031da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 26041da177e4SLinus Torvalds * @table: the sysctl table 26051da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26061da177e4SLinus Torvalds * @buffer: the user buffer 26071da177e4SLinus Torvalds * @lenp: the size of the user buffer 26081da177e4SLinus Torvalds * @ppos: file position 26091da177e4SLinus Torvalds * 26101da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26111da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 26121da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 26131da177e4SLinus Torvalds * 26141da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26151da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26161da177e4SLinus Torvalds * 26171da177e4SLinus Torvalds * Returns 0 on success. 26181da177e4SLinus Torvalds */ 2619d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26201da177e4SLinus Torvalds void __user *buffer, 26211da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26221da177e4SLinus Torvalds { 26238d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 26241da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 26251da177e4SLinus Torvalds } 26261da177e4SLinus Torvalds 26271da177e4SLinus Torvalds 262800b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 26291da177e4SLinus Torvalds int *valp, 26301da177e4SLinus Torvalds int write, void *data) 26311da177e4SLinus Torvalds { 26321da177e4SLinus Torvalds if (write) { 2633cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2634cba9f33dSBart Samwel return 1; 26351da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 26361da177e4SLinus Torvalds } else { 26371da177e4SLinus Torvalds int val = *valp; 26381da177e4SLinus Torvalds unsigned long lval; 26391da177e4SLinus Torvalds if (val < 0) { 264000b7c339SAmerigo Wang *negp = true; 26411da177e4SLinus Torvalds lval = (unsigned long)-val; 26421da177e4SLinus Torvalds } else { 264300b7c339SAmerigo Wang *negp = false; 26441da177e4SLinus Torvalds lval = (unsigned long)val; 26451da177e4SLinus Torvalds } 26461da177e4SLinus Torvalds *lvalp = lval / HZ; 26471da177e4SLinus Torvalds } 26481da177e4SLinus Torvalds return 0; 26491da177e4SLinus Torvalds } 26501da177e4SLinus Torvalds 265100b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 26521da177e4SLinus Torvalds int *valp, 26531da177e4SLinus Torvalds int write, void *data) 26541da177e4SLinus Torvalds { 26551da177e4SLinus Torvalds if (write) { 2656cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2657cba9f33dSBart Samwel return 1; 26581da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 26591da177e4SLinus Torvalds } else { 26601da177e4SLinus Torvalds int val = *valp; 26611da177e4SLinus Torvalds unsigned long lval; 26621da177e4SLinus Torvalds if (val < 0) { 266300b7c339SAmerigo Wang *negp = true; 26641da177e4SLinus Torvalds lval = (unsigned long)-val; 26651da177e4SLinus Torvalds } else { 266600b7c339SAmerigo Wang *negp = false; 26671da177e4SLinus Torvalds lval = (unsigned long)val; 26681da177e4SLinus Torvalds } 26691da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 26701da177e4SLinus Torvalds } 26711da177e4SLinus Torvalds return 0; 26721da177e4SLinus Torvalds } 26731da177e4SLinus Torvalds 267400b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 26751da177e4SLinus Torvalds int *valp, 26761da177e4SLinus Torvalds int write, void *data) 26771da177e4SLinus Torvalds { 26781da177e4SLinus Torvalds if (write) { 26791da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 26801da177e4SLinus Torvalds } else { 26811da177e4SLinus Torvalds int val = *valp; 26821da177e4SLinus Torvalds unsigned long lval; 26831da177e4SLinus Torvalds if (val < 0) { 268400b7c339SAmerigo Wang *negp = true; 26851da177e4SLinus Torvalds lval = (unsigned long)-val; 26861da177e4SLinus Torvalds } else { 268700b7c339SAmerigo Wang *negp = false; 26881da177e4SLinus Torvalds lval = (unsigned long)val; 26891da177e4SLinus Torvalds } 26901da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 26911da177e4SLinus Torvalds } 26921da177e4SLinus Torvalds return 0; 26931da177e4SLinus Torvalds } 26941da177e4SLinus Torvalds 26951da177e4SLinus Torvalds /** 26961da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 26971da177e4SLinus Torvalds * @table: the sysctl table 26981da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26991da177e4SLinus Torvalds * @buffer: the user buffer 27001da177e4SLinus Torvalds * @lenp: the size of the user buffer 27011da177e4SLinus Torvalds * @ppos: file position 27021da177e4SLinus Torvalds * 27031da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27041da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27051da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 27061da177e4SLinus Torvalds * jiffies. 27071da177e4SLinus Torvalds * 27081da177e4SLinus Torvalds * Returns 0 on success. 27091da177e4SLinus Torvalds */ 27108d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 27111da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27121da177e4SLinus Torvalds { 27138d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27141da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 27151da177e4SLinus Torvalds } 27161da177e4SLinus Torvalds 27171da177e4SLinus Torvalds /** 27181da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 27191da177e4SLinus Torvalds * @table: the sysctl table 27201da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27211da177e4SLinus Torvalds * @buffer: the user buffer 27221da177e4SLinus Torvalds * @lenp: the size of the user buffer 27231e5d5331SRandy Dunlap * @ppos: pointer to the file position 27241da177e4SLinus Torvalds * 27251da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27261da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27271da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 27281da177e4SLinus Torvalds * are converted into jiffies. 27291da177e4SLinus Torvalds * 27301da177e4SLinus Torvalds * Returns 0 on success. 27311da177e4SLinus Torvalds */ 27328d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 27331da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27341da177e4SLinus Torvalds { 27358d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27361da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 27371da177e4SLinus Torvalds } 27381da177e4SLinus Torvalds 27391da177e4SLinus Torvalds /** 27401da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 27411da177e4SLinus Torvalds * @table: the sysctl table 27421da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27431da177e4SLinus Torvalds * @buffer: the user buffer 27441da177e4SLinus Torvalds * @lenp: the size of the user buffer 274567be2dd1SMartin Waitz * @ppos: file position 274667be2dd1SMartin Waitz * @ppos: the current position in the file 27471da177e4SLinus Torvalds * 27481da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27491da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27501da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 27511da177e4SLinus Torvalds * are converted into jiffies. 27521da177e4SLinus Torvalds * 27531da177e4SLinus Torvalds * Returns 0 on success. 27541da177e4SLinus Torvalds */ 27558d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 27561da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27571da177e4SLinus Torvalds { 27588d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 27591da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 27601da177e4SLinus Torvalds } 27611da177e4SLinus Torvalds 27628d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 27639ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 27649ec52099SCedric Le Goater { 27659ec52099SCedric Le Goater struct pid *new_pid; 27669ec52099SCedric Le Goater pid_t tmp; 27679ec52099SCedric Le Goater int r; 27689ec52099SCedric Le Goater 27696c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 27709ec52099SCedric Le Goater 27718d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 27729ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 27739ec52099SCedric Le Goater if (r || !write) 27749ec52099SCedric Le Goater return r; 27759ec52099SCedric Le Goater 27769ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 27779ec52099SCedric Le Goater if (!new_pid) 27789ec52099SCedric Le Goater return -ESRCH; 27799ec52099SCedric Le Goater 27809ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 27819ec52099SCedric Le Goater return 0; 27829ec52099SCedric Le Goater } 27839ec52099SCedric Le Goater 27849f977fb7SOctavian Purdila /** 27859f977fb7SOctavian Purdila * proc_do_large_bitmap - read/write from/to a large bitmap 27869f977fb7SOctavian Purdila * @table: the sysctl table 27879f977fb7SOctavian Purdila * @write: %TRUE if this is a write to the sysctl file 27889f977fb7SOctavian Purdila * @buffer: the user buffer 27899f977fb7SOctavian Purdila * @lenp: the size of the user buffer 27909f977fb7SOctavian Purdila * @ppos: file position 27919f977fb7SOctavian Purdila * 27929f977fb7SOctavian Purdila * The bitmap is stored at table->data and the bitmap length (in bits) 27939f977fb7SOctavian Purdila * in table->maxlen. 27949f977fb7SOctavian Purdila * 27959f977fb7SOctavian Purdila * We use a range comma separated format (e.g. 1,3-4,10-10) so that 27969f977fb7SOctavian Purdila * large bitmaps may be represented in a compact manner. Writing into 27979f977fb7SOctavian Purdila * the file will clear the bitmap then update it with the given input. 27989f977fb7SOctavian Purdila * 27999f977fb7SOctavian Purdila * Returns 0 on success. 28009f977fb7SOctavian Purdila */ 28019f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write, 28029f977fb7SOctavian Purdila void __user *buffer, size_t *lenp, loff_t *ppos) 28039f977fb7SOctavian Purdila { 28049f977fb7SOctavian Purdila int err = 0; 28059f977fb7SOctavian Purdila bool first = 1; 28069f977fb7SOctavian Purdila size_t left = *lenp; 28079f977fb7SOctavian Purdila unsigned long bitmap_len = table->maxlen; 28089f977fb7SOctavian Purdila unsigned long *bitmap = (unsigned long *) table->data; 28099f977fb7SOctavian Purdila unsigned long *tmp_bitmap = NULL; 28109f977fb7SOctavian Purdila char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 28119f977fb7SOctavian Purdila 28129f977fb7SOctavian Purdila if (!bitmap_len || !left || (*ppos && !write)) { 28139f977fb7SOctavian Purdila *lenp = 0; 28149f977fb7SOctavian Purdila return 0; 28159f977fb7SOctavian Purdila } 28169f977fb7SOctavian Purdila 28179f977fb7SOctavian Purdila if (write) { 28189f977fb7SOctavian Purdila unsigned long page = 0; 28199f977fb7SOctavian Purdila char *kbuf; 28209f977fb7SOctavian Purdila 28219f977fb7SOctavian Purdila if (left > PAGE_SIZE - 1) 28229f977fb7SOctavian Purdila left = PAGE_SIZE - 1; 28239f977fb7SOctavian Purdila 28249f977fb7SOctavian Purdila page = __get_free_page(GFP_TEMPORARY); 28259f977fb7SOctavian Purdila kbuf = (char *) page; 28269f977fb7SOctavian Purdila if (!kbuf) 28279f977fb7SOctavian Purdila return -ENOMEM; 28289f977fb7SOctavian Purdila if (copy_from_user(kbuf, buffer, left)) { 28299f977fb7SOctavian Purdila free_page(page); 28309f977fb7SOctavian Purdila return -EFAULT; 28319f977fb7SOctavian Purdila } 28329f977fb7SOctavian Purdila kbuf[left] = 0; 28339f977fb7SOctavian Purdila 28349f977fb7SOctavian Purdila tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), 28359f977fb7SOctavian Purdila GFP_KERNEL); 28369f977fb7SOctavian Purdila if (!tmp_bitmap) { 28379f977fb7SOctavian Purdila free_page(page); 28389f977fb7SOctavian Purdila return -ENOMEM; 28399f977fb7SOctavian Purdila } 28409f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28419f977fb7SOctavian Purdila while (!err && left) { 28429f977fb7SOctavian Purdila unsigned long val_a, val_b; 28439f977fb7SOctavian Purdila bool neg; 28449f977fb7SOctavian Purdila 28459f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, 28469f977fb7SOctavian Purdila sizeof(tr_a), &c); 28479f977fb7SOctavian Purdila if (err) 28489f977fb7SOctavian Purdila break; 28499f977fb7SOctavian Purdila if (val_a >= bitmap_len || neg) { 28509f977fb7SOctavian Purdila err = -EINVAL; 28519f977fb7SOctavian Purdila break; 28529f977fb7SOctavian Purdila } 28539f977fb7SOctavian Purdila 28549f977fb7SOctavian Purdila val_b = val_a; 28559f977fb7SOctavian Purdila if (left) { 28569f977fb7SOctavian Purdila kbuf++; 28579f977fb7SOctavian Purdila left--; 28589f977fb7SOctavian Purdila } 28599f977fb7SOctavian Purdila 28609f977fb7SOctavian Purdila if (c == '-') { 28619f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_b, 28629f977fb7SOctavian Purdila &neg, tr_b, sizeof(tr_b), 28639f977fb7SOctavian Purdila &c); 28649f977fb7SOctavian Purdila if (err) 28659f977fb7SOctavian Purdila break; 28669f977fb7SOctavian Purdila if (val_b >= bitmap_len || neg || 28679f977fb7SOctavian Purdila val_a > val_b) { 28689f977fb7SOctavian Purdila err = -EINVAL; 28699f977fb7SOctavian Purdila break; 28709f977fb7SOctavian Purdila } 28719f977fb7SOctavian Purdila if (left) { 28729f977fb7SOctavian Purdila kbuf++; 28739f977fb7SOctavian Purdila left--; 28749f977fb7SOctavian Purdila } 28759f977fb7SOctavian Purdila } 28769f977fb7SOctavian Purdila 28779f977fb7SOctavian Purdila while (val_a <= val_b) 28789f977fb7SOctavian Purdila set_bit(val_a++, tmp_bitmap); 28799f977fb7SOctavian Purdila 28809f977fb7SOctavian Purdila first = 0; 28819f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28829f977fb7SOctavian Purdila } 28839f977fb7SOctavian Purdila free_page(page); 28849f977fb7SOctavian Purdila } else { 28859f977fb7SOctavian Purdila unsigned long bit_a, bit_b = 0; 28869f977fb7SOctavian Purdila 28879f977fb7SOctavian Purdila while (left) { 28889f977fb7SOctavian Purdila bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 28899f977fb7SOctavian Purdila if (bit_a >= bitmap_len) 28909f977fb7SOctavian Purdila break; 28919f977fb7SOctavian Purdila bit_b = find_next_zero_bit(bitmap, bitmap_len, 28929f977fb7SOctavian Purdila bit_a + 1) - 1; 28939f977fb7SOctavian Purdila 28949f977fb7SOctavian Purdila if (!first) { 28959f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, ','); 28969f977fb7SOctavian Purdila if (err) 28979f977fb7SOctavian Purdila break; 28989f977fb7SOctavian Purdila } 28999f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_a, false); 29009f977fb7SOctavian Purdila if (err) 29019f977fb7SOctavian Purdila break; 29029f977fb7SOctavian Purdila if (bit_a != bit_b) { 29039f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '-'); 29049f977fb7SOctavian Purdila if (err) 29059f977fb7SOctavian Purdila break; 29069f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_b, false); 29079f977fb7SOctavian Purdila if (err) 29089f977fb7SOctavian Purdila break; 29099f977fb7SOctavian Purdila } 29109f977fb7SOctavian Purdila 29119f977fb7SOctavian Purdila first = 0; bit_b++; 29129f977fb7SOctavian Purdila } 29139f977fb7SOctavian Purdila if (!err) 29149f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '\n'); 29159f977fb7SOctavian Purdila } 29169f977fb7SOctavian Purdila 29179f977fb7SOctavian Purdila if (!err) { 29189f977fb7SOctavian Purdila if (write) { 29199f977fb7SOctavian Purdila if (*ppos) 29209f977fb7SOctavian Purdila bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 29219f977fb7SOctavian Purdila else 29229f977fb7SOctavian Purdila memcpy(bitmap, tmp_bitmap, 29239f977fb7SOctavian Purdila BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long)); 29249f977fb7SOctavian Purdila } 29259f977fb7SOctavian Purdila kfree(tmp_bitmap); 29269f977fb7SOctavian Purdila *lenp -= left; 29279f977fb7SOctavian Purdila *ppos += *lenp; 29289f977fb7SOctavian Purdila return 0; 29299f977fb7SOctavian Purdila } else { 29309f977fb7SOctavian Purdila kfree(tmp_bitmap); 29319f977fb7SOctavian Purdila return err; 29329f977fb7SOctavian Purdila } 29339f977fb7SOctavian Purdila } 29349f977fb7SOctavian Purdila 293555610500SJovi Zhang #else /* CONFIG_PROC_SYSCTL */ 29361da177e4SLinus Torvalds 29378d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 29381da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29391da177e4SLinus Torvalds { 29401da177e4SLinus Torvalds return -ENOSYS; 29411da177e4SLinus Torvalds } 29421da177e4SLinus Torvalds 29438d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 29441da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29451da177e4SLinus Torvalds { 29461da177e4SLinus Torvalds return -ENOSYS; 29471da177e4SLinus Torvalds } 29481da177e4SLinus Torvalds 29498d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 29501da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29511da177e4SLinus Torvalds { 29521da177e4SLinus Torvalds return -ENOSYS; 29531da177e4SLinus Torvalds } 29541da177e4SLinus Torvalds 29558d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 29561da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29571da177e4SLinus Torvalds { 29581da177e4SLinus Torvalds return -ENOSYS; 29591da177e4SLinus Torvalds } 29601da177e4SLinus Torvalds 29618d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 29621da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29631da177e4SLinus Torvalds { 29641da177e4SLinus Torvalds return -ENOSYS; 29651da177e4SLinus Torvalds } 29661da177e4SLinus Torvalds 29678d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 29681da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29691da177e4SLinus Torvalds { 29701da177e4SLinus Torvalds return -ENOSYS; 29711da177e4SLinus Torvalds } 29721da177e4SLinus Torvalds 29738d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 29741da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29751da177e4SLinus Torvalds { 29761da177e4SLinus Torvalds return -ENOSYS; 29771da177e4SLinus Torvalds } 29781da177e4SLinus Torvalds 2979d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 29801da177e4SLinus Torvalds void __user *buffer, 29811da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 29821da177e4SLinus Torvalds { 29831da177e4SLinus Torvalds return -ENOSYS; 29841da177e4SLinus Torvalds } 29851da177e4SLinus Torvalds 29861da177e4SLinus Torvalds 298755610500SJovi Zhang #endif /* CONFIG_PROC_SYSCTL */ 29881da177e4SLinus Torvalds 29891da177e4SLinus Torvalds /* 29901da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 29911da177e4SLinus Torvalds * exception granted :-) 29921da177e4SLinus Torvalds */ 29931da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 29941da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 29951da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 29961da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 29971da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 29981da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 29991da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 30001da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 30011da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 300229e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 30031da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 3004