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 382f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 383f20786ffSPeter Zijlstra { 384f20786ffSPeter Zijlstra .procname = "prove_locking", 385f20786ffSPeter Zijlstra .data = &prove_locking, 386f20786ffSPeter Zijlstra .maxlen = sizeof(int), 387f20786ffSPeter Zijlstra .mode = 0644, 3886d456111SEric W. Biederman .proc_handler = proc_dointvec, 389f20786ffSPeter Zijlstra }, 390f20786ffSPeter Zijlstra #endif 391f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 392f20786ffSPeter Zijlstra { 393f20786ffSPeter Zijlstra .procname = "lock_stat", 394f20786ffSPeter Zijlstra .data = &lock_stat, 395f20786ffSPeter Zijlstra .maxlen = sizeof(int), 396f20786ffSPeter Zijlstra .mode = 0644, 3976d456111SEric W. Biederman .proc_handler = proc_dointvec, 398f20786ffSPeter Zijlstra }, 399f20786ffSPeter Zijlstra #endif 40077e54a1fSIngo Molnar { 4011da177e4SLinus Torvalds .procname = "panic", 4021da177e4SLinus Torvalds .data = &panic_timeout, 4031da177e4SLinus Torvalds .maxlen = sizeof(int), 4041da177e4SLinus Torvalds .mode = 0644, 4056d456111SEric W. Biederman .proc_handler = proc_dointvec, 4061da177e4SLinus Torvalds }, 4071da177e4SLinus Torvalds { 4081da177e4SLinus Torvalds .procname = "core_uses_pid", 4091da177e4SLinus Torvalds .data = &core_uses_pid, 4101da177e4SLinus Torvalds .maxlen = sizeof(int), 4111da177e4SLinus Torvalds .mode = 0644, 4126d456111SEric W. Biederman .proc_handler = proc_dointvec, 4131da177e4SLinus Torvalds }, 4141da177e4SLinus Torvalds { 4151da177e4SLinus Torvalds .procname = "core_pattern", 4161da177e4SLinus Torvalds .data = core_pattern, 41771ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4181da177e4SLinus Torvalds .mode = 0644, 4196d456111SEric W. Biederman .proc_handler = proc_dostring, 4201da177e4SLinus Torvalds }, 421a293980cSNeil Horman { 422a293980cSNeil Horman .procname = "core_pipe_limit", 423a293980cSNeil Horman .data = &core_pipe_limit, 424a293980cSNeil Horman .maxlen = sizeof(unsigned int), 425a293980cSNeil Horman .mode = 0644, 4266d456111SEric W. Biederman .proc_handler = proc_dointvec, 427a293980cSNeil Horman }, 42834f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4291da177e4SLinus Torvalds { 4301da177e4SLinus Torvalds .procname = "tainted", 43125ddbb18SAndi Kleen .maxlen = sizeof(long), 43234f5a398STheodore Ts'o .mode = 0644, 4336d456111SEric W. Biederman .proc_handler = proc_taint, 4341da177e4SLinus Torvalds }, 43534f5a398STheodore Ts'o #endif 4369745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4379745512cSArjan van de Ven { 4389745512cSArjan van de Ven .procname = "latencytop", 4399745512cSArjan van de Ven .data = &latencytop_enabled, 4409745512cSArjan van de Ven .maxlen = sizeof(int), 4419745512cSArjan van de Ven .mode = 0644, 4426d456111SEric W. Biederman .proc_handler = proc_dointvec, 4439745512cSArjan van de Ven }, 4449745512cSArjan van de Ven #endif 4451da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4461da177e4SLinus Torvalds { 4471da177e4SLinus Torvalds .procname = "real-root-dev", 4481da177e4SLinus Torvalds .data = &real_root_dev, 4491da177e4SLinus Torvalds .maxlen = sizeof(int), 4501da177e4SLinus Torvalds .mode = 0644, 4516d456111SEric W. Biederman .proc_handler = proc_dointvec, 4521da177e4SLinus Torvalds }, 4531da177e4SLinus Torvalds #endif 45445807a1dSIngo Molnar { 45545807a1dSIngo Molnar .procname = "print-fatal-signals", 45645807a1dSIngo Molnar .data = &print_fatal_signals, 45745807a1dSIngo Molnar .maxlen = sizeof(int), 45845807a1dSIngo Molnar .mode = 0644, 4596d456111SEric W. Biederman .proc_handler = proc_dointvec, 46045807a1dSIngo Molnar }, 46172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4621da177e4SLinus Torvalds { 4631da177e4SLinus Torvalds .procname = "reboot-cmd", 4641da177e4SLinus Torvalds .data = reboot_command, 4651da177e4SLinus Torvalds .maxlen = 256, 4661da177e4SLinus Torvalds .mode = 0644, 4676d456111SEric W. Biederman .proc_handler = proc_dostring, 4681da177e4SLinus Torvalds }, 4691da177e4SLinus Torvalds { 4701da177e4SLinus Torvalds .procname = "stop-a", 4711da177e4SLinus Torvalds .data = &stop_a_enabled, 4721da177e4SLinus Torvalds .maxlen = sizeof (int), 4731da177e4SLinus Torvalds .mode = 0644, 4746d456111SEric W. Biederman .proc_handler = proc_dointvec, 4751da177e4SLinus Torvalds }, 4761da177e4SLinus Torvalds { 4771da177e4SLinus Torvalds .procname = "scons-poweroff", 4781da177e4SLinus Torvalds .data = &scons_pwroff, 4791da177e4SLinus Torvalds .maxlen = sizeof (int), 4801da177e4SLinus Torvalds .mode = 0644, 4816d456111SEric W. Biederman .proc_handler = proc_dointvec, 4821da177e4SLinus Torvalds }, 4831da177e4SLinus Torvalds #endif 4840871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4850871420fSDavid S. Miller { 4860871420fSDavid S. Miller .procname = "tsb-ratio", 4870871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4880871420fSDavid S. Miller .maxlen = sizeof (int), 4890871420fSDavid S. Miller .mode = 0644, 4906d456111SEric W. Biederman .proc_handler = proc_dointvec, 4910871420fSDavid S. Miller }, 4920871420fSDavid S. Miller #endif 4931da177e4SLinus Torvalds #ifdef __hppa__ 4941da177e4SLinus Torvalds { 4951da177e4SLinus Torvalds .procname = "soft-power", 4961da177e4SLinus Torvalds .data = &pwrsw_enabled, 4971da177e4SLinus Torvalds .maxlen = sizeof (int), 4981da177e4SLinus Torvalds .mode = 0644, 4996d456111SEric W. Biederman .proc_handler = proc_dointvec, 5001da177e4SLinus Torvalds }, 5011da177e4SLinus Torvalds { 5021da177e4SLinus Torvalds .procname = "unaligned-trap", 5031da177e4SLinus Torvalds .data = &unaligned_enabled, 5041da177e4SLinus Torvalds .maxlen = sizeof (int), 5051da177e4SLinus Torvalds .mode = 0644, 5066d456111SEric W. Biederman .proc_handler = proc_dointvec, 5071da177e4SLinus Torvalds }, 5081da177e4SLinus Torvalds #endif 5091da177e4SLinus Torvalds { 5101da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5111da177e4SLinus Torvalds .data = &C_A_D, 5121da177e4SLinus Torvalds .maxlen = sizeof(int), 5131da177e4SLinus Torvalds .mode = 0644, 5146d456111SEric W. Biederman .proc_handler = proc_dointvec, 5151da177e4SLinus Torvalds }, 516606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 517b0fc494fSSteven Rostedt { 518b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 519b0fc494fSSteven Rostedt .data = &ftrace_enabled, 520b0fc494fSSteven Rostedt .maxlen = sizeof(int), 521b0fc494fSSteven Rostedt .mode = 0644, 5226d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 523b0fc494fSSteven Rostedt }, 524b0fc494fSSteven Rostedt #endif 525f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 526f38f1d2aSSteven Rostedt { 527f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 528f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 529f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 530f38f1d2aSSteven Rostedt .mode = 0644, 5316d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 532f38f1d2aSSteven Rostedt }, 533f38f1d2aSSteven Rostedt #endif 534944ac425SSteven Rostedt #ifdef CONFIG_TRACING 535944ac425SSteven Rostedt { 5363299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 537944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 538944ac425SSteven Rostedt .maxlen = sizeof(int), 539944ac425SSteven Rostedt .mode = 0644, 5406d456111SEric W. Biederman .proc_handler = proc_dointvec, 541944ac425SSteven Rostedt }, 542944ac425SSteven Rostedt #endif 543a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5441da177e4SLinus Torvalds { 5451da177e4SLinus Torvalds .procname = "modprobe", 5461da177e4SLinus Torvalds .data = &modprobe_path, 5471da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5481da177e4SLinus Torvalds .mode = 0644, 5496d456111SEric W. Biederman .proc_handler = proc_dostring, 5501da177e4SLinus Torvalds }, 5513d43321bSKees Cook { 5523d43321bSKees Cook .procname = "modules_disabled", 5533d43321bSKees Cook .data = &modules_disabled, 5543d43321bSKees Cook .maxlen = sizeof(int), 5553d43321bSKees Cook .mode = 0644, 5563d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5576d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5583d43321bSKees Cook .extra1 = &one, 5593d43321bSKees Cook .extra2 = &one, 5603d43321bSKees Cook }, 5611da177e4SLinus Torvalds #endif 56294f17cd7SIan Abbott #ifdef CONFIG_HOTPLUG 5631da177e4SLinus Torvalds { 5641da177e4SLinus Torvalds .procname = "hotplug", 565312c004dSKay Sievers .data = &uevent_helper, 566312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5671da177e4SLinus Torvalds .mode = 0644, 5686d456111SEric W. Biederman .proc_handler = proc_dostring, 5691da177e4SLinus Torvalds }, 5701da177e4SLinus Torvalds #endif 5711da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5721da177e4SLinus Torvalds { 5731da177e4SLinus Torvalds .procname = "sg-big-buff", 5741da177e4SLinus Torvalds .data = &sg_big_buff, 5751da177e4SLinus Torvalds .maxlen = sizeof (int), 5761da177e4SLinus Torvalds .mode = 0444, 5776d456111SEric W. Biederman .proc_handler = proc_dointvec, 5781da177e4SLinus Torvalds }, 5791da177e4SLinus Torvalds #endif 5801da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5811da177e4SLinus Torvalds { 5821da177e4SLinus Torvalds .procname = "acct", 5831da177e4SLinus Torvalds .data = &acct_parm, 5841da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5851da177e4SLinus Torvalds .mode = 0644, 5866d456111SEric W. Biederman .proc_handler = proc_dointvec, 5871da177e4SLinus Torvalds }, 5881da177e4SLinus Torvalds #endif 5891da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5901da177e4SLinus Torvalds { 5911da177e4SLinus Torvalds .procname = "sysrq", 5925d6f647fSIngo Molnar .data = &__sysrq_enabled, 5931da177e4SLinus Torvalds .maxlen = sizeof (int), 5941da177e4SLinus Torvalds .mode = 0644, 59597f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 5961da177e4SLinus Torvalds }, 5971da177e4SLinus Torvalds #endif 598d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5991da177e4SLinus Torvalds { 6001da177e4SLinus Torvalds .procname = "cad_pid", 6019ec52099SCedric Le Goater .data = NULL, 6021da177e4SLinus Torvalds .maxlen = sizeof (int), 6031da177e4SLinus Torvalds .mode = 0600, 6046d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 6051da177e4SLinus Torvalds }, 606d6f8ff73SRandy Dunlap #endif 6071da177e4SLinus Torvalds { 6081da177e4SLinus Torvalds .procname = "threads-max", 6091da177e4SLinus Torvalds .data = &max_threads, 6101da177e4SLinus Torvalds .maxlen = sizeof(int), 6111da177e4SLinus Torvalds .mode = 0644, 6126d456111SEric W. Biederman .proc_handler = proc_dointvec, 6131da177e4SLinus Torvalds }, 6141da177e4SLinus Torvalds { 6151da177e4SLinus Torvalds .procname = "random", 6161da177e4SLinus Torvalds .mode = 0555, 6171da177e4SLinus Torvalds .child = random_table, 6181da177e4SLinus Torvalds }, 6191da177e4SLinus Torvalds { 62017f60a7dSEric Paris .procname = "usermodehelper", 62117f60a7dSEric Paris .mode = 0555, 62217f60a7dSEric Paris .child = usermodehelper_table, 62317f60a7dSEric Paris }, 62417f60a7dSEric Paris { 6251da177e4SLinus Torvalds .procname = "overflowuid", 6261da177e4SLinus Torvalds .data = &overflowuid, 6271da177e4SLinus Torvalds .maxlen = sizeof(int), 6281da177e4SLinus Torvalds .mode = 0644, 6296d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6301da177e4SLinus Torvalds .extra1 = &minolduid, 6311da177e4SLinus Torvalds .extra2 = &maxolduid, 6321da177e4SLinus Torvalds }, 6331da177e4SLinus Torvalds { 6341da177e4SLinus Torvalds .procname = "overflowgid", 6351da177e4SLinus Torvalds .data = &overflowgid, 6361da177e4SLinus Torvalds .maxlen = sizeof(int), 6371da177e4SLinus Torvalds .mode = 0644, 6386d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6391da177e4SLinus Torvalds .extra1 = &minolduid, 6401da177e4SLinus Torvalds .extra2 = &maxolduid, 6411da177e4SLinus Torvalds }, 642347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6431da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6441da177e4SLinus Torvalds { 6451da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6461da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6471da177e4SLinus Torvalds .maxlen = sizeof(int), 6481da177e4SLinus Torvalds .mode = 0644, 6496d456111SEric W. Biederman .proc_handler = proc_dointvec, 6501da177e4SLinus Torvalds }, 6511da177e4SLinus Torvalds #endif 6521da177e4SLinus Torvalds { 6531da177e4SLinus Torvalds .procname = "userprocess_debug", 654ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 6551da177e4SLinus Torvalds .maxlen = sizeof(int), 6561da177e4SLinus Torvalds .mode = 0644, 6576d456111SEric W. Biederman .proc_handler = proc_dointvec, 6581da177e4SLinus Torvalds }, 6591da177e4SLinus Torvalds #endif 6601da177e4SLinus Torvalds { 6611da177e4SLinus Torvalds .procname = "pid_max", 6621da177e4SLinus Torvalds .data = &pid_max, 6631da177e4SLinus Torvalds .maxlen = sizeof (int), 6641da177e4SLinus Torvalds .mode = 0644, 6656d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6661da177e4SLinus Torvalds .extra1 = &pid_max_min, 6671da177e4SLinus Torvalds .extra2 = &pid_max_max, 6681da177e4SLinus Torvalds }, 6691da177e4SLinus Torvalds { 6701da177e4SLinus Torvalds .procname = "panic_on_oops", 6711da177e4SLinus Torvalds .data = &panic_on_oops, 6721da177e4SLinus Torvalds .maxlen = sizeof(int), 6731da177e4SLinus Torvalds .mode = 0644, 6746d456111SEric W. Biederman .proc_handler = proc_dointvec, 6751da177e4SLinus Torvalds }, 6767ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6777ef3d2fdSJoe Perches { 6787ef3d2fdSJoe Perches .procname = "printk", 6797ef3d2fdSJoe Perches .data = &console_loglevel, 6807ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6817ef3d2fdSJoe Perches .mode = 0644, 6826d456111SEric W. Biederman .proc_handler = proc_dointvec, 6837ef3d2fdSJoe Perches }, 6841da177e4SLinus Torvalds { 6851da177e4SLinus Torvalds .procname = "printk_ratelimit", 686717115e1SDave Young .data = &printk_ratelimit_state.interval, 6871da177e4SLinus Torvalds .maxlen = sizeof(int), 6881da177e4SLinus Torvalds .mode = 0644, 6896d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6901da177e4SLinus Torvalds }, 6911da177e4SLinus Torvalds { 6921da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 693717115e1SDave Young .data = &printk_ratelimit_state.burst, 6941da177e4SLinus Torvalds .maxlen = sizeof(int), 6951da177e4SLinus Torvalds .mode = 0644, 6966d456111SEric W. Biederman .proc_handler = proc_dointvec, 6971da177e4SLinus Torvalds }, 698af91322eSDave Young { 699af91322eSDave Young .procname = "printk_delay", 700af91322eSDave Young .data = &printk_delay_msec, 701af91322eSDave Young .maxlen = sizeof(int), 702af91322eSDave Young .mode = 0644, 7036d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 704af91322eSDave Young .extra1 = &zero, 705af91322eSDave Young .extra2 = &ten_thousand, 706af91322eSDave Young }, 7071da177e4SLinus Torvalds { 708eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 709eaf06b24SDan Rosenberg .data = &dmesg_restrict, 710eaf06b24SDan Rosenberg .maxlen = sizeof(int), 711eaf06b24SDan Rosenberg .mode = 0644, 712eaf06b24SDan Rosenberg .proc_handler = proc_dointvec_minmax, 713eaf06b24SDan Rosenberg .extra1 = &zero, 714eaf06b24SDan Rosenberg .extra2 = &one, 715eaf06b24SDan Rosenberg }, 716455cd5abSDan Rosenberg { 717455cd5abSDan Rosenberg .procname = "kptr_restrict", 718455cd5abSDan Rosenberg .data = &kptr_restrict, 719455cd5abSDan Rosenberg .maxlen = sizeof(int), 720455cd5abSDan Rosenberg .mode = 0644, 721bfdc0b49SRichard Weinberger .proc_handler = proc_dmesg_restrict, 722455cd5abSDan Rosenberg .extra1 = &zero, 723455cd5abSDan Rosenberg .extra2 = &two, 724455cd5abSDan Rosenberg }, 725df6e61d4SJoe Perches #endif 726eaf06b24SDan Rosenberg { 7271da177e4SLinus Torvalds .procname = "ngroups_max", 7281da177e4SLinus Torvalds .data = &ngroups_max, 7291da177e4SLinus Torvalds .maxlen = sizeof (int), 7301da177e4SLinus Torvalds .mode = 0444, 7316d456111SEric W. Biederman .proc_handler = proc_dointvec, 7321da177e4SLinus Torvalds }, 73358687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 734504d7cf1SDon Zickus { 73558687acbSDon Zickus .procname = "watchdog", 73658687acbSDon Zickus .data = &watchdog_enabled, 737504d7cf1SDon Zickus .maxlen = sizeof (int), 738504d7cf1SDon Zickus .mode = 0644, 739586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 740586692a5SMandeep Singh Baines .extra1 = &zero, 741586692a5SMandeep Singh Baines .extra2 = &one, 74258687acbSDon Zickus }, 74358687acbSDon Zickus { 74458687acbSDon Zickus .procname = "watchdog_thresh", 745586692a5SMandeep Singh Baines .data = &watchdog_thresh, 74658687acbSDon Zickus .maxlen = sizeof(int), 74758687acbSDon Zickus .mode = 0644, 748586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 74958687acbSDon Zickus .extra1 = &neg_one, 75058687acbSDon Zickus .extra2 = &sixty, 751504d7cf1SDon Zickus }, 7522508ce18SDon Zickus { 7532508ce18SDon Zickus .procname = "softlockup_panic", 7542508ce18SDon Zickus .data = &softlockup_panic, 7552508ce18SDon Zickus .maxlen = sizeof(int), 7562508ce18SDon Zickus .mode = 0644, 7572508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 7582508ce18SDon Zickus .extra1 = &zero, 7592508ce18SDon Zickus .extra2 = &one, 7602508ce18SDon Zickus }, 7615dc30558SDon Zickus { 7625dc30558SDon Zickus .procname = "nmi_watchdog", 7635dc30558SDon Zickus .data = &watchdog_enabled, 7645dc30558SDon Zickus .maxlen = sizeof (int), 7655dc30558SDon Zickus .mode = 0644, 766586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 767586692a5SMandeep Singh Baines .extra1 = &zero, 768586692a5SMandeep Singh Baines .extra2 = &one, 7695dc30558SDon Zickus }, 7705dc30558SDon Zickus #endif 7715dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7725dc30558SDon Zickus { 7735dc30558SDon Zickus .procname = "unknown_nmi_panic", 7745dc30558SDon Zickus .data = &unknown_nmi_panic, 7755dc30558SDon Zickus .maxlen = sizeof (int), 7765dc30558SDon Zickus .mode = 0644, 7775dc30558SDon Zickus .proc_handler = proc_dointvec, 7785dc30558SDon Zickus }, 779504d7cf1SDon Zickus #endif 7801da177e4SLinus Torvalds #if defined(CONFIG_X86) 7811da177e4SLinus Torvalds { 7828da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7838da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7848da5addaSDon Zickus .maxlen = sizeof(int), 7858da5addaSDon Zickus .mode = 0644, 7866d456111SEric W. Biederman .proc_handler = proc_dointvec, 7878da5addaSDon Zickus }, 7888da5addaSDon Zickus { 7895211a242SKurt Garloff .procname = "panic_on_io_nmi", 7905211a242SKurt Garloff .data = &panic_on_io_nmi, 7915211a242SKurt Garloff .maxlen = sizeof(int), 7925211a242SKurt Garloff .mode = 0644, 7936d456111SEric W. Biederman .proc_handler = proc_dointvec, 7945211a242SKurt Garloff }, 7955211a242SKurt Garloff { 7961da177e4SLinus Torvalds .procname = "bootloader_type", 7971da177e4SLinus Torvalds .data = &bootloader_type, 7981da177e4SLinus Torvalds .maxlen = sizeof (int), 7991da177e4SLinus Torvalds .mode = 0444, 8006d456111SEric W. Biederman .proc_handler = proc_dointvec, 8011da177e4SLinus Torvalds }, 8020741f4d2SChuck Ebbert { 8035031296cSH. Peter Anvin .procname = "bootloader_version", 8045031296cSH. Peter Anvin .data = &bootloader_version, 8055031296cSH. Peter Anvin .maxlen = sizeof (int), 8065031296cSH. Peter Anvin .mode = 0444, 8076d456111SEric W. Biederman .proc_handler = proc_dointvec, 8085031296cSH. Peter Anvin }, 8095031296cSH. Peter Anvin { 8100741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 8110741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 8120741f4d2SChuck Ebbert .maxlen = sizeof(int), 8130741f4d2SChuck Ebbert .mode = 0644, 8146d456111SEric W. Biederman .proc_handler = proc_dointvec, 8150741f4d2SChuck Ebbert }, 8166e7c4025SIngo Molnar { 8176e7c4025SIngo Molnar .procname = "io_delay_type", 8186e7c4025SIngo Molnar .data = &io_delay_type, 8196e7c4025SIngo Molnar .maxlen = sizeof(int), 8206e7c4025SIngo Molnar .mode = 0644, 8216d456111SEric W. Biederman .proc_handler = proc_dointvec, 8226e7c4025SIngo Molnar }, 8231da177e4SLinus Torvalds #endif 8247a9166e3SLuke Yang #if defined(CONFIG_MMU) 8251da177e4SLinus Torvalds { 8261da177e4SLinus Torvalds .procname = "randomize_va_space", 8271da177e4SLinus Torvalds .data = &randomize_va_space, 8281da177e4SLinus Torvalds .maxlen = sizeof(int), 8291da177e4SLinus Torvalds .mode = 0644, 8306d456111SEric W. Biederman .proc_handler = proc_dointvec, 8311da177e4SLinus Torvalds }, 8327a9166e3SLuke Yang #endif 8330152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 834951f22d5SMartin Schwidefsky { 835951f22d5SMartin Schwidefsky .procname = "spin_retry", 836951f22d5SMartin Schwidefsky .data = &spin_retry, 837951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 838951f22d5SMartin Schwidefsky .mode = 0644, 8396d456111SEric W. Biederman .proc_handler = proc_dointvec, 840951f22d5SMartin Schwidefsky }, 841951f22d5SMartin Schwidefsky #endif 842673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 843c255d844SPavel Machek { 844c255d844SPavel Machek .procname = "acpi_video_flags", 84577afcf78SPavel Machek .data = &acpi_realmode_flags, 846c255d844SPavel Machek .maxlen = sizeof (unsigned long), 847c255d844SPavel Machek .mode = 0644, 8486d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 849c255d844SPavel Machek }, 850c255d844SPavel Machek #endif 851d2b176edSJes Sorensen #ifdef CONFIG_IA64 852d2b176edSJes Sorensen { 853d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 854d2b176edSJes Sorensen .data = &no_unaligned_warning, 855d2b176edSJes Sorensen .maxlen = sizeof (int), 856d2b176edSJes Sorensen .mode = 0644, 8576d456111SEric W. Biederman .proc_handler = proc_dointvec, 858d2b176edSJes Sorensen }, 85988fc241fSDoug Chapman { 86088fc241fSDoug Chapman .procname = "unaligned-dump-stack", 86188fc241fSDoug Chapman .data = &unaligned_dump_stack, 86288fc241fSDoug Chapman .maxlen = sizeof (int), 86388fc241fSDoug Chapman .mode = 0644, 8646d456111SEric W. Biederman .proc_handler = proc_dointvec, 86588fc241fSDoug Chapman }, 866d2b176edSJes Sorensen #endif 867e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 868e162b39aSMandeep Singh Baines { 869e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 870e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 871e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 872e162b39aSMandeep Singh Baines .mode = 0644, 8736d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 874e162b39aSMandeep Singh Baines .extra1 = &zero, 875e162b39aSMandeep Singh Baines .extra2 = &one, 876e162b39aSMandeep Singh Baines }, 87782a1fcb9SIngo Molnar { 87882a1fcb9SIngo Molnar .procname = "hung_task_check_count", 87982a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 88090739081SIngo Molnar .maxlen = sizeof(unsigned long), 88182a1fcb9SIngo Molnar .mode = 0644, 8826d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 88382a1fcb9SIngo Molnar }, 88482a1fcb9SIngo Molnar { 88582a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 88682a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 88790739081SIngo Molnar .maxlen = sizeof(unsigned long), 88882a1fcb9SIngo Molnar .mode = 0644, 8896d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 89082a1fcb9SIngo Molnar }, 89182a1fcb9SIngo Molnar { 89282a1fcb9SIngo Molnar .procname = "hung_task_warnings", 89382a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 89490739081SIngo Molnar .maxlen = sizeof(unsigned long), 89582a1fcb9SIngo Molnar .mode = 0644, 8966d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 89782a1fcb9SIngo Molnar }, 898c4f3b63fSRavikiran G Thirumalai #endif 899bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 900bebfa101SAndi Kleen { 901bebfa101SAndi Kleen .procname = "compat-log", 902bebfa101SAndi Kleen .data = &compat_log, 903bebfa101SAndi Kleen .maxlen = sizeof (int), 904bebfa101SAndi Kleen .mode = 0644, 9056d456111SEric W. Biederman .proc_handler = proc_dointvec, 906bebfa101SAndi Kleen }, 907bebfa101SAndi Kleen #endif 90823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 90923f78d4aSIngo Molnar { 91023f78d4aSIngo Molnar .procname = "max_lock_depth", 91123f78d4aSIngo Molnar .data = &max_lock_depth, 91223f78d4aSIngo Molnar .maxlen = sizeof(int), 91323f78d4aSIngo Molnar .mode = 0644, 9146d456111SEric W. Biederman .proc_handler = proc_dointvec, 91523f78d4aSIngo Molnar }, 91623f78d4aSIngo Molnar #endif 91710a0a8d4SJeremy Fitzhardinge { 91810a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 91910a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 92010a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 92110a0a8d4SJeremy Fitzhardinge .mode = 0644, 9226d456111SEric W. Biederman .proc_handler = proc_dostring, 92310a0a8d4SJeremy Fitzhardinge }, 9240b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9250b77f5bfSDavid Howells { 9260b77f5bfSDavid Howells .procname = "keys", 9270b77f5bfSDavid Howells .mode = 0555, 9280b77f5bfSDavid Howells .child = key_sysctls, 9290b77f5bfSDavid Howells }, 9300b77f5bfSDavid Howells #endif 93131a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 93231a72bceSPaul E. McKenney { 93331a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 93431a72bceSPaul E. McKenney .data = &rcutorture_runnable, 93531a72bceSPaul E. McKenney .maxlen = sizeof(int), 93631a72bceSPaul E. McKenney .mode = 0644, 9376d456111SEric W. Biederman .proc_handler = proc_dointvec, 93831a72bceSPaul E. McKenney }, 93931a72bceSPaul E. McKenney #endif 940cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 941*aa4a2218SVince Weaver /* 942*aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 943*aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 944*aa4a2218SVince Weaver * 945*aa4a2218SVince Weaver * So it's an ABI, do not remove! 946*aa4a2218SVince Weaver */ 9471ccd1549SPeter Zijlstra { 948cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 949cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 950cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9511ccd1549SPeter Zijlstra .mode = 0644, 9526d456111SEric W. Biederman .proc_handler = proc_dointvec, 9531ccd1549SPeter Zijlstra }, 954c5078f78SPeter Zijlstra { 955cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 956cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 957cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 958c5078f78SPeter Zijlstra .mode = 0644, 9596d456111SEric W. Biederman .proc_handler = proc_dointvec, 960c5078f78SPeter Zijlstra }, 961a78ac325SPeter Zijlstra { 962cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 963cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 964cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 965a78ac325SPeter Zijlstra .mode = 0644, 966163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 967a78ac325SPeter Zijlstra }, 9681ccd1549SPeter Zijlstra #endif 969dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 970dfec072eSVegard Nossum { 971dfec072eSVegard Nossum .procname = "kmemcheck", 972dfec072eSVegard Nossum .data = &kmemcheck_enabled, 973dfec072eSVegard Nossum .maxlen = sizeof(int), 974dfec072eSVegard Nossum .mode = 0644, 9756d456111SEric W. Biederman .proc_handler = proc_dointvec, 976dfec072eSVegard Nossum }, 977dfec072eSVegard Nossum #endif 978cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9795e605b64SJens Axboe { 9805e605b64SJens Axboe .procname = "blk_iopoll", 9815e605b64SJens Axboe .data = &blk_iopoll_enabled, 9825e605b64SJens Axboe .maxlen = sizeof(int), 9835e605b64SJens Axboe .mode = 0644, 9846d456111SEric W. Biederman .proc_handler = proc_dointvec, 9855e605b64SJens Axboe }, 986cb684b5bSJens Axboe #endif 9876fce56ecSEric W. Biederman { } 9881da177e4SLinus Torvalds }; 9891da177e4SLinus Torvalds 990d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 9911da177e4SLinus Torvalds { 9921da177e4SLinus Torvalds .procname = "overcommit_memory", 9931da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 9941da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 9951da177e4SLinus Torvalds .mode = 0644, 996cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 997cb16e95fSPetr Holasek .extra1 = &zero, 998cb16e95fSPetr Holasek .extra2 = &two, 9991da177e4SLinus Torvalds }, 10001da177e4SLinus Torvalds { 1001fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1002fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1003fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1004fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1005cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1006cb16e95fSPetr Holasek .extra1 = &zero, 1007cb16e95fSPetr Holasek .extra2 = &two, 1008fadd8fbdSKAMEZAWA Hiroyuki }, 1009fadd8fbdSKAMEZAWA Hiroyuki { 1010fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1011fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1012fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1013fe071d7eSDavid Rientjes .mode = 0644, 10146d456111SEric W. Biederman .proc_handler = proc_dointvec, 1015fe071d7eSDavid Rientjes }, 1016fe071d7eSDavid Rientjes { 1017fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1018fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1019fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1020fef1bdd6SDavid Rientjes .mode = 0644, 10216d456111SEric W. Biederman .proc_handler = proc_dointvec, 1022fef1bdd6SDavid Rientjes }, 1023fef1bdd6SDavid Rientjes { 10241da177e4SLinus Torvalds .procname = "overcommit_ratio", 10251da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10261da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10271da177e4SLinus Torvalds .mode = 0644, 10286d456111SEric W. Biederman .proc_handler = proc_dointvec, 10291da177e4SLinus Torvalds }, 10301da177e4SLinus Torvalds { 10311da177e4SLinus Torvalds .procname = "page-cluster", 10321da177e4SLinus Torvalds .data = &page_cluster, 10331da177e4SLinus Torvalds .maxlen = sizeof(int), 10341da177e4SLinus Torvalds .mode = 0644, 1035cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1036cb16e95fSPetr Holasek .extra1 = &zero, 10371da177e4SLinus Torvalds }, 10381da177e4SLinus Torvalds { 10391da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10401da177e4SLinus Torvalds .data = &dirty_background_ratio, 10411da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10421da177e4SLinus Torvalds .mode = 0644, 10436d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 10441da177e4SLinus Torvalds .extra1 = &zero, 10451da177e4SLinus Torvalds .extra2 = &one_hundred, 10461da177e4SLinus Torvalds }, 10471da177e4SLinus Torvalds { 10482da02997SDavid Rientjes .procname = "dirty_background_bytes", 10492da02997SDavid Rientjes .data = &dirty_background_bytes, 10502da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10512da02997SDavid Rientjes .mode = 0644, 10526d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1053fc3501d4SSven Wegener .extra1 = &one_ul, 10542da02997SDavid Rientjes }, 10552da02997SDavid Rientjes { 10561da177e4SLinus Torvalds .procname = "dirty_ratio", 10571da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10581da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10591da177e4SLinus Torvalds .mode = 0644, 10606d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10611da177e4SLinus Torvalds .extra1 = &zero, 10621da177e4SLinus Torvalds .extra2 = &one_hundred, 10631da177e4SLinus Torvalds }, 10641da177e4SLinus Torvalds { 10652da02997SDavid Rientjes .procname = "dirty_bytes", 10662da02997SDavid Rientjes .data = &vm_dirty_bytes, 10672da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10682da02997SDavid Rientjes .mode = 0644, 10696d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10709e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10712da02997SDavid Rientjes }, 10722da02997SDavid Rientjes { 10731da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1074f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1075f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10761da177e4SLinus Torvalds .mode = 0644, 10776d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10781da177e4SLinus Torvalds }, 10791da177e4SLinus Torvalds { 10801da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1081f6ef9438SBart Samwel .data = &dirty_expire_interval, 1082f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10831da177e4SLinus Torvalds .mode = 0644, 1084cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1085cb16e95fSPetr Holasek .extra1 = &zero, 10861da177e4SLinus Torvalds }, 10871da177e4SLinus Torvalds { 10881da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10891da177e4SLinus Torvalds .data = &nr_pdflush_threads, 10901da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 10911da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 10926d456111SEric W. Biederman .proc_handler = proc_dointvec, 10931da177e4SLinus Torvalds }, 10941da177e4SLinus Torvalds { 10951da177e4SLinus Torvalds .procname = "swappiness", 10961da177e4SLinus Torvalds .data = &vm_swappiness, 10971da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 10981da177e4SLinus Torvalds .mode = 0644, 10996d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 11001da177e4SLinus Torvalds .extra1 = &zero, 11011da177e4SLinus Torvalds .extra2 = &one_hundred, 11021da177e4SLinus Torvalds }, 11031da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11041da177e4SLinus Torvalds { 11051da177e4SLinus Torvalds .procname = "nr_hugepages", 1106e5ff2159SAndi Kleen .data = NULL, 11071da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11081da177e4SLinus Torvalds .mode = 0644, 11096d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 11101da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11111da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11121da177e4SLinus Torvalds }, 111306808b08SLee Schermerhorn #ifdef CONFIG_NUMA 111406808b08SLee Schermerhorn { 111506808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 111606808b08SLee Schermerhorn .data = NULL, 111706808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 111806808b08SLee Schermerhorn .mode = 0644, 111906808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 112006808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 112106808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 112206808b08SLee Schermerhorn }, 112306808b08SLee Schermerhorn #endif 11241da177e4SLinus Torvalds { 11251da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11261da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11271da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11281da177e4SLinus Torvalds .mode = 0644, 11296d456111SEric W. Biederman .proc_handler = proc_dointvec, 11301da177e4SLinus Torvalds }, 1131396faf03SMel Gorman { 1132396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1133396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1134396faf03SMel Gorman .maxlen = sizeof(int), 1135396faf03SMel Gorman .mode = 0644, 11366d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1137396faf03SMel Gorman }, 113854f9f80dSAdam Litke { 1139d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1140e5ff2159SAndi Kleen .data = NULL, 1141e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1142d1c3fb1fSNishanth Aravamudan .mode = 0644, 11436d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1144e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1145e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1146d1c3fb1fSNishanth Aravamudan }, 11471da177e4SLinus Torvalds #endif 11481da177e4SLinus Torvalds { 11491da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11501da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11511da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11521da177e4SLinus Torvalds .mode = 0644, 11536d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11541da177e4SLinus Torvalds }, 11551da177e4SLinus Torvalds { 11569d0243bcSAndrew Morton .procname = "drop_caches", 11579d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11589d0243bcSAndrew Morton .maxlen = sizeof(int), 11599d0243bcSAndrew Morton .mode = 0644, 11609d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 1161cb16e95fSPetr Holasek .extra1 = &one, 1162cb16e95fSPetr Holasek .extra2 = &three, 11639d0243bcSAndrew Morton }, 116476ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 116576ab0f53SMel Gorman { 116676ab0f53SMel Gorman .procname = "compact_memory", 116776ab0f53SMel Gorman .data = &sysctl_compact_memory, 116876ab0f53SMel Gorman .maxlen = sizeof(int), 116976ab0f53SMel Gorman .mode = 0200, 117076ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 117176ab0f53SMel Gorman }, 11725e771905SMel Gorman { 11735e771905SMel Gorman .procname = "extfrag_threshold", 11745e771905SMel Gorman .data = &sysctl_extfrag_threshold, 11755e771905SMel Gorman .maxlen = sizeof(int), 11765e771905SMel Gorman .mode = 0644, 11775e771905SMel Gorman .proc_handler = sysctl_extfrag_handler, 11785e771905SMel Gorman .extra1 = &min_extfrag_threshold, 11795e771905SMel Gorman .extra2 = &max_extfrag_threshold, 11805e771905SMel Gorman }, 11815e771905SMel Gorman 118276ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 11839d0243bcSAndrew Morton { 11841da177e4SLinus Torvalds .procname = "min_free_kbytes", 11851da177e4SLinus Torvalds .data = &min_free_kbytes, 11861da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11871da177e4SLinus Torvalds .mode = 0644, 11886d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 11891da177e4SLinus Torvalds .extra1 = &zero, 11901da177e4SLinus Torvalds }, 11918ad4b1fbSRohit Seth { 11928ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 11938ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 11948ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 11958ad4b1fbSRohit Seth .mode = 0644, 11966d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 11978ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 11988ad4b1fbSRohit Seth }, 11991da177e4SLinus Torvalds #ifdef CONFIG_MMU 12001da177e4SLinus Torvalds { 12011da177e4SLinus Torvalds .procname = "max_map_count", 12021da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12031da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12041da177e4SLinus Torvalds .mode = 0644, 12053e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 120670da2340SAmerigo Wang .extra1 = &zero, 12071da177e4SLinus Torvalds }, 1208dd8632a1SPaul Mundt #else 1209dd8632a1SPaul Mundt { 1210dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1211dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1212dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1213dd8632a1SPaul Mundt .mode = 0644, 12146d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1215dd8632a1SPaul Mundt .extra1 = &zero, 1216dd8632a1SPaul Mundt }, 12171da177e4SLinus Torvalds #endif 12181da177e4SLinus Torvalds { 12191da177e4SLinus Torvalds .procname = "laptop_mode", 12201da177e4SLinus Torvalds .data = &laptop_mode, 12211da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12221da177e4SLinus Torvalds .mode = 0644, 12236d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 12241da177e4SLinus Torvalds }, 12251da177e4SLinus Torvalds { 12261da177e4SLinus Torvalds .procname = "block_dump", 12271da177e4SLinus Torvalds .data = &block_dump, 12281da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12291da177e4SLinus Torvalds .mode = 0644, 12306d456111SEric W. Biederman .proc_handler = proc_dointvec, 12311da177e4SLinus Torvalds .extra1 = &zero, 12321da177e4SLinus Torvalds }, 12331da177e4SLinus Torvalds { 12341da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12351da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12361da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12371da177e4SLinus Torvalds .mode = 0644, 12386d456111SEric W. Biederman .proc_handler = proc_dointvec, 12391da177e4SLinus Torvalds .extra1 = &zero, 12401da177e4SLinus Torvalds }, 12411da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12421da177e4SLinus Torvalds { 12431da177e4SLinus Torvalds .procname = "legacy_va_layout", 12441da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12451da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12461da177e4SLinus Torvalds .mode = 0644, 12476d456111SEric W. Biederman .proc_handler = proc_dointvec, 12481da177e4SLinus Torvalds .extra1 = &zero, 12491da177e4SLinus Torvalds }, 12501da177e4SLinus Torvalds #endif 12511743660bSChristoph Lameter #ifdef CONFIG_NUMA 12521743660bSChristoph Lameter { 12531743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12541743660bSChristoph Lameter .data = &zone_reclaim_mode, 12551743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12561743660bSChristoph Lameter .mode = 0644, 12576d456111SEric W. Biederman .proc_handler = proc_dointvec, 1258c84db23cSChristoph Lameter .extra1 = &zero, 12591743660bSChristoph Lameter }, 12609614634fSChristoph Lameter { 12619614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12629614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12639614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12649614634fSChristoph Lameter .mode = 0644, 12656d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 12669614634fSChristoph Lameter .extra1 = &zero, 12679614634fSChristoph Lameter .extra2 = &one_hundred, 12689614634fSChristoph Lameter }, 12690ff38490SChristoph Lameter { 12700ff38490SChristoph Lameter .procname = "min_slab_ratio", 12710ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12720ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12730ff38490SChristoph Lameter .mode = 0644, 12746d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12750ff38490SChristoph Lameter .extra1 = &zero, 12760ff38490SChristoph Lameter .extra2 = &one_hundred, 12770ff38490SChristoph Lameter }, 12781743660bSChristoph Lameter #endif 127977461ab3SChristoph Lameter #ifdef CONFIG_SMP 128077461ab3SChristoph Lameter { 128177461ab3SChristoph Lameter .procname = "stat_interval", 128277461ab3SChristoph Lameter .data = &sysctl_stat_interval, 128377461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 128477461ab3SChristoph Lameter .mode = 0644, 12856d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 128677461ab3SChristoph Lameter }, 128777461ab3SChristoph Lameter #endif 12886e141546SDavid Howells #ifdef CONFIG_MMU 1289ed032189SEric Paris { 1290ed032189SEric Paris .procname = "mmap_min_addr", 1291788084abSEric Paris .data = &dac_mmap_min_addr, 1292ed032189SEric Paris .maxlen = sizeof(unsigned long), 1293ed032189SEric Paris .mode = 0644, 12946d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1295ed032189SEric Paris }, 12966e141546SDavid Howells #endif 1297f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1298f0c0b2b8SKAMEZAWA Hiroyuki { 1299f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1300f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1301f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1302f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 13036d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1304f0c0b2b8SKAMEZAWA Hiroyuki }, 1305f0c0b2b8SKAMEZAWA Hiroyuki #endif 13062b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13075c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1308e6e5494cSIngo Molnar { 1309e6e5494cSIngo Molnar .procname = "vdso_enabled", 1310e6e5494cSIngo Molnar .data = &vdso_enabled, 1311e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1312e6e5494cSIngo Molnar .mode = 0644, 13136d456111SEric W. Biederman .proc_handler = proc_dointvec, 1314e6e5494cSIngo Molnar .extra1 = &zero, 1315e6e5494cSIngo Molnar }, 1316e6e5494cSIngo Molnar #endif 1317195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1318195cf453SBron Gondwana { 1319195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1320195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1321195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1322195cf453SBron Gondwana .mode = 0644, 13236d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1324195cf453SBron Gondwana .extra1 = &zero, 1325195cf453SBron Gondwana .extra2 = &one, 1326195cf453SBron Gondwana }, 1327195cf453SBron Gondwana #endif 13284be6f6bbSPeter Zijlstra { 13294be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13304be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13314be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13324be6f6bbSPeter Zijlstra .mode = 0644, 13336d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 13344be6f6bbSPeter Zijlstra }, 13356a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 13366a46079cSAndi Kleen { 13376a46079cSAndi Kleen .procname = "memory_failure_early_kill", 13386a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 13396a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 13406a46079cSAndi Kleen .mode = 0644, 13416d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13426a46079cSAndi Kleen .extra1 = &zero, 13436a46079cSAndi Kleen .extra2 = &one, 13446a46079cSAndi Kleen }, 13456a46079cSAndi Kleen { 13466a46079cSAndi Kleen .procname = "memory_failure_recovery", 13476a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 13486a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 13496a46079cSAndi Kleen .mode = 0644, 13506d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13516a46079cSAndi Kleen .extra1 = &zero, 13526a46079cSAndi Kleen .extra2 = &one, 13536a46079cSAndi Kleen }, 13546a46079cSAndi Kleen #endif 13556fce56ecSEric W. Biederman { } 13561da177e4SLinus Torvalds }; 13571da177e4SLinus Torvalds 13582abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1359d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13606fce56ecSEric W. Biederman { } 13612abc26fcSEric W. Biederman }; 13622abc26fcSEric W. Biederman #endif 13632abc26fcSEric W. Biederman 1364d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13651da177e4SLinus Torvalds { 13661da177e4SLinus Torvalds .procname = "inode-nr", 13671da177e4SLinus Torvalds .data = &inodes_stat, 13681da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13691da177e4SLinus Torvalds .mode = 0444, 1370cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13711da177e4SLinus Torvalds }, 13721da177e4SLinus Torvalds { 13731da177e4SLinus Torvalds .procname = "inode-state", 13741da177e4SLinus Torvalds .data = &inodes_stat, 13751da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13761da177e4SLinus Torvalds .mode = 0444, 1377cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13781da177e4SLinus Torvalds }, 13791da177e4SLinus Torvalds { 13801da177e4SLinus Torvalds .procname = "file-nr", 13811da177e4SLinus Torvalds .data = &files_stat, 1382518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 13831da177e4SLinus Torvalds .mode = 0444, 13846d456111SEric W. Biederman .proc_handler = proc_nr_files, 13851da177e4SLinus Torvalds }, 13861da177e4SLinus Torvalds { 13871da177e4SLinus Torvalds .procname = "file-max", 13881da177e4SLinus Torvalds .data = &files_stat.max_files, 1389518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 13901da177e4SLinus Torvalds .mode = 0644, 1391518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 13921da177e4SLinus Torvalds }, 13931da177e4SLinus Torvalds { 13949cfe015aSEric Dumazet .procname = "nr_open", 13959cfe015aSEric Dumazet .data = &sysctl_nr_open, 13969cfe015aSEric Dumazet .maxlen = sizeof(int), 13979cfe015aSEric Dumazet .mode = 0644, 13986d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1399eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1400eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14019cfe015aSEric Dumazet }, 14029cfe015aSEric Dumazet { 14031da177e4SLinus Torvalds .procname = "dentry-state", 14041da177e4SLinus Torvalds .data = &dentry_stat, 14051da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14061da177e4SLinus Torvalds .mode = 0444, 1407312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 14081da177e4SLinus Torvalds }, 14091da177e4SLinus Torvalds { 14101da177e4SLinus Torvalds .procname = "overflowuid", 14111da177e4SLinus Torvalds .data = &fs_overflowuid, 14121da177e4SLinus Torvalds .maxlen = sizeof(int), 14131da177e4SLinus Torvalds .mode = 0644, 14146d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14151da177e4SLinus Torvalds .extra1 = &minolduid, 14161da177e4SLinus Torvalds .extra2 = &maxolduid, 14171da177e4SLinus Torvalds }, 14181da177e4SLinus Torvalds { 14191da177e4SLinus Torvalds .procname = "overflowgid", 14201da177e4SLinus Torvalds .data = &fs_overflowgid, 14211da177e4SLinus Torvalds .maxlen = sizeof(int), 14221da177e4SLinus Torvalds .mode = 0644, 14236d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14241da177e4SLinus Torvalds .extra1 = &minolduid, 14251da177e4SLinus Torvalds .extra2 = &maxolduid, 14261da177e4SLinus Torvalds }, 1427bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14281da177e4SLinus Torvalds { 14291da177e4SLinus Torvalds .procname = "leases-enable", 14301da177e4SLinus Torvalds .data = &leases_enable, 14311da177e4SLinus Torvalds .maxlen = sizeof(int), 14321da177e4SLinus Torvalds .mode = 0644, 14336d456111SEric W. Biederman .proc_handler = proc_dointvec, 14341da177e4SLinus Torvalds }, 1435bfcd17a6SThomas Petazzoni #endif 14361da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14371da177e4SLinus Torvalds { 14381da177e4SLinus Torvalds .procname = "dir-notify-enable", 14391da177e4SLinus Torvalds .data = &dir_notify_enable, 14401da177e4SLinus Torvalds .maxlen = sizeof(int), 14411da177e4SLinus Torvalds .mode = 0644, 14426d456111SEric W. Biederman .proc_handler = proc_dointvec, 14431da177e4SLinus Torvalds }, 14441da177e4SLinus Torvalds #endif 14451da177e4SLinus Torvalds #ifdef CONFIG_MMU 1446bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14471da177e4SLinus Torvalds { 14481da177e4SLinus Torvalds .procname = "lease-break-time", 14491da177e4SLinus Torvalds .data = &lease_break_time, 14501da177e4SLinus Torvalds .maxlen = sizeof(int), 14511da177e4SLinus Torvalds .mode = 0644, 14526d456111SEric W. Biederman .proc_handler = proc_dointvec, 14531da177e4SLinus Torvalds }, 1454bfcd17a6SThomas Petazzoni #endif 1455ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14561da177e4SLinus Torvalds { 14571da177e4SLinus Torvalds .procname = "aio-nr", 14581da177e4SLinus Torvalds .data = &aio_nr, 14591da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14601da177e4SLinus Torvalds .mode = 0444, 14616d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14621da177e4SLinus Torvalds }, 14631da177e4SLinus Torvalds { 14641da177e4SLinus Torvalds .procname = "aio-max-nr", 14651da177e4SLinus Torvalds .data = &aio_max_nr, 14661da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14671da177e4SLinus Torvalds .mode = 0644, 14686d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14691da177e4SLinus Torvalds }, 1470ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14712d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14720399cb08SRobert Love { 14730399cb08SRobert Love .procname = "inotify", 14740399cb08SRobert Love .mode = 0555, 14750399cb08SRobert Love .child = inotify_table, 14760399cb08SRobert Love }, 14770399cb08SRobert Love #endif 14787ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14797ef9964eSDavide Libenzi { 14807ef9964eSDavide Libenzi .procname = "epoll", 14817ef9964eSDavide Libenzi .mode = 0555, 14827ef9964eSDavide Libenzi .child = epoll_table, 14837ef9964eSDavide Libenzi }, 14847ef9964eSDavide Libenzi #endif 14851da177e4SLinus Torvalds #endif 1486d6e71144SAlan Cox { 1487d6e71144SAlan Cox .procname = "suid_dumpable", 1488d6e71144SAlan Cox .data = &suid_dumpable, 1489d6e71144SAlan Cox .maxlen = sizeof(int), 1490d6e71144SAlan Cox .mode = 0644, 14916d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14928e654fbaSMatthew Wilcox .extra1 = &zero, 14938e654fbaSMatthew Wilcox .extra2 = &two, 1494d6e71144SAlan Cox }, 14952abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14962abc26fcSEric W. Biederman { 14972abc26fcSEric W. Biederman .procname = "binfmt_misc", 14982abc26fcSEric W. Biederman .mode = 0555, 14992abc26fcSEric W. Biederman .child = binfmt_misc_table, 15002abc26fcSEric W. Biederman }, 15012abc26fcSEric W. Biederman #endif 1502b492e95bSJens Axboe { 1503ff9da691SJens Axboe .procname = "pipe-max-size", 1504ff9da691SJens Axboe .data = &pipe_max_size, 1505b492e95bSJens Axboe .maxlen = sizeof(int), 1506b492e95bSJens Axboe .mode = 0644, 1507ff9da691SJens Axboe .proc_handler = &pipe_proc_fn, 1508ff9da691SJens Axboe .extra1 = &pipe_min_size, 1509b492e95bSJens Axboe }, 15106fce56ecSEric W. Biederman { } 15111da177e4SLinus Torvalds }; 15121da177e4SLinus Torvalds 1513d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1514ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ 1515571d76acSChris Metcalf defined(CONFIG_S390) || defined(CONFIG_TILE) 1516abd4f750SMasoud Asgharifard Sharbiani { 1517abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1518abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1519abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1520abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1521abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1522abd4f750SMasoud Asgharifard Sharbiani }, 1523abd4f750SMasoud Asgharifard Sharbiani #endif 1524b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1525b2be84dfSMasami Hiramatsu { 1526b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1527b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1528b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1529b2be84dfSMasami Hiramatsu .mode = 0644, 1530b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1531b2be84dfSMasami Hiramatsu .extra1 = &zero, 1532b2be84dfSMasami Hiramatsu .extra2 = &one, 1533b2be84dfSMasami Hiramatsu }, 1534b2be84dfSMasami Hiramatsu #endif 15356fce56ecSEric W. Biederman { } 15361da177e4SLinus Torvalds }; 15371da177e4SLinus Torvalds 1538d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15396fce56ecSEric W. Biederman { } 15401da177e4SLinus Torvalds }; 15411da177e4SLinus Torvalds 1542330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1543330d57fbSAl Viro 1544330d57fbSAl Viro /* called under sysctl_lock */ 1545330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1546330d57fbSAl Viro { 1547330d57fbSAl Viro if (unlikely(p->unregistering)) 1548330d57fbSAl Viro return 0; 1549330d57fbSAl Viro p->used++; 1550330d57fbSAl Viro return 1; 1551330d57fbSAl Viro } 1552330d57fbSAl Viro 1553330d57fbSAl Viro /* called under sysctl_lock */ 1554330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1555330d57fbSAl Viro { 1556330d57fbSAl Viro if (!--p->used) 1557330d57fbSAl Viro if (unlikely(p->unregistering)) 1558330d57fbSAl Viro complete(p->unregistering); 1559330d57fbSAl Viro } 1560330d57fbSAl Viro 1561330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1562330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1563330d57fbSAl Viro { 1564330d57fbSAl Viro /* 1565330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1566330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1567330d57fbSAl Viro */ 1568330d57fbSAl Viro if (unlikely(p->used)) { 1569330d57fbSAl Viro struct completion wait; 1570330d57fbSAl Viro init_completion(&wait); 1571330d57fbSAl Viro p->unregistering = &wait; 1572330d57fbSAl Viro spin_unlock(&sysctl_lock); 1573330d57fbSAl Viro wait_for_completion(&wait); 1574330d57fbSAl Viro spin_lock(&sysctl_lock); 1575f7e6ced4SAl Viro } else { 1576f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1577f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1578330d57fbSAl Viro } 1579330d57fbSAl Viro /* 1580330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1581330d57fbSAl Viro * list in do_sysctl() relies on that. 1582330d57fbSAl Viro */ 1583330d57fbSAl Viro list_del_init(&p->ctl_entry); 1584330d57fbSAl Viro } 1585330d57fbSAl Viro 1586f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1587f7e6ced4SAl Viro { 1588f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1589f7e6ced4SAl Viro head->count++; 1590f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1591f7e6ced4SAl Viro } 1592f7e6ced4SAl Viro 1593dfef6dcdSAl Viro static void free_head(struct rcu_head *rcu) 1594dfef6dcdSAl Viro { 1595dfef6dcdSAl Viro kfree(container_of(rcu, struct ctl_table_header, rcu)); 1596dfef6dcdSAl Viro } 1597dfef6dcdSAl Viro 1598f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1599f7e6ced4SAl Viro { 1600f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1601f7e6ced4SAl Viro if (!--head->count) 1602dfef6dcdSAl Viro call_rcu(&head->rcu, free_head); 1603f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1604f7e6ced4SAl Viro } 1605f7e6ced4SAl Viro 1606f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1607f7e6ced4SAl Viro { 1608f7e6ced4SAl Viro if (!head) 1609f7e6ced4SAl Viro BUG(); 1610f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1611f7e6ced4SAl Viro if (!use_table(head)) 1612f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1613f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1614f7e6ced4SAl Viro return head; 1615f7e6ced4SAl Viro } 1616f7e6ced4SAl Viro 1617805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1618805b5d5eSEric W. Biederman { 1619805b5d5eSEric W. Biederman if (!head) 1620805b5d5eSEric W. Biederman return; 1621805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1622805b5d5eSEric W. Biederman unuse_table(head); 1623805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1624805b5d5eSEric W. Biederman } 1625805b5d5eSEric W. Biederman 162673455092SAl Viro static struct ctl_table_set * 162773455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 162873455092SAl Viro { 162973455092SAl Viro struct ctl_table_set *set = &root->default_set; 163073455092SAl Viro if (root->lookup) 163173455092SAl Viro set = root->lookup(root, namespaces); 163273455092SAl Viro return set; 163373455092SAl Viro } 163473455092SAl Viro 1635e51b6ba0SEric W. Biederman static struct list_head * 1636e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1637805b5d5eSEric W. Biederman { 163873455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 163973455092SAl Viro return &set->list; 1640e51b6ba0SEric W. Biederman } 1641e51b6ba0SEric W. Biederman 1642e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1643e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1644e51b6ba0SEric W. Biederman { 1645e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1646e51b6ba0SEric W. Biederman struct list_head *header_list; 1647805b5d5eSEric W. Biederman struct ctl_table_header *head; 1648805b5d5eSEric W. Biederman struct list_head *tmp; 1649e51b6ba0SEric W. Biederman 1650805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1651805b5d5eSEric W. Biederman if (prev) { 1652e51b6ba0SEric W. Biederman head = prev; 1653805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1654805b5d5eSEric W. Biederman unuse_table(prev); 1655805b5d5eSEric W. Biederman goto next; 1656805b5d5eSEric W. Biederman } 1657805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1658805b5d5eSEric W. Biederman for (;;) { 1659805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1660805b5d5eSEric W. Biederman 1661805b5d5eSEric W. Biederman if (!use_table(head)) 1662805b5d5eSEric W. Biederman goto next; 1663805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1664805b5d5eSEric W. Biederman return head; 1665805b5d5eSEric W. Biederman next: 1666e51b6ba0SEric W. Biederman root = head->root; 1667805b5d5eSEric W. Biederman tmp = tmp->next; 1668e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1669e51b6ba0SEric W. Biederman if (tmp != header_list) 1670e51b6ba0SEric W. Biederman continue; 1671e51b6ba0SEric W. Biederman 1672e51b6ba0SEric W. Biederman do { 1673e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1674e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1675e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1676e51b6ba0SEric W. Biederman goto out; 1677e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1678e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1679e51b6ba0SEric W. Biederman tmp = header_list->next; 1680805b5d5eSEric W. Biederman } 1681e51b6ba0SEric W. Biederman out: 1682805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1683805b5d5eSEric W. Biederman return NULL; 1684805b5d5eSEric W. Biederman } 1685805b5d5eSEric W. Biederman 1686e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1687e51b6ba0SEric W. Biederman { 1688e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1689e51b6ba0SEric W. Biederman } 1690e51b6ba0SEric W. Biederman 1691e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1692e51b6ba0SEric W. Biederman { 1693e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1694e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1695e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1696e51b6ba0SEric W. Biederman } 1697e51b6ba0SEric W. Biederman 16981da177e4SLinus Torvalds /* 16991ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 17001da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 17011da177e4SLinus Torvalds */ 17021da177e4SLinus Torvalds 17031da177e4SLinus Torvalds static int test_perm(int mode, int op) 17041da177e4SLinus Torvalds { 170576aac0e9SDavid Howells if (!current_euid()) 17061da177e4SLinus Torvalds mode >>= 6; 17071da177e4SLinus Torvalds else if (in_egroup_p(0)) 17081da177e4SLinus Torvalds mode >>= 3; 1709e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 17101da177e4SLinus Torvalds return 0; 17111da177e4SLinus Torvalds return -EACCES; 17121da177e4SLinus Torvalds } 17131da177e4SLinus Torvalds 1714d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 17151da177e4SLinus Torvalds { 1716d7321cd6SPavel Emelyanov int mode; 1717d7321cd6SPavel Emelyanov 1718d7321cd6SPavel Emelyanov if (root->permissions) 1719d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1720d7321cd6SPavel Emelyanov else 1721d7321cd6SPavel Emelyanov mode = table->mode; 1722d7321cd6SPavel Emelyanov 1723d7321cd6SPavel Emelyanov return test_perm(mode, op); 17241da177e4SLinus Torvalds } 17251da177e4SLinus Torvalds 1726d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1727d912b0ccSEric W. Biederman { 17282315ffa0SEric W. Biederman for (; table->procname; table++) { 1729d912b0ccSEric W. Biederman table->parent = parent; 1730d912b0ccSEric W. Biederman if (table->child) 1731d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1732d912b0ccSEric W. Biederman } 1733d912b0ccSEric W. Biederman } 1734d912b0ccSEric W. Biederman 1735d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1736d912b0ccSEric W. Biederman { 1737d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 173888f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1739b3bd3de6SAndi Kleen sysctl_check_table(current->nsproxy, root_table); 174088f458e4SHolger Schurig #endif 1741d912b0ccSEric W. Biederman return 0; 1742d912b0ccSEric W. Biederman } 1743d912b0ccSEric W. Biederman 1744d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1745d912b0ccSEric W. Biederman 1746bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1747bfbcf034SAl Viro struct ctl_table *table) 1748ae7edeccSAl Viro { 1749ae7edeccSAl Viro struct ctl_table *p; 1750ae7edeccSAl Viro const char *s = branch->procname; 1751ae7edeccSAl Viro 1752ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1753ae7edeccSAl Viro if (!s || !branch->child) 1754bfbcf034SAl Viro return NULL; 1755ae7edeccSAl Viro 1756ae7edeccSAl Viro /* ... and nothing else */ 17572315ffa0SEric W. Biederman if (branch[1].procname) 1758bfbcf034SAl Viro return NULL; 1759ae7edeccSAl Viro 1760ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 17612315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1762ae7edeccSAl Viro if (!p->child) 1763ae7edeccSAl Viro continue; 1764ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1765bfbcf034SAl Viro return p; 1766ae7edeccSAl Viro } 1767bfbcf034SAl Viro return NULL; 1768ae7edeccSAl Viro } 1769ae7edeccSAl Viro 1770ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1771ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1772ae7edeccSAl Viro { 1773ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1774bfbcf034SAl Viro struct ctl_table *next; 1775ae7edeccSAl Viro int is_better = 0; 1776ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1777ae7edeccSAl Viro 1778bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1779ae7edeccSAl Viro if (by == q->attached_by) 1780ae7edeccSAl Viro is_better = 1; 1781ae7edeccSAl Viro if (to == p->attached_by) 1782ae7edeccSAl Viro not_in_parent = 1; 1783ae7edeccSAl Viro by = by->child; 1784bfbcf034SAl Viro to = next->child; 1785ae7edeccSAl Viro } 1786ae7edeccSAl Viro 1787ae7edeccSAl Viro if (is_better && not_in_parent) { 1788ae7edeccSAl Viro q->attached_by = by; 1789ae7edeccSAl Viro q->attached_to = to; 1790ae7edeccSAl Viro q->parent = p; 1791ae7edeccSAl Viro } 1792ae7edeccSAl Viro } 1793ae7edeccSAl Viro 17941da177e4SLinus Torvalds /** 1795e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1796e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1797e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 179829e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 17991da177e4SLinus Torvalds * @table: the top-level table structure 18001da177e4SLinus Torvalds * 18011da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 180229e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 18031da177e4SLinus Torvalds * 1804d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 18051da177e4SLinus Torvalds * 18061da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 18071da177e4SLinus Torvalds * enter a sysctl file 18081da177e4SLinus Torvalds * 18091da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 18101da177e4SLinus Torvalds * 18111da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 18121da177e4SLinus Torvalds * 18131da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 18141da177e4SLinus Torvalds * 18151da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 18161da177e4SLinus Torvalds * %NULL. 18171da177e4SLinus Torvalds * 18181da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 18191da177e4SLinus Torvalds * 18201da177e4SLinus Torvalds * de - for internal use by the sysctl routines 18211da177e4SLinus Torvalds * 18221da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 18231da177e4SLinus Torvalds * 18241da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 18251da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 18261da177e4SLinus Torvalds * 18271da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 18281da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 18291da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 18301da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 18311da177e4SLinus Torvalds * 18321da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 18331da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 18341da177e4SLinus Torvalds * directory handler). Several default handlers are available to 18351da177e4SLinus Torvalds * cover common cases - 18361da177e4SLinus Torvalds * 18371da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 18381da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 18391da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 18401da177e4SLinus Torvalds * 18411da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 18421da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 18431da177e4SLinus Torvalds * 18441da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 18451da177e4SLinus Torvalds * to the table header on success. 18461da177e4SLinus Torvalds */ 1847e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1848e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1849e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1850e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 18511da177e4SLinus Torvalds { 185229e796fdSEric W. Biederman struct ctl_table_header *header; 185329e796fdSEric W. Biederman struct ctl_table *new, **prevp; 185429e796fdSEric W. Biederman unsigned int n, npath; 1855ae7edeccSAl Viro struct ctl_table_set *set; 185629e796fdSEric W. Biederman 185729e796fdSEric W. Biederman /* Count the path components */ 18582315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 185929e796fdSEric W. Biederman ; 186029e796fdSEric W. Biederman 186129e796fdSEric W. Biederman /* 186229e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 186329e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 18642315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 186529e796fdSEric W. Biederman * 186629e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 186729e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 186829e796fdSEric W. Biederman */ 186929e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 187029e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 187129e796fdSEric W. Biederman if (!header) 18721da177e4SLinus Torvalds return NULL; 187329e796fdSEric W. Biederman 187429e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 187529e796fdSEric W. Biederman 187629e796fdSEric W. Biederman /* Now connect the dots */ 187729e796fdSEric W. Biederman prevp = &header->ctl_table; 187829e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 187929e796fdSEric W. Biederman /* Copy the procname */ 188029e796fdSEric W. Biederman new->procname = path->procname; 188129e796fdSEric W. Biederman new->mode = 0555; 188229e796fdSEric W. Biederman 188329e796fdSEric W. Biederman *prevp = new; 188429e796fdSEric W. Biederman prevp = &new->child; 188529e796fdSEric W. Biederman 188629e796fdSEric W. Biederman new += 2; 188729e796fdSEric W. Biederman } 188829e796fdSEric W. Biederman *prevp = table; 188923eb06deSEric W. Biederman header->ctl_table_arg = table; 189029e796fdSEric W. Biederman 189129e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 189229e796fdSEric W. Biederman header->used = 0; 189329e796fdSEric W. Biederman header->unregistering = NULL; 1894e51b6ba0SEric W. Biederman header->root = root; 189529e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1896f7e6ced4SAl Viro header->count = 1; 189788f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1898e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 189929e796fdSEric W. Biederman kfree(header); 1900fc6cd25bSEric W. Biederman return NULL; 1901fc6cd25bSEric W. Biederman } 190288f458e4SHolger Schurig #endif 1903330d57fbSAl Viro spin_lock(&sysctl_lock); 190473455092SAl Viro header->set = lookup_header_set(root, namespaces); 1905ae7edeccSAl Viro header->attached_by = header->ctl_table; 1906ae7edeccSAl Viro header->attached_to = root_table; 1907ae7edeccSAl Viro header->parent = &root_table_header; 1908ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1909ae7edeccSAl Viro struct ctl_table_header *p; 1910ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1911ae7edeccSAl Viro if (p->unregistering) 1912ae7edeccSAl Viro continue; 1913ae7edeccSAl Viro try_attach(p, header); 1914ae7edeccSAl Viro } 1915ae7edeccSAl Viro } 1916ae7edeccSAl Viro header->parent->count++; 191773455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1918330d57fbSAl Viro spin_unlock(&sysctl_lock); 191929e796fdSEric W. Biederman 192029e796fdSEric W. Biederman return header; 192129e796fdSEric W. Biederman } 192229e796fdSEric W. Biederman 192329e796fdSEric W. Biederman /** 1924e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1925e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1926e51b6ba0SEric W. Biederman * @table: the top-level table structure 1927e51b6ba0SEric W. Biederman * 1928e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1929e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1930e51b6ba0SEric W. Biederman * 1931e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1932e51b6ba0SEric W. Biederman */ 1933e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1934e51b6ba0SEric W. Biederman struct ctl_table *table) 1935e51b6ba0SEric W. Biederman { 1936e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1937e51b6ba0SEric W. Biederman path, table); 1938e51b6ba0SEric W. Biederman } 1939e51b6ba0SEric W. Biederman 1940e51b6ba0SEric W. Biederman /** 194129e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 194229e796fdSEric W. Biederman * @table: the top-level table structure 194329e796fdSEric W. Biederman * 194429e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 194529e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 194629e796fdSEric W. Biederman * 194729e796fdSEric W. Biederman * See register_sysctl_paths for more details. 194829e796fdSEric W. Biederman */ 194929e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 195029e796fdSEric W. Biederman { 195129e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 195229e796fdSEric W. Biederman 195329e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 19541da177e4SLinus Torvalds } 19551da177e4SLinus Torvalds 19561da177e4SLinus Torvalds /** 19571da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 19581da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 19591da177e4SLinus Torvalds * 19601da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 19611da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 19621da177e4SLinus Torvalds */ 19631da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 19641da177e4SLinus Torvalds { 1965330d57fbSAl Viro might_sleep(); 1966f1dad166SPavel Emelyanov 1967f1dad166SPavel Emelyanov if (header == NULL) 1968f1dad166SPavel Emelyanov return; 1969f1dad166SPavel Emelyanov 1970330d57fbSAl Viro spin_lock(&sysctl_lock); 1971330d57fbSAl Viro start_unregistering(header); 1972ae7edeccSAl Viro if (!--header->parent->count) { 1973ae7edeccSAl Viro WARN_ON(1); 1974dfef6dcdSAl Viro call_rcu(&header->parent->rcu, free_head); 1975ae7edeccSAl Viro } 1976f7e6ced4SAl Viro if (!--header->count) 1977dfef6dcdSAl Viro call_rcu(&header->rcu, free_head); 1978f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19791da177e4SLinus Torvalds } 19801da177e4SLinus Torvalds 19819043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19829043476fSAl Viro { 19839043476fSAl Viro struct ctl_table_set *set = p->set; 19849043476fSAl Viro int res; 19859043476fSAl Viro spin_lock(&sysctl_lock); 19869043476fSAl Viro if (p->unregistering) 19879043476fSAl Viro res = 0; 19889043476fSAl Viro else if (!set->is_seen) 19899043476fSAl Viro res = 1; 19909043476fSAl Viro else 19919043476fSAl Viro res = set->is_seen(set); 19929043476fSAl Viro spin_unlock(&sysctl_lock); 19939043476fSAl Viro return res; 19949043476fSAl Viro } 19959043476fSAl Viro 199673455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 199773455092SAl Viro struct ctl_table_set *parent, 199873455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 199973455092SAl Viro { 200073455092SAl Viro INIT_LIST_HEAD(&p->list); 200173455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 200273455092SAl Viro p->is_seen = is_seen; 200373455092SAl Viro } 200473455092SAl Viro 2005b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 2006d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 2007b89a8171SEric W. Biederman { 2008b89a8171SEric W. Biederman return NULL; 2009b89a8171SEric W. Biederman } 2010b89a8171SEric W. Biederman 201129e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 201229e796fdSEric W. Biederman struct ctl_table *table) 201329e796fdSEric W. Biederman { 201429e796fdSEric W. Biederman return NULL; 201529e796fdSEric W. Biederman } 201629e796fdSEric W. Biederman 2017b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2018b89a8171SEric W. Biederman { 2019b89a8171SEric W. Biederman } 2020b89a8171SEric W. Biederman 202173455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 202273455092SAl Viro struct ctl_table_set *parent, 202373455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 202473455092SAl Viro { 202573455092SAl Viro } 202673455092SAl Viro 2027f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2028f7e6ced4SAl Viro { 2029f7e6ced4SAl Viro } 2030f7e6ced4SAl Viro 2031b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2032b89a8171SEric W. Biederman 20331da177e4SLinus Torvalds /* 20341da177e4SLinus Torvalds * /proc/sys support 20351da177e4SLinus Torvalds */ 20361da177e4SLinus Torvalds 2037b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 20381da177e4SLinus Torvalds 2039b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 20408d65af78SAlexey Dobriyan void __user *buffer, 2041b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2042f5dd3d6fSSam Vilain { 2043f5dd3d6fSSam Vilain size_t len; 2044f5dd3d6fSSam Vilain char __user *p; 2045f5dd3d6fSSam Vilain char c; 2046f5dd3d6fSSam Vilain 20478d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2048f5dd3d6fSSam Vilain *lenp = 0; 2049f5dd3d6fSSam Vilain return 0; 2050f5dd3d6fSSam Vilain } 2051f5dd3d6fSSam Vilain 2052f5dd3d6fSSam Vilain if (write) { 2053f5dd3d6fSSam Vilain len = 0; 2054f5dd3d6fSSam Vilain p = buffer; 2055f5dd3d6fSSam Vilain while (len < *lenp) { 2056f5dd3d6fSSam Vilain if (get_user(c, p++)) 2057f5dd3d6fSSam Vilain return -EFAULT; 2058f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2059f5dd3d6fSSam Vilain break; 2060f5dd3d6fSSam Vilain len++; 2061f5dd3d6fSSam Vilain } 2062f5dd3d6fSSam Vilain if (len >= maxlen) 2063f5dd3d6fSSam Vilain len = maxlen-1; 2064f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2065f5dd3d6fSSam Vilain return -EFAULT; 2066f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2067f5dd3d6fSSam Vilain *ppos += *lenp; 2068f5dd3d6fSSam Vilain } else { 2069f5dd3d6fSSam Vilain len = strlen(data); 2070f5dd3d6fSSam Vilain if (len > maxlen) 2071f5dd3d6fSSam Vilain len = maxlen; 20728d060877SOleg Nesterov 20738d060877SOleg Nesterov if (*ppos > len) { 20748d060877SOleg Nesterov *lenp = 0; 20758d060877SOleg Nesterov return 0; 20768d060877SOleg Nesterov } 20778d060877SOleg Nesterov 20788d060877SOleg Nesterov data += *ppos; 20798d060877SOleg Nesterov len -= *ppos; 20808d060877SOleg Nesterov 2081f5dd3d6fSSam Vilain if (len > *lenp) 2082f5dd3d6fSSam Vilain len = *lenp; 2083f5dd3d6fSSam Vilain if (len) 2084f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2085f5dd3d6fSSam Vilain return -EFAULT; 2086f5dd3d6fSSam Vilain if (len < *lenp) { 2087f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2088f5dd3d6fSSam Vilain return -EFAULT; 2089f5dd3d6fSSam Vilain len++; 2090f5dd3d6fSSam Vilain } 2091f5dd3d6fSSam Vilain *lenp = len; 2092f5dd3d6fSSam Vilain *ppos += len; 2093f5dd3d6fSSam Vilain } 2094f5dd3d6fSSam Vilain return 0; 2095f5dd3d6fSSam Vilain } 2096f5dd3d6fSSam Vilain 20971da177e4SLinus Torvalds /** 20981da177e4SLinus Torvalds * proc_dostring - read a string sysctl 20991da177e4SLinus Torvalds * @table: the sysctl table 21001da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21011da177e4SLinus Torvalds * @buffer: the user buffer 21021da177e4SLinus Torvalds * @lenp: the size of the user buffer 21031da177e4SLinus Torvalds * @ppos: file position 21041da177e4SLinus Torvalds * 21051da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 21061da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 21071da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 21081da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 21091da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 21101da177e4SLinus Torvalds * not large enough. 21111da177e4SLinus Torvalds * 21121da177e4SLinus Torvalds * Returns 0 on success. 21131da177e4SLinus Torvalds */ 21148d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 21151da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21161da177e4SLinus Torvalds { 21178d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2118f5dd3d6fSSam Vilain buffer, lenp, ppos); 21191da177e4SLinus Torvalds } 21201da177e4SLinus Torvalds 212100b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 212200b7c339SAmerigo Wang { 212300b7c339SAmerigo Wang size_t ret; 212400b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 212500b7c339SAmerigo Wang ret = tmp - *buf; 212600b7c339SAmerigo Wang *buf = tmp; 212700b7c339SAmerigo Wang return ret; 212800b7c339SAmerigo Wang } 21291da177e4SLinus Torvalds 21309f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v) 21319f977fb7SOctavian Purdila { 21329f977fb7SOctavian Purdila while (*size) { 21339f977fb7SOctavian Purdila if (**buf != v) 21349f977fb7SOctavian Purdila break; 21359f977fb7SOctavian Purdila (*size)--; 21369f977fb7SOctavian Purdila (*buf)++; 21379f977fb7SOctavian Purdila } 21389f977fb7SOctavian Purdila } 21399f977fb7SOctavian Purdila 214000b7c339SAmerigo Wang #define TMPBUFLEN 22 214100b7c339SAmerigo Wang /** 21420fc377bdSRandy Dunlap * proc_get_long - reads an ASCII formatted integer from a user buffer 214300b7c339SAmerigo Wang * 21440fc377bdSRandy Dunlap * @buf: a kernel buffer 21450fc377bdSRandy Dunlap * @size: size of the kernel buffer 21460fc377bdSRandy Dunlap * @val: this is where the number will be stored 21470fc377bdSRandy Dunlap * @neg: set to %TRUE if number is negative 21480fc377bdSRandy Dunlap * @perm_tr: a vector which contains the allowed trailers 21490fc377bdSRandy Dunlap * @perm_tr_len: size of the perm_tr vector 21500fc377bdSRandy Dunlap * @tr: pointer to store the trailer character 215100b7c339SAmerigo Wang * 21520fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 21530fc377bdSRandy Dunlap * the amount of bytes read. If @tr is non-NULL and a trailing 21540fc377bdSRandy Dunlap * character exists (size is non-zero after returning from this 21550fc377bdSRandy Dunlap * function), @tr is updated with the trailing character. 215600b7c339SAmerigo Wang */ 215700b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 215800b7c339SAmerigo Wang unsigned long *val, bool *neg, 215900b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 216000b7c339SAmerigo Wang { 216100b7c339SAmerigo Wang int len; 216200b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 216300b7c339SAmerigo Wang 216400b7c339SAmerigo Wang if (!*size) 216500b7c339SAmerigo Wang return -EINVAL; 216600b7c339SAmerigo Wang 216700b7c339SAmerigo Wang len = *size; 216800b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 216900b7c339SAmerigo Wang len = TMPBUFLEN - 1; 217000b7c339SAmerigo Wang 217100b7c339SAmerigo Wang memcpy(tmp, *buf, len); 217200b7c339SAmerigo Wang 217300b7c339SAmerigo Wang tmp[len] = 0; 217400b7c339SAmerigo Wang p = tmp; 217500b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 217600b7c339SAmerigo Wang *neg = true; 217700b7c339SAmerigo Wang p++; 217800b7c339SAmerigo Wang } else 217900b7c339SAmerigo Wang *neg = false; 218000b7c339SAmerigo Wang if (!isdigit(*p)) 218100b7c339SAmerigo Wang return -EINVAL; 218200b7c339SAmerigo Wang 218300b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 218400b7c339SAmerigo Wang 218500b7c339SAmerigo Wang len = p - tmp; 218600b7c339SAmerigo Wang 218700b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 218800b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 218900b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 219000b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 219100b7c339SAmerigo Wang return -EINVAL; 219200b7c339SAmerigo Wang 219300b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 219400b7c339SAmerigo Wang return -EINVAL; 219500b7c339SAmerigo Wang 219600b7c339SAmerigo Wang if (tr && (len < *size)) 219700b7c339SAmerigo Wang *tr = *p; 219800b7c339SAmerigo Wang 219900b7c339SAmerigo Wang *buf += len; 220000b7c339SAmerigo Wang *size -= len; 220100b7c339SAmerigo Wang 220200b7c339SAmerigo Wang return 0; 220300b7c339SAmerigo Wang } 220400b7c339SAmerigo Wang 220500b7c339SAmerigo Wang /** 22060fc377bdSRandy Dunlap * proc_put_long - converts an integer to a decimal ASCII formatted string 220700b7c339SAmerigo Wang * 22080fc377bdSRandy Dunlap * @buf: the user buffer 22090fc377bdSRandy Dunlap * @size: the size of the user buffer 22100fc377bdSRandy Dunlap * @val: the integer to be converted 22110fc377bdSRandy Dunlap * @neg: sign of the number, %TRUE for negative 221200b7c339SAmerigo Wang * 22130fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 22140fc377bdSRandy Dunlap * the amount of bytes written. 221500b7c339SAmerigo Wang */ 221600b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 221700b7c339SAmerigo Wang bool neg) 221800b7c339SAmerigo Wang { 221900b7c339SAmerigo Wang int len; 222000b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 222100b7c339SAmerigo Wang 222200b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 222300b7c339SAmerigo Wang len = strlen(tmp); 222400b7c339SAmerigo Wang if (len > *size) 222500b7c339SAmerigo Wang len = *size; 222600b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 222700b7c339SAmerigo Wang return -EFAULT; 222800b7c339SAmerigo Wang *size -= len; 222900b7c339SAmerigo Wang *buf += len; 223000b7c339SAmerigo Wang return 0; 223100b7c339SAmerigo Wang } 223200b7c339SAmerigo Wang #undef TMPBUFLEN 223300b7c339SAmerigo Wang 223400b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 223500b7c339SAmerigo Wang { 223600b7c339SAmerigo Wang if (*size) { 223700b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 223800b7c339SAmerigo Wang if (put_user(c, *buffer)) 223900b7c339SAmerigo Wang return -EFAULT; 224000b7c339SAmerigo Wang (*size)--, (*buffer)++; 224100b7c339SAmerigo Wang *buf = *buffer; 224200b7c339SAmerigo Wang } 224300b7c339SAmerigo Wang return 0; 224400b7c339SAmerigo Wang } 224500b7c339SAmerigo Wang 224600b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 22471da177e4SLinus Torvalds int *valp, 22481da177e4SLinus Torvalds int write, void *data) 22491da177e4SLinus Torvalds { 22501da177e4SLinus Torvalds if (write) { 22511da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 22521da177e4SLinus Torvalds } else { 22531da177e4SLinus Torvalds int val = *valp; 22541da177e4SLinus Torvalds if (val < 0) { 225500b7c339SAmerigo Wang *negp = true; 22561da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22571da177e4SLinus Torvalds } else { 225800b7c339SAmerigo Wang *negp = false; 22591da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22601da177e4SLinus Torvalds } 22611da177e4SLinus Torvalds } 22621da177e4SLinus Torvalds return 0; 22631da177e4SLinus Torvalds } 22641da177e4SLinus Torvalds 226500b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 226600b7c339SAmerigo Wang 2267d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 22688d65af78SAlexey Dobriyan int write, void __user *buffer, 2269fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 227000b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 22711da177e4SLinus Torvalds int write, void *data), 22721da177e4SLinus Torvalds void *data) 22731da177e4SLinus Torvalds { 227400b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 227500b7c339SAmerigo Wang unsigned long page = 0; 227600b7c339SAmerigo Wang size_t left; 227700b7c339SAmerigo Wang char *kbuf; 22781da177e4SLinus Torvalds 227900b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 22801da177e4SLinus Torvalds *lenp = 0; 22811da177e4SLinus Torvalds return 0; 22821da177e4SLinus Torvalds } 22831da177e4SLinus Torvalds 2284fcfbd547SKirill Korotaev i = (int *) tbl_data; 22851da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 22861da177e4SLinus Torvalds left = *lenp; 22871da177e4SLinus Torvalds 22881da177e4SLinus Torvalds if (!conv) 22891da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 22901da177e4SLinus Torvalds 229100b7c339SAmerigo Wang if (write) { 229200b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 229300b7c339SAmerigo Wang left = PAGE_SIZE - 1; 229400b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 229500b7c339SAmerigo Wang kbuf = (char *) page; 229600b7c339SAmerigo Wang if (!kbuf) 229700b7c339SAmerigo Wang return -ENOMEM; 229800b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 229900b7c339SAmerigo Wang err = -EFAULT; 230000b7c339SAmerigo Wang goto free; 230100b7c339SAmerigo Wang } 230200b7c339SAmerigo Wang kbuf[left] = 0; 230300b7c339SAmerigo Wang } 230400b7c339SAmerigo Wang 23051da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 230600b7c339SAmerigo Wang unsigned long lval; 230700b7c339SAmerigo Wang bool neg; 230800b7c339SAmerigo Wang 23091da177e4SLinus Torvalds if (write) { 231000b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 231100b7c339SAmerigo Wang 2312563b0467SJ. R. Okajima if (!left) 2313563b0467SJ. R. Okajima break; 231400b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 231500b7c339SAmerigo Wang proc_wspace_sep, 231600b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 231700b7c339SAmerigo Wang if (err) 23181da177e4SLinus Torvalds break; 231900b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 232000b7c339SAmerigo Wang err = -EINVAL; 232100b7c339SAmerigo Wang break; 23221da177e4SLinus Torvalds } 23231da177e4SLinus Torvalds } else { 232400b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 232500b7c339SAmerigo Wang err = -EINVAL; 232600b7c339SAmerigo Wang break; 232700b7c339SAmerigo Wang } 23281da177e4SLinus Torvalds if (!first) 232900b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 233000b7c339SAmerigo Wang if (err) 23311da177e4SLinus Torvalds break; 233200b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 233300b7c339SAmerigo Wang if (err) 233400b7c339SAmerigo Wang break; 23351da177e4SLinus Torvalds } 23361da177e4SLinus Torvalds } 23371da177e4SLinus Torvalds 233800b7c339SAmerigo Wang if (!write && !first && left && !err) 233900b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 2340563b0467SJ. R. Okajima if (write && !err && left) 234100b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 234200b7c339SAmerigo Wang free: 23431da177e4SLinus Torvalds if (write) { 234400b7c339SAmerigo Wang free_page(page); 234500b7c339SAmerigo Wang if (first) 234600b7c339SAmerigo Wang return err ? : -EINVAL; 23471da177e4SLinus Torvalds } 23481da177e4SLinus Torvalds *lenp -= left; 23491da177e4SLinus Torvalds *ppos += *lenp; 235000b7c339SAmerigo Wang return err; 23511da177e4SLinus Torvalds } 23521da177e4SLinus Torvalds 23538d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2354fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 235500b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 2356fcfbd547SKirill Korotaev int write, void *data), 2357fcfbd547SKirill Korotaev void *data) 2358fcfbd547SKirill Korotaev { 23598d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2360fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2361fcfbd547SKirill Korotaev } 2362fcfbd547SKirill Korotaev 23631da177e4SLinus Torvalds /** 23641da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 23651da177e4SLinus Torvalds * @table: the sysctl table 23661da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23671da177e4SLinus Torvalds * @buffer: the user buffer 23681da177e4SLinus Torvalds * @lenp: the size of the user buffer 23691da177e4SLinus Torvalds * @ppos: file position 23701da177e4SLinus Torvalds * 23711da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23721da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23731da177e4SLinus Torvalds * 23741da177e4SLinus Torvalds * Returns 0 on success. 23751da177e4SLinus Torvalds */ 23768d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 23771da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23781da177e4SLinus Torvalds { 23798d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 23801da177e4SLinus Torvalds NULL,NULL); 23811da177e4SLinus Torvalds } 23821da177e4SLinus Torvalds 238334f5a398STheodore Ts'o /* 238434f5a398STheodore Ts'o * Taint values can only be increased 238525ddbb18SAndi Kleen * This means we can safely use a temporary. 238634f5a398STheodore Ts'o */ 23878d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 238834f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 238934f5a398STheodore Ts'o { 239025ddbb18SAndi Kleen struct ctl_table t; 239125ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 239225ddbb18SAndi Kleen int err; 239334f5a398STheodore Ts'o 239491fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 239534f5a398STheodore Ts'o return -EPERM; 239634f5a398STheodore Ts'o 239725ddbb18SAndi Kleen t = *table; 239825ddbb18SAndi Kleen t.data = &tmptaint; 23998d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 240025ddbb18SAndi Kleen if (err < 0) 240125ddbb18SAndi Kleen return err; 240225ddbb18SAndi Kleen 240325ddbb18SAndi Kleen if (write) { 240425ddbb18SAndi Kleen /* 240525ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 240625ddbb18SAndi Kleen * to everyone's atomic.h for this 240725ddbb18SAndi Kleen */ 240825ddbb18SAndi Kleen int i; 240925ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 241025ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 241125ddbb18SAndi Kleen add_taint(i); 241225ddbb18SAndi Kleen } 241325ddbb18SAndi Kleen } 241425ddbb18SAndi Kleen 241525ddbb18SAndi Kleen return err; 241634f5a398STheodore Ts'o } 241734f5a398STheodore Ts'o 2418bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 2419bfdc0b49SRichard Weinberger static int proc_dmesg_restrict(struct ctl_table *table, int write, 2420bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos) 2421bfdc0b49SRichard Weinberger { 2422bfdc0b49SRichard Weinberger if (write && !capable(CAP_SYS_ADMIN)) 2423bfdc0b49SRichard Weinberger return -EPERM; 2424bfdc0b49SRichard Weinberger 2425bfdc0b49SRichard Weinberger return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 2426bfdc0b49SRichard Weinberger } 2427bfdc0b49SRichard Weinberger #endif 2428bfdc0b49SRichard Weinberger 24291da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 24301da177e4SLinus Torvalds int *min; 24311da177e4SLinus Torvalds int *max; 24321da177e4SLinus Torvalds }; 24331da177e4SLinus Torvalds 243400b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 24351da177e4SLinus Torvalds int *valp, 24361da177e4SLinus Torvalds int write, void *data) 24371da177e4SLinus Torvalds { 24381da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 24391da177e4SLinus Torvalds if (write) { 24401da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 24411da177e4SLinus Torvalds if ((param->min && *param->min > val) || 24421da177e4SLinus Torvalds (param->max && *param->max < val)) 24431da177e4SLinus Torvalds return -EINVAL; 24441da177e4SLinus Torvalds *valp = val; 24451da177e4SLinus Torvalds } else { 24461da177e4SLinus Torvalds int val = *valp; 24471da177e4SLinus Torvalds if (val < 0) { 244800b7c339SAmerigo Wang *negp = true; 24491da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 24501da177e4SLinus Torvalds } else { 245100b7c339SAmerigo Wang *negp = false; 24521da177e4SLinus Torvalds *lvalp = (unsigned long)val; 24531da177e4SLinus Torvalds } 24541da177e4SLinus Torvalds } 24551da177e4SLinus Torvalds return 0; 24561da177e4SLinus Torvalds } 24571da177e4SLinus Torvalds 24581da177e4SLinus Torvalds /** 24591da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 24601da177e4SLinus Torvalds * @table: the sysctl table 24611da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24621da177e4SLinus Torvalds * @buffer: the user buffer 24631da177e4SLinus Torvalds * @lenp: the size of the user buffer 24641da177e4SLinus Torvalds * @ppos: file position 24651da177e4SLinus Torvalds * 24661da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24671da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24681da177e4SLinus Torvalds * 24691da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24701da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24711da177e4SLinus Torvalds * 24721da177e4SLinus Torvalds * Returns 0 on success. 24731da177e4SLinus Torvalds */ 24748d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 24751da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24761da177e4SLinus Torvalds { 24771da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 24781da177e4SLinus Torvalds .min = (int *) table->extra1, 24791da177e4SLinus Torvalds .max = (int *) table->extra2, 24801da177e4SLinus Torvalds }; 24818d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 24821da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 24831da177e4SLinus Torvalds } 24841da177e4SLinus Torvalds 2485d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 24861da177e4SLinus Torvalds void __user *buffer, 24871da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 24881da177e4SLinus Torvalds unsigned long convmul, 24891da177e4SLinus Torvalds unsigned long convdiv) 24901da177e4SLinus Torvalds { 249100b7c339SAmerigo Wang unsigned long *i, *min, *max; 249200b7c339SAmerigo Wang int vleft, first = 1, err = 0; 249300b7c339SAmerigo Wang unsigned long page = 0; 249400b7c339SAmerigo Wang size_t left; 249500b7c339SAmerigo Wang char *kbuf; 24961da177e4SLinus Torvalds 249700b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 24981da177e4SLinus Torvalds *lenp = 0; 24991da177e4SLinus Torvalds return 0; 25001da177e4SLinus Torvalds } 25011da177e4SLinus Torvalds 2502fcfbd547SKirill Korotaev i = (unsigned long *) data; 25031da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 25041da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 25051da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 25061da177e4SLinus Torvalds left = *lenp; 25071da177e4SLinus Torvalds 25081da177e4SLinus Torvalds if (write) { 250900b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 251000b7c339SAmerigo Wang left = PAGE_SIZE - 1; 251100b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 251200b7c339SAmerigo Wang kbuf = (char *) page; 251300b7c339SAmerigo Wang if (!kbuf) 251400b7c339SAmerigo Wang return -ENOMEM; 251500b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 251600b7c339SAmerigo Wang err = -EFAULT; 251700b7c339SAmerigo Wang goto free; 25181da177e4SLinus Torvalds } 251900b7c339SAmerigo Wang kbuf[left] = 0; 25201da177e4SLinus Torvalds } 25211da177e4SLinus Torvalds 252227b3d80aSEric Dumazet for (; left && vleft--; i++, first = 0) { 252300b7c339SAmerigo Wang unsigned long val; 252400b7c339SAmerigo Wang 252500b7c339SAmerigo Wang if (write) { 252600b7c339SAmerigo Wang bool neg; 252700b7c339SAmerigo Wang 252800b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 252900b7c339SAmerigo Wang 253000b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 253100b7c339SAmerigo Wang proc_wspace_sep, 253200b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 253300b7c339SAmerigo Wang if (err) 253400b7c339SAmerigo Wang break; 25351da177e4SLinus Torvalds if (neg) 25361da177e4SLinus Torvalds continue; 25371da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 25381da177e4SLinus Torvalds continue; 25391da177e4SLinus Torvalds *i = val; 25401da177e4SLinus Torvalds } else { 254100b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 25421da177e4SLinus Torvalds if (!first) 254300b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 254400b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 254500b7c339SAmerigo Wang if (err) 254600b7c339SAmerigo Wang break; 25471da177e4SLinus Torvalds } 25481da177e4SLinus Torvalds } 25491da177e4SLinus Torvalds 255000b7c339SAmerigo Wang if (!write && !first && left && !err) 255100b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 255200b7c339SAmerigo Wang if (write && !err) 255300b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 255400b7c339SAmerigo Wang free: 25551da177e4SLinus Torvalds if (write) { 255600b7c339SAmerigo Wang free_page(page); 255700b7c339SAmerigo Wang if (first) 255800b7c339SAmerigo Wang return err ? : -EINVAL; 25591da177e4SLinus Torvalds } 25601da177e4SLinus Torvalds *lenp -= left; 25611da177e4SLinus Torvalds *ppos += *lenp; 256200b7c339SAmerigo Wang return err; 25631da177e4SLinus Torvalds } 25641da177e4SLinus Torvalds 2565d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2566fcfbd547SKirill Korotaev void __user *buffer, 2567fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2568fcfbd547SKirill Korotaev unsigned long convmul, 2569fcfbd547SKirill Korotaev unsigned long convdiv) 2570fcfbd547SKirill Korotaev { 2571fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 25728d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2573fcfbd547SKirill Korotaev } 2574fcfbd547SKirill Korotaev 25751da177e4SLinus Torvalds /** 25761da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 25771da177e4SLinus Torvalds * @table: the sysctl table 25781da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25791da177e4SLinus Torvalds * @buffer: the user buffer 25801da177e4SLinus Torvalds * @lenp: the size of the user buffer 25811da177e4SLinus Torvalds * @ppos: file position 25821da177e4SLinus Torvalds * 25831da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 25841da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25851da177e4SLinus Torvalds * 25861da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25871da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25881da177e4SLinus Torvalds * 25891da177e4SLinus Torvalds * Returns 0 on success. 25901da177e4SLinus Torvalds */ 25918d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 25921da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25931da177e4SLinus Torvalds { 25948d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 25951da177e4SLinus Torvalds } 25961da177e4SLinus Torvalds 25971da177e4SLinus Torvalds /** 25981da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 25991da177e4SLinus Torvalds * @table: the sysctl table 26001da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26011da177e4SLinus Torvalds * @buffer: the user buffer 26021da177e4SLinus Torvalds * @lenp: the size of the user buffer 26031da177e4SLinus Torvalds * @ppos: file position 26041da177e4SLinus Torvalds * 26051da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 26061da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 26071da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 26081da177e4SLinus Torvalds * 26091da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 26101da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 26111da177e4SLinus Torvalds * 26121da177e4SLinus Torvalds * Returns 0 on success. 26131da177e4SLinus Torvalds */ 2614d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 26151da177e4SLinus Torvalds void __user *buffer, 26161da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 26171da177e4SLinus Torvalds { 26188d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 26191da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 26201da177e4SLinus Torvalds } 26211da177e4SLinus Torvalds 26221da177e4SLinus Torvalds 262300b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 26241da177e4SLinus Torvalds int *valp, 26251da177e4SLinus Torvalds int write, void *data) 26261da177e4SLinus Torvalds { 26271da177e4SLinus Torvalds if (write) { 2628cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2629cba9f33dSBart Samwel return 1; 26301da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 26311da177e4SLinus Torvalds } else { 26321da177e4SLinus Torvalds int val = *valp; 26331da177e4SLinus Torvalds unsigned long lval; 26341da177e4SLinus Torvalds if (val < 0) { 263500b7c339SAmerigo Wang *negp = true; 26361da177e4SLinus Torvalds lval = (unsigned long)-val; 26371da177e4SLinus Torvalds } else { 263800b7c339SAmerigo Wang *negp = false; 26391da177e4SLinus Torvalds lval = (unsigned long)val; 26401da177e4SLinus Torvalds } 26411da177e4SLinus Torvalds *lvalp = lval / HZ; 26421da177e4SLinus Torvalds } 26431da177e4SLinus Torvalds return 0; 26441da177e4SLinus Torvalds } 26451da177e4SLinus Torvalds 264600b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 26471da177e4SLinus Torvalds int *valp, 26481da177e4SLinus Torvalds int write, void *data) 26491da177e4SLinus Torvalds { 26501da177e4SLinus Torvalds if (write) { 2651cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2652cba9f33dSBart Samwel return 1; 26531da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 26541da177e4SLinus Torvalds } else { 26551da177e4SLinus Torvalds int val = *valp; 26561da177e4SLinus Torvalds unsigned long lval; 26571da177e4SLinus Torvalds if (val < 0) { 265800b7c339SAmerigo Wang *negp = true; 26591da177e4SLinus Torvalds lval = (unsigned long)-val; 26601da177e4SLinus Torvalds } else { 266100b7c339SAmerigo Wang *negp = false; 26621da177e4SLinus Torvalds lval = (unsigned long)val; 26631da177e4SLinus Torvalds } 26641da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 26651da177e4SLinus Torvalds } 26661da177e4SLinus Torvalds return 0; 26671da177e4SLinus Torvalds } 26681da177e4SLinus Torvalds 266900b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 26701da177e4SLinus Torvalds int *valp, 26711da177e4SLinus Torvalds int write, void *data) 26721da177e4SLinus Torvalds { 26731da177e4SLinus Torvalds if (write) { 26741da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 26751da177e4SLinus Torvalds } else { 26761da177e4SLinus Torvalds int val = *valp; 26771da177e4SLinus Torvalds unsigned long lval; 26781da177e4SLinus Torvalds if (val < 0) { 267900b7c339SAmerigo Wang *negp = true; 26801da177e4SLinus Torvalds lval = (unsigned long)-val; 26811da177e4SLinus Torvalds } else { 268200b7c339SAmerigo Wang *negp = false; 26831da177e4SLinus Torvalds lval = (unsigned long)val; 26841da177e4SLinus Torvalds } 26851da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 26861da177e4SLinus Torvalds } 26871da177e4SLinus Torvalds return 0; 26881da177e4SLinus Torvalds } 26891da177e4SLinus Torvalds 26901da177e4SLinus Torvalds /** 26911da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 26921da177e4SLinus Torvalds * @table: the sysctl table 26931da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26941da177e4SLinus Torvalds * @buffer: the user buffer 26951da177e4SLinus Torvalds * @lenp: the size of the user buffer 26961da177e4SLinus Torvalds * @ppos: file position 26971da177e4SLinus Torvalds * 26981da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 26991da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27001da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 27011da177e4SLinus Torvalds * jiffies. 27021da177e4SLinus Torvalds * 27031da177e4SLinus Torvalds * Returns 0 on success. 27041da177e4SLinus Torvalds */ 27058d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 27061da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27071da177e4SLinus Torvalds { 27088d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27091da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 27101da177e4SLinus Torvalds } 27111da177e4SLinus Torvalds 27121da177e4SLinus Torvalds /** 27131da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 27141da177e4SLinus Torvalds * @table: the sysctl table 27151da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27161da177e4SLinus Torvalds * @buffer: the user buffer 27171da177e4SLinus Torvalds * @lenp: the size of the user buffer 27181e5d5331SRandy Dunlap * @ppos: pointer to the file position 27191da177e4SLinus Torvalds * 27201da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27211da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27221da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 27231da177e4SLinus Torvalds * are converted into jiffies. 27241da177e4SLinus Torvalds * 27251da177e4SLinus Torvalds * Returns 0 on success. 27261da177e4SLinus Torvalds */ 27278d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 27281da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27291da177e4SLinus Torvalds { 27308d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27311da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 27321da177e4SLinus Torvalds } 27331da177e4SLinus Torvalds 27341da177e4SLinus Torvalds /** 27351da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 27361da177e4SLinus Torvalds * @table: the sysctl table 27371da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27381da177e4SLinus Torvalds * @buffer: the user buffer 27391da177e4SLinus Torvalds * @lenp: the size of the user buffer 274067be2dd1SMartin Waitz * @ppos: file position 274167be2dd1SMartin Waitz * @ppos: the current position in the file 27421da177e4SLinus Torvalds * 27431da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27441da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27451da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 27461da177e4SLinus Torvalds * are converted into jiffies. 27471da177e4SLinus Torvalds * 27481da177e4SLinus Torvalds * Returns 0 on success. 27491da177e4SLinus Torvalds */ 27508d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 27511da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27521da177e4SLinus Torvalds { 27538d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 27541da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 27551da177e4SLinus Torvalds } 27561da177e4SLinus Torvalds 27578d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 27589ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 27599ec52099SCedric Le Goater { 27609ec52099SCedric Le Goater struct pid *new_pid; 27619ec52099SCedric Le Goater pid_t tmp; 27629ec52099SCedric Le Goater int r; 27639ec52099SCedric Le Goater 27646c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 27659ec52099SCedric Le Goater 27668d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 27679ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 27689ec52099SCedric Le Goater if (r || !write) 27699ec52099SCedric Le Goater return r; 27709ec52099SCedric Le Goater 27719ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 27729ec52099SCedric Le Goater if (!new_pid) 27739ec52099SCedric Le Goater return -ESRCH; 27749ec52099SCedric Le Goater 27759ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 27769ec52099SCedric Le Goater return 0; 27779ec52099SCedric Le Goater } 27789ec52099SCedric Le Goater 27799f977fb7SOctavian Purdila /** 27809f977fb7SOctavian Purdila * proc_do_large_bitmap - read/write from/to a large bitmap 27819f977fb7SOctavian Purdila * @table: the sysctl table 27829f977fb7SOctavian Purdila * @write: %TRUE if this is a write to the sysctl file 27839f977fb7SOctavian Purdila * @buffer: the user buffer 27849f977fb7SOctavian Purdila * @lenp: the size of the user buffer 27859f977fb7SOctavian Purdila * @ppos: file position 27869f977fb7SOctavian Purdila * 27879f977fb7SOctavian Purdila * The bitmap is stored at table->data and the bitmap length (in bits) 27889f977fb7SOctavian Purdila * in table->maxlen. 27899f977fb7SOctavian Purdila * 27909f977fb7SOctavian Purdila * We use a range comma separated format (e.g. 1,3-4,10-10) so that 27919f977fb7SOctavian Purdila * large bitmaps may be represented in a compact manner. Writing into 27929f977fb7SOctavian Purdila * the file will clear the bitmap then update it with the given input. 27939f977fb7SOctavian Purdila * 27949f977fb7SOctavian Purdila * Returns 0 on success. 27959f977fb7SOctavian Purdila */ 27969f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write, 27979f977fb7SOctavian Purdila void __user *buffer, size_t *lenp, loff_t *ppos) 27989f977fb7SOctavian Purdila { 27999f977fb7SOctavian Purdila int err = 0; 28009f977fb7SOctavian Purdila bool first = 1; 28019f977fb7SOctavian Purdila size_t left = *lenp; 28029f977fb7SOctavian Purdila unsigned long bitmap_len = table->maxlen; 28039f977fb7SOctavian Purdila unsigned long *bitmap = (unsigned long *) table->data; 28049f977fb7SOctavian Purdila unsigned long *tmp_bitmap = NULL; 28059f977fb7SOctavian Purdila char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 28069f977fb7SOctavian Purdila 28079f977fb7SOctavian Purdila if (!bitmap_len || !left || (*ppos && !write)) { 28089f977fb7SOctavian Purdila *lenp = 0; 28099f977fb7SOctavian Purdila return 0; 28109f977fb7SOctavian Purdila } 28119f977fb7SOctavian Purdila 28129f977fb7SOctavian Purdila if (write) { 28139f977fb7SOctavian Purdila unsigned long page = 0; 28149f977fb7SOctavian Purdila char *kbuf; 28159f977fb7SOctavian Purdila 28169f977fb7SOctavian Purdila if (left > PAGE_SIZE - 1) 28179f977fb7SOctavian Purdila left = PAGE_SIZE - 1; 28189f977fb7SOctavian Purdila 28199f977fb7SOctavian Purdila page = __get_free_page(GFP_TEMPORARY); 28209f977fb7SOctavian Purdila kbuf = (char *) page; 28219f977fb7SOctavian Purdila if (!kbuf) 28229f977fb7SOctavian Purdila return -ENOMEM; 28239f977fb7SOctavian Purdila if (copy_from_user(kbuf, buffer, left)) { 28249f977fb7SOctavian Purdila free_page(page); 28259f977fb7SOctavian Purdila return -EFAULT; 28269f977fb7SOctavian Purdila } 28279f977fb7SOctavian Purdila kbuf[left] = 0; 28289f977fb7SOctavian Purdila 28299f977fb7SOctavian Purdila tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), 28309f977fb7SOctavian Purdila GFP_KERNEL); 28319f977fb7SOctavian Purdila if (!tmp_bitmap) { 28329f977fb7SOctavian Purdila free_page(page); 28339f977fb7SOctavian Purdila return -ENOMEM; 28349f977fb7SOctavian Purdila } 28359f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28369f977fb7SOctavian Purdila while (!err && left) { 28379f977fb7SOctavian Purdila unsigned long val_a, val_b; 28389f977fb7SOctavian Purdila bool neg; 28399f977fb7SOctavian Purdila 28409f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, 28419f977fb7SOctavian Purdila sizeof(tr_a), &c); 28429f977fb7SOctavian Purdila if (err) 28439f977fb7SOctavian Purdila break; 28449f977fb7SOctavian Purdila if (val_a >= bitmap_len || neg) { 28459f977fb7SOctavian Purdila err = -EINVAL; 28469f977fb7SOctavian Purdila break; 28479f977fb7SOctavian Purdila } 28489f977fb7SOctavian Purdila 28499f977fb7SOctavian Purdila val_b = val_a; 28509f977fb7SOctavian Purdila if (left) { 28519f977fb7SOctavian Purdila kbuf++; 28529f977fb7SOctavian Purdila left--; 28539f977fb7SOctavian Purdila } 28549f977fb7SOctavian Purdila 28559f977fb7SOctavian Purdila if (c == '-') { 28569f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_b, 28579f977fb7SOctavian Purdila &neg, tr_b, sizeof(tr_b), 28589f977fb7SOctavian Purdila &c); 28599f977fb7SOctavian Purdila if (err) 28609f977fb7SOctavian Purdila break; 28619f977fb7SOctavian Purdila if (val_b >= bitmap_len || neg || 28629f977fb7SOctavian Purdila val_a > val_b) { 28639f977fb7SOctavian Purdila err = -EINVAL; 28649f977fb7SOctavian Purdila break; 28659f977fb7SOctavian Purdila } 28669f977fb7SOctavian Purdila if (left) { 28679f977fb7SOctavian Purdila kbuf++; 28689f977fb7SOctavian Purdila left--; 28699f977fb7SOctavian Purdila } 28709f977fb7SOctavian Purdila } 28719f977fb7SOctavian Purdila 28729f977fb7SOctavian Purdila while (val_a <= val_b) 28739f977fb7SOctavian Purdila set_bit(val_a++, tmp_bitmap); 28749f977fb7SOctavian Purdila 28759f977fb7SOctavian Purdila first = 0; 28769f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28779f977fb7SOctavian Purdila } 28789f977fb7SOctavian Purdila free_page(page); 28799f977fb7SOctavian Purdila } else { 28809f977fb7SOctavian Purdila unsigned long bit_a, bit_b = 0; 28819f977fb7SOctavian Purdila 28829f977fb7SOctavian Purdila while (left) { 28839f977fb7SOctavian Purdila bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 28849f977fb7SOctavian Purdila if (bit_a >= bitmap_len) 28859f977fb7SOctavian Purdila break; 28869f977fb7SOctavian Purdila bit_b = find_next_zero_bit(bitmap, bitmap_len, 28879f977fb7SOctavian Purdila bit_a + 1) - 1; 28889f977fb7SOctavian Purdila 28899f977fb7SOctavian Purdila if (!first) { 28909f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, ','); 28919f977fb7SOctavian Purdila if (err) 28929f977fb7SOctavian Purdila break; 28939f977fb7SOctavian Purdila } 28949f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_a, false); 28959f977fb7SOctavian Purdila if (err) 28969f977fb7SOctavian Purdila break; 28979f977fb7SOctavian Purdila if (bit_a != bit_b) { 28989f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '-'); 28999f977fb7SOctavian Purdila if (err) 29009f977fb7SOctavian Purdila break; 29019f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_b, false); 29029f977fb7SOctavian Purdila if (err) 29039f977fb7SOctavian Purdila break; 29049f977fb7SOctavian Purdila } 29059f977fb7SOctavian Purdila 29069f977fb7SOctavian Purdila first = 0; bit_b++; 29079f977fb7SOctavian Purdila } 29089f977fb7SOctavian Purdila if (!err) 29099f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '\n'); 29109f977fb7SOctavian Purdila } 29119f977fb7SOctavian Purdila 29129f977fb7SOctavian Purdila if (!err) { 29139f977fb7SOctavian Purdila if (write) { 29149f977fb7SOctavian Purdila if (*ppos) 29159f977fb7SOctavian Purdila bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 29169f977fb7SOctavian Purdila else 29179f977fb7SOctavian Purdila memcpy(bitmap, tmp_bitmap, 29189f977fb7SOctavian Purdila BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long)); 29199f977fb7SOctavian Purdila } 29209f977fb7SOctavian Purdila kfree(tmp_bitmap); 29219f977fb7SOctavian Purdila *lenp -= left; 29229f977fb7SOctavian Purdila *ppos += *lenp; 29239f977fb7SOctavian Purdila return 0; 29249f977fb7SOctavian Purdila } else { 29259f977fb7SOctavian Purdila kfree(tmp_bitmap); 29269f977fb7SOctavian Purdila return err; 29279f977fb7SOctavian Purdila } 29289f977fb7SOctavian Purdila } 29299f977fb7SOctavian Purdila 293055610500SJovi Zhang #else /* CONFIG_PROC_SYSCTL */ 29311da177e4SLinus Torvalds 29328d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 29331da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29341da177e4SLinus Torvalds { 29351da177e4SLinus Torvalds return -ENOSYS; 29361da177e4SLinus Torvalds } 29371da177e4SLinus Torvalds 29388d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 29391da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29401da177e4SLinus Torvalds { 29411da177e4SLinus Torvalds return -ENOSYS; 29421da177e4SLinus Torvalds } 29431da177e4SLinus Torvalds 29448d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 29451da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29461da177e4SLinus Torvalds { 29471da177e4SLinus Torvalds return -ENOSYS; 29481da177e4SLinus Torvalds } 29491da177e4SLinus Torvalds 29508d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 29511da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29521da177e4SLinus Torvalds { 29531da177e4SLinus Torvalds return -ENOSYS; 29541da177e4SLinus Torvalds } 29551da177e4SLinus Torvalds 29568d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 29571da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29581da177e4SLinus Torvalds { 29591da177e4SLinus Torvalds return -ENOSYS; 29601da177e4SLinus Torvalds } 29611da177e4SLinus Torvalds 29628d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 29631da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29641da177e4SLinus Torvalds { 29651da177e4SLinus Torvalds return -ENOSYS; 29661da177e4SLinus Torvalds } 29671da177e4SLinus Torvalds 29688d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 29691da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29701da177e4SLinus Torvalds { 29711da177e4SLinus Torvalds return -ENOSYS; 29721da177e4SLinus Torvalds } 29731da177e4SLinus Torvalds 2974d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 29751da177e4SLinus Torvalds void __user *buffer, 29761da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 29771da177e4SLinus Torvalds { 29781da177e4SLinus Torvalds return -ENOSYS; 29791da177e4SLinus Torvalds } 29801da177e4SLinus Torvalds 29811da177e4SLinus Torvalds 298255610500SJovi Zhang #endif /* CONFIG_PROC_SYSCTL */ 29831da177e4SLinus Torvalds 29841da177e4SLinus Torvalds /* 29851da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 29861da177e4SLinus Torvalds * exception granted :-) 29871da177e4SLinus Torvalds */ 29881da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 29891da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 29901da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 29911da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 29921da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 29931da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 29941da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 29951da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 29961da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 299729e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 29981da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2999