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> 271da177e4SLinus Torvalds #include <linux/proc_fs.h> 2872c2d582SAndrew Morgan #include <linux/security.h> 291da177e4SLinus Torvalds #include <linux/ctype.h> 30dfec072eSVegard Nossum #include <linux/kmemcheck.h> 3162239ac2SAdrian Bunk #include <linux/fs.h> 321da177e4SLinus Torvalds #include <linux/init.h> 331da177e4SLinus Torvalds #include <linux/kernel.h> 340296b228SKay Sievers #include <linux/kobject.h> 3520380731SArnaldo Carvalho de Melo #include <linux/net.h> 361da177e4SLinus Torvalds #include <linux/sysrq.h> 371da177e4SLinus Torvalds #include <linux/highuid.h> 381da177e4SLinus Torvalds #include <linux/writeback.h> 393fff4c42SIngo Molnar #include <linux/ratelimit.h> 4076ab0f53SMel Gorman #include <linux/compaction.h> 411da177e4SLinus Torvalds #include <linux/hugetlb.h> 421da177e4SLinus Torvalds #include <linux/initrd.h> 430b77f5bfSDavid Howells #include <linux/key.h> 441da177e4SLinus Torvalds #include <linux/times.h> 451da177e4SLinus Torvalds #include <linux/limits.h> 461da177e4SLinus Torvalds #include <linux/dcache.h> 476e006701SAlexey Dobriyan #include <linux/dnotify.h> 481da177e4SLinus Torvalds #include <linux/syscalls.h> 49c748e134SAdrian Bunk #include <linux/vmstat.h> 50c255d844SPavel Machek #include <linux/nfs_fs.h> 51c255d844SPavel Machek #include <linux/acpi.h> 5210a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 53b0fc494fSSteven Rostedt #include <linux/ftrace.h> 54cdd6c482SIngo Molnar #include <linux/perf_event.h> 55b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 56b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 578e4228e1SDavid Rientjes #include <linux/oom.h> 581da177e4SLinus Torvalds 591da177e4SLinus Torvalds #include <asm/uaccess.h> 601da177e4SLinus Torvalds #include <asm/processor.h> 611da177e4SLinus Torvalds 6229cbc78bSAndi Kleen #ifdef CONFIG_X86 6329cbc78bSAndi Kleen #include <asm/nmi.h> 640741f4d2SChuck Ebbert #include <asm/stacktrace.h> 656e7c4025SIngo Molnar #include <asm/io.h> 6629cbc78bSAndi Kleen #endif 67c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 68c55b7c3eSDave Young #include <linux/acct.h> 69c55b7c3eSDave Young #endif 704f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 714f0e056fSDave Young #include <linux/rtmutex.h> 724f0e056fSDave Young #endif 732edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 742edf5e49SDave Young #include <linux/lockdep.h> 752edf5e49SDave Young #endif 7615485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 7715485a46SDave Young #include <scsi/sg.h> 7815485a46SDave Young #endif 7929cbc78bSAndi Kleen 8058687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 81504d7cf1SDon Zickus #include <linux/nmi.h> 82504d7cf1SDon Zickus #endif 83504d7cf1SDon Zickus 847058cb02SEric W. Biederman 851da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds /* External variables not in a header file. */ 881da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 891da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 901da177e4SLinus Torvalds extern int max_threads; 911da177e4SLinus Torvalds extern int core_uses_pid; 92d6e71144SAlan Cox extern int suid_dumpable; 931da177e4SLinus Torvalds extern char core_pattern[]; 94a293980cSNeil Horman extern unsigned int core_pipe_limit; 951da177e4SLinus Torvalds extern int pid_max; 961da177e4SLinus Torvalds extern int min_free_kbytes; 971da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 989d0243bcSAndrew Morton extern int sysctl_drop_caches; 998ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 100bebfa101SAndi Kleen extern int compat_log; 1019745512cSArjan van de Ven extern int latencytop_enabled; 102eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 103dd8632a1SPaul Mundt #ifndef CONFIG_MMU 104dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 105dd8632a1SPaul Mundt #endif 106cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 1075e605b64SJens Axboe extern int blk_iopoll_enabled; 108cb684b5bSJens Axboe #endif 1091da177e4SLinus Torvalds 110c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1112508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 112c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1139383d967SDimitri Sivanich static int neg_one = -1; 114c4f3b63fSRavikiran G Thirumalai #endif 115c4f3b63fSRavikiran G Thirumalai 116c4f3b63fSRavikiran G Thirumalai static int zero; 117cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 118cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 119fc3501d4SSven Wegener static unsigned long one_ul = 1; 120c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 121af91322eSDave Young #ifdef CONFIG_PRINTK 122af91322eSDave Young static int ten_thousand = 10000; 123af91322eSDave Young #endif 124c4f3b63fSRavikiran G Thirumalai 1259e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1269e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1279e4a5bdaSAndrea Righi 1281da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1291da177e4SLinus Torvalds static int maxolduid = 65535; 1301da177e4SLinus Torvalds static int minolduid; 1318ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1341da177e4SLinus Torvalds 135d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 136d14f1729SDave Young #include <linux/inotify.h> 137d14f1729SDave Young #endif 13872c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 13917f04fbbSDavid S. Miller #include <asm/system.h> 1401da177e4SLinus Torvalds #endif 1411da177e4SLinus Torvalds 1420871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1430871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1440871420fSDavid S. Miller #endif 1450871420fSDavid S. Miller 1461da177e4SLinus Torvalds #ifdef __hppa__ 1471da177e4SLinus Torvalds extern int pwrsw_enabled; 1481da177e4SLinus Torvalds extern int unaligned_enabled; 1491da177e4SLinus Torvalds #endif 1501da177e4SLinus Torvalds 151347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1521da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1531da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1541da177e4SLinus Torvalds #endif 1551da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 156951f22d5SMartin Schwidefsky extern int spin_retry; 1571da177e4SLinus Torvalds #endif 1581da177e4SLinus Torvalds 159d2b176edSJes Sorensen #ifdef CONFIG_IA64 160d2b176edSJes Sorensen extern int no_unaligned_warning; 16188fc241fSDoug Chapman extern int unaligned_dump_stack; 162d2b176edSJes Sorensen #endif 163d2b176edSJes Sorensen 164d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1658d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1669ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1678d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 16834f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 169d6f8ff73SRandy Dunlap #endif 1709ec52099SCedric Le Goater 17197f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ 17297f5f0cdSDmitry Torokhov static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */ 17397f5f0cdSDmitry Torokhov 17497f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write, 17597f5f0cdSDmitry Torokhov void __user *buffer, size_t *lenp, 17697f5f0cdSDmitry Torokhov loff_t *ppos) 17797f5f0cdSDmitry Torokhov { 17897f5f0cdSDmitry Torokhov int error; 17997f5f0cdSDmitry Torokhov 18097f5f0cdSDmitry Torokhov error = proc_dointvec(table, write, buffer, lenp, ppos); 18197f5f0cdSDmitry Torokhov if (error) 18297f5f0cdSDmitry Torokhov return error; 18397f5f0cdSDmitry Torokhov 18497f5f0cdSDmitry Torokhov if (write) 18597f5f0cdSDmitry Torokhov sysrq_toggle_support(__sysrq_enabled); 18697f5f0cdSDmitry Torokhov 18797f5f0cdSDmitry Torokhov return 0; 18897f5f0cdSDmitry Torokhov } 18997f5f0cdSDmitry Torokhov 19097f5f0cdSDmitry Torokhov #endif 19197f5f0cdSDmitry Torokhov 192d8217f07SEric W. Biederman static struct ctl_table root_table[]; 193e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 194e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 195b380b0d4SAl Viro .count = 1, 196e51b6ba0SEric W. Biederman .ctl_table = root_table, 19773455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 198e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 19973455092SAl Viro .set = &sysctl_table_root.default_set, 200e51b6ba0SEric W. Biederman }; 201e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 202e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 20373455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 204e51b6ba0SEric W. Biederman }; 2051da177e4SLinus Torvalds 206d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 207d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 208d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 209d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 210d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 211d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 2127ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 2137ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 2147ef9964eSDavide Libenzi #endif 2151da177e4SLinus Torvalds 2161da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2171da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2181da177e4SLinus Torvalds #endif 2191da177e4SLinus Torvalds 2201da177e4SLinus Torvalds /* The default sysctl tables: */ 2211da177e4SLinus Torvalds 222d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2231da177e4SLinus Torvalds { 2241da177e4SLinus Torvalds .procname = "kernel", 2251da177e4SLinus Torvalds .mode = 0555, 2261da177e4SLinus Torvalds .child = kern_table, 2271da177e4SLinus Torvalds }, 2281da177e4SLinus Torvalds { 2291da177e4SLinus Torvalds .procname = "vm", 2301da177e4SLinus Torvalds .mode = 0555, 2311da177e4SLinus Torvalds .child = vm_table, 2321da177e4SLinus Torvalds }, 2331da177e4SLinus Torvalds { 2341da177e4SLinus Torvalds .procname = "fs", 2351da177e4SLinus Torvalds .mode = 0555, 2361da177e4SLinus Torvalds .child = fs_table, 2371da177e4SLinus Torvalds }, 2381da177e4SLinus Torvalds { 2391da177e4SLinus Torvalds .procname = "debug", 2401da177e4SLinus Torvalds .mode = 0555, 2411da177e4SLinus Torvalds .child = debug_table, 2421da177e4SLinus Torvalds }, 2431da177e4SLinus Torvalds { 2441da177e4SLinus Torvalds .procname = "dev", 2451da177e4SLinus Torvalds .mode = 0555, 2461da177e4SLinus Torvalds .child = dev_table, 2471da177e4SLinus Torvalds }, 2482be7fe07SAndrew Morton /* 2492be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2502be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2512be7fe07SAndrew Morton */ 2526fce56ecSEric W. Biederman { } 2531da177e4SLinus Torvalds }; 2541da177e4SLinus Torvalds 25577e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 25673c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 25773c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 25873c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 25973c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2601983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2611983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 26277e54a1fSIngo Molnar #endif 26377e54a1fSIngo Molnar 2645e771905SMel Gorman #ifdef CONFIG_COMPACTION 2655e771905SMel Gorman static int min_extfrag_threshold; 2665e771905SMel Gorman static int max_extfrag_threshold = 1000; 2675e771905SMel Gorman #endif 2685e771905SMel Gorman 269d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2702bba22c5SMike Galbraith { 2712bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2722bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2732bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2742bba22c5SMike Galbraith .mode = 0644, 2756d456111SEric W. Biederman .proc_handler = proc_dointvec, 2762bba22c5SMike Galbraith }, 27777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 27877e54a1fSIngo Molnar { 279b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 280b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 28177e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28277e54a1fSIngo Molnar .mode = 0644, 283702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 284b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 285b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28677e54a1fSIngo Molnar }, 28777e54a1fSIngo Molnar { 28821805085SPeter Zijlstra .procname = "sched_latency_ns", 28921805085SPeter Zijlstra .data = &sysctl_sched_latency, 29021805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 29121805085SPeter Zijlstra .mode = 0644, 292702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 29321805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 29421805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 29521805085SPeter Zijlstra }, 29621805085SPeter Zijlstra { 29777e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 29877e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 29977e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 30077e54a1fSIngo Molnar .mode = 0644, 301702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 30277e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 30377e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 30477e54a1fSIngo Molnar }, 30577e54a1fSIngo Molnar { 3061983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3071983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3081983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3091983a922SChristian Ehrhardt .mode = 0644, 310702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3111983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3121983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3132398f2c6SPeter Zijlstra }, 3142398f2c6SPeter Zijlstra { 315da84d961SIngo Molnar .procname = "sched_migration_cost", 316da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 317da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 318da84d961SIngo Molnar .mode = 0644, 3196d456111SEric W. Biederman .proc_handler = proc_dointvec, 320da84d961SIngo Molnar }, 321b82d9fddSPeter Zijlstra { 322b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 323b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 324b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 325fa85ae24SPeter Zijlstra .mode = 0644, 3266d456111SEric W. Biederman .proc_handler = proc_dointvec, 327fa85ae24SPeter Zijlstra }, 328cd1bb94bSArun R Bharadwaj { 329e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 330e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 331e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 332e9e9250bSPeter Zijlstra .mode = 0644, 3336d456111SEric W. Biederman .proc_handler = proc_dointvec, 334e9e9250bSPeter Zijlstra }, 335e9e9250bSPeter Zijlstra { 336a7a4f8a7SPaul Turner .procname = "sched_shares_window", 337a7a4f8a7SPaul Turner .data = &sysctl_sched_shares_window, 338a7a4f8a7SPaul Turner .maxlen = sizeof(unsigned int), 339a7a4f8a7SPaul Turner .mode = 0644, 340a7a4f8a7SPaul Turner .proc_handler = proc_dointvec, 341a7a4f8a7SPaul Turner }, 342a7a4f8a7SPaul Turner { 343cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 344cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 345cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 346cd1bb94bSArun R Bharadwaj .mode = 0644, 3476d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 348bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 349bfdb4d9fSArun R Bharadwaj .extra2 = &one, 350cd1bb94bSArun R Bharadwaj }, 3511fc84aaaSPeter Zijlstra #endif 3521799e35dSIngo Molnar { 3539f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3549f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3559f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3569f0c1e56SPeter Zijlstra .mode = 0644, 3576d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3589f0c1e56SPeter Zijlstra }, 3599f0c1e56SPeter Zijlstra { 3609f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3619f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3629f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3639f0c1e56SPeter Zijlstra .mode = 0644, 3646d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3659f0c1e56SPeter Zijlstra }, 3669f0c1e56SPeter Zijlstra { 3671799e35dSIngo Molnar .procname = "sched_compat_yield", 3681799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3691799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3701799e35dSIngo Molnar .mode = 0644, 3716d456111SEric W. Biederman .proc_handler = proc_dointvec, 3721799e35dSIngo Molnar }, 373*5091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 374*5091faa4SMike Galbraith { 375*5091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 376*5091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 377*5091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 378*5091faa4SMike Galbraith .mode = 0644, 379*5091faa4SMike Galbraith .proc_handler = proc_dointvec, 380*5091faa4SMike Galbraith .extra1 = &zero, 381*5091faa4SMike Galbraith .extra2 = &one, 382*5091faa4SMike Galbraith }, 383*5091faa4SMike Galbraith #endif 384f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 385f20786ffSPeter Zijlstra { 386f20786ffSPeter Zijlstra .procname = "prove_locking", 387f20786ffSPeter Zijlstra .data = &prove_locking, 388f20786ffSPeter Zijlstra .maxlen = sizeof(int), 389f20786ffSPeter Zijlstra .mode = 0644, 3906d456111SEric W. Biederman .proc_handler = proc_dointvec, 391f20786ffSPeter Zijlstra }, 392f20786ffSPeter Zijlstra #endif 393f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 394f20786ffSPeter Zijlstra { 395f20786ffSPeter Zijlstra .procname = "lock_stat", 396f20786ffSPeter Zijlstra .data = &lock_stat, 397f20786ffSPeter Zijlstra .maxlen = sizeof(int), 398f20786ffSPeter Zijlstra .mode = 0644, 3996d456111SEric W. Biederman .proc_handler = proc_dointvec, 400f20786ffSPeter Zijlstra }, 401f20786ffSPeter Zijlstra #endif 40277e54a1fSIngo Molnar { 4031da177e4SLinus Torvalds .procname = "panic", 4041da177e4SLinus Torvalds .data = &panic_timeout, 4051da177e4SLinus Torvalds .maxlen = sizeof(int), 4061da177e4SLinus Torvalds .mode = 0644, 4076d456111SEric W. Biederman .proc_handler = proc_dointvec, 4081da177e4SLinus Torvalds }, 4091da177e4SLinus Torvalds { 4101da177e4SLinus Torvalds .procname = "core_uses_pid", 4111da177e4SLinus Torvalds .data = &core_uses_pid, 4121da177e4SLinus Torvalds .maxlen = sizeof(int), 4131da177e4SLinus Torvalds .mode = 0644, 4146d456111SEric W. Biederman .proc_handler = proc_dointvec, 4151da177e4SLinus Torvalds }, 4161da177e4SLinus Torvalds { 4171da177e4SLinus Torvalds .procname = "core_pattern", 4181da177e4SLinus Torvalds .data = core_pattern, 41971ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4201da177e4SLinus Torvalds .mode = 0644, 4216d456111SEric W. Biederman .proc_handler = proc_dostring, 4221da177e4SLinus Torvalds }, 423a293980cSNeil Horman { 424a293980cSNeil Horman .procname = "core_pipe_limit", 425a293980cSNeil Horman .data = &core_pipe_limit, 426a293980cSNeil Horman .maxlen = sizeof(unsigned int), 427a293980cSNeil Horman .mode = 0644, 4286d456111SEric W. Biederman .proc_handler = proc_dointvec, 429a293980cSNeil Horman }, 43034f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4311da177e4SLinus Torvalds { 4321da177e4SLinus Torvalds .procname = "tainted", 43325ddbb18SAndi Kleen .maxlen = sizeof(long), 43434f5a398STheodore Ts'o .mode = 0644, 4356d456111SEric W. Biederman .proc_handler = proc_taint, 4361da177e4SLinus Torvalds }, 43734f5a398STheodore Ts'o #endif 4389745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4399745512cSArjan van de Ven { 4409745512cSArjan van de Ven .procname = "latencytop", 4419745512cSArjan van de Ven .data = &latencytop_enabled, 4429745512cSArjan van de Ven .maxlen = sizeof(int), 4439745512cSArjan van de Ven .mode = 0644, 4446d456111SEric W. Biederman .proc_handler = proc_dointvec, 4459745512cSArjan van de Ven }, 4469745512cSArjan van de Ven #endif 4471da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4481da177e4SLinus Torvalds { 4491da177e4SLinus Torvalds .procname = "real-root-dev", 4501da177e4SLinus Torvalds .data = &real_root_dev, 4511da177e4SLinus Torvalds .maxlen = sizeof(int), 4521da177e4SLinus Torvalds .mode = 0644, 4536d456111SEric W. Biederman .proc_handler = proc_dointvec, 4541da177e4SLinus Torvalds }, 4551da177e4SLinus Torvalds #endif 45645807a1dSIngo Molnar { 45745807a1dSIngo Molnar .procname = "print-fatal-signals", 45845807a1dSIngo Molnar .data = &print_fatal_signals, 45945807a1dSIngo Molnar .maxlen = sizeof(int), 46045807a1dSIngo Molnar .mode = 0644, 4616d456111SEric W. Biederman .proc_handler = proc_dointvec, 46245807a1dSIngo Molnar }, 46372c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4641da177e4SLinus Torvalds { 4651da177e4SLinus Torvalds .procname = "reboot-cmd", 4661da177e4SLinus Torvalds .data = reboot_command, 4671da177e4SLinus Torvalds .maxlen = 256, 4681da177e4SLinus Torvalds .mode = 0644, 4696d456111SEric W. Biederman .proc_handler = proc_dostring, 4701da177e4SLinus Torvalds }, 4711da177e4SLinus Torvalds { 4721da177e4SLinus Torvalds .procname = "stop-a", 4731da177e4SLinus Torvalds .data = &stop_a_enabled, 4741da177e4SLinus Torvalds .maxlen = sizeof (int), 4751da177e4SLinus Torvalds .mode = 0644, 4766d456111SEric W. Biederman .proc_handler = proc_dointvec, 4771da177e4SLinus Torvalds }, 4781da177e4SLinus Torvalds { 4791da177e4SLinus Torvalds .procname = "scons-poweroff", 4801da177e4SLinus Torvalds .data = &scons_pwroff, 4811da177e4SLinus Torvalds .maxlen = sizeof (int), 4821da177e4SLinus Torvalds .mode = 0644, 4836d456111SEric W. Biederman .proc_handler = proc_dointvec, 4841da177e4SLinus Torvalds }, 4851da177e4SLinus Torvalds #endif 4860871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4870871420fSDavid S. Miller { 4880871420fSDavid S. Miller .procname = "tsb-ratio", 4890871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4900871420fSDavid S. Miller .maxlen = sizeof (int), 4910871420fSDavid S. Miller .mode = 0644, 4926d456111SEric W. Biederman .proc_handler = proc_dointvec, 4930871420fSDavid S. Miller }, 4940871420fSDavid S. Miller #endif 4951da177e4SLinus Torvalds #ifdef __hppa__ 4961da177e4SLinus Torvalds { 4971da177e4SLinus Torvalds .procname = "soft-power", 4981da177e4SLinus Torvalds .data = &pwrsw_enabled, 4991da177e4SLinus Torvalds .maxlen = sizeof (int), 5001da177e4SLinus Torvalds .mode = 0644, 5016d456111SEric W. Biederman .proc_handler = proc_dointvec, 5021da177e4SLinus Torvalds }, 5031da177e4SLinus Torvalds { 5041da177e4SLinus Torvalds .procname = "unaligned-trap", 5051da177e4SLinus Torvalds .data = &unaligned_enabled, 5061da177e4SLinus Torvalds .maxlen = sizeof (int), 5071da177e4SLinus Torvalds .mode = 0644, 5086d456111SEric W. Biederman .proc_handler = proc_dointvec, 5091da177e4SLinus Torvalds }, 5101da177e4SLinus Torvalds #endif 5111da177e4SLinus Torvalds { 5121da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5131da177e4SLinus Torvalds .data = &C_A_D, 5141da177e4SLinus Torvalds .maxlen = sizeof(int), 5151da177e4SLinus Torvalds .mode = 0644, 5166d456111SEric W. Biederman .proc_handler = proc_dointvec, 5171da177e4SLinus Torvalds }, 518606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 519b0fc494fSSteven Rostedt { 520b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 521b0fc494fSSteven Rostedt .data = &ftrace_enabled, 522b0fc494fSSteven Rostedt .maxlen = sizeof(int), 523b0fc494fSSteven Rostedt .mode = 0644, 5246d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 525b0fc494fSSteven Rostedt }, 526b0fc494fSSteven Rostedt #endif 527f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 528f38f1d2aSSteven Rostedt { 529f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 530f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 531f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 532f38f1d2aSSteven Rostedt .mode = 0644, 5336d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 534f38f1d2aSSteven Rostedt }, 535f38f1d2aSSteven Rostedt #endif 536944ac425SSteven Rostedt #ifdef CONFIG_TRACING 537944ac425SSteven Rostedt { 5383299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 539944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 540944ac425SSteven Rostedt .maxlen = sizeof(int), 541944ac425SSteven Rostedt .mode = 0644, 5426d456111SEric W. Biederman .proc_handler = proc_dointvec, 543944ac425SSteven Rostedt }, 544944ac425SSteven Rostedt #endif 545a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5461da177e4SLinus Torvalds { 5471da177e4SLinus Torvalds .procname = "modprobe", 5481da177e4SLinus Torvalds .data = &modprobe_path, 5491da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5501da177e4SLinus Torvalds .mode = 0644, 5516d456111SEric W. Biederman .proc_handler = proc_dostring, 5521da177e4SLinus Torvalds }, 5533d43321bSKees Cook { 5543d43321bSKees Cook .procname = "modules_disabled", 5553d43321bSKees Cook .data = &modules_disabled, 5563d43321bSKees Cook .maxlen = sizeof(int), 5573d43321bSKees Cook .mode = 0644, 5583d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5596d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5603d43321bSKees Cook .extra1 = &one, 5613d43321bSKees Cook .extra2 = &one, 5623d43321bSKees Cook }, 5631da177e4SLinus Torvalds #endif 56494f17cd7SIan Abbott #ifdef CONFIG_HOTPLUG 5651da177e4SLinus Torvalds { 5661da177e4SLinus Torvalds .procname = "hotplug", 567312c004dSKay Sievers .data = &uevent_helper, 568312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5691da177e4SLinus Torvalds .mode = 0644, 5706d456111SEric W. Biederman .proc_handler = proc_dostring, 5711da177e4SLinus Torvalds }, 5721da177e4SLinus Torvalds #endif 5731da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5741da177e4SLinus Torvalds { 5751da177e4SLinus Torvalds .procname = "sg-big-buff", 5761da177e4SLinus Torvalds .data = &sg_big_buff, 5771da177e4SLinus Torvalds .maxlen = sizeof (int), 5781da177e4SLinus Torvalds .mode = 0444, 5796d456111SEric W. Biederman .proc_handler = proc_dointvec, 5801da177e4SLinus Torvalds }, 5811da177e4SLinus Torvalds #endif 5821da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5831da177e4SLinus Torvalds { 5841da177e4SLinus Torvalds .procname = "acct", 5851da177e4SLinus Torvalds .data = &acct_parm, 5861da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5871da177e4SLinus Torvalds .mode = 0644, 5886d456111SEric W. Biederman .proc_handler = proc_dointvec, 5891da177e4SLinus Torvalds }, 5901da177e4SLinus Torvalds #endif 5911da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5921da177e4SLinus Torvalds { 5931da177e4SLinus Torvalds .procname = "sysrq", 5945d6f647fSIngo Molnar .data = &__sysrq_enabled, 5951da177e4SLinus Torvalds .maxlen = sizeof (int), 5961da177e4SLinus Torvalds .mode = 0644, 59797f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 5981da177e4SLinus Torvalds }, 5991da177e4SLinus Torvalds #endif 600d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 6011da177e4SLinus Torvalds { 6021da177e4SLinus Torvalds .procname = "cad_pid", 6039ec52099SCedric Le Goater .data = NULL, 6041da177e4SLinus Torvalds .maxlen = sizeof (int), 6051da177e4SLinus Torvalds .mode = 0600, 6066d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 6071da177e4SLinus Torvalds }, 608d6f8ff73SRandy Dunlap #endif 6091da177e4SLinus Torvalds { 6101da177e4SLinus Torvalds .procname = "threads-max", 6111da177e4SLinus Torvalds .data = &max_threads, 6121da177e4SLinus Torvalds .maxlen = sizeof(int), 6131da177e4SLinus Torvalds .mode = 0644, 6146d456111SEric W. Biederman .proc_handler = proc_dointvec, 6151da177e4SLinus Torvalds }, 6161da177e4SLinus Torvalds { 6171da177e4SLinus Torvalds .procname = "random", 6181da177e4SLinus Torvalds .mode = 0555, 6191da177e4SLinus Torvalds .child = random_table, 6201da177e4SLinus Torvalds }, 6211da177e4SLinus Torvalds { 6221da177e4SLinus Torvalds .procname = "overflowuid", 6231da177e4SLinus Torvalds .data = &overflowuid, 6241da177e4SLinus Torvalds .maxlen = sizeof(int), 6251da177e4SLinus Torvalds .mode = 0644, 6266d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6271da177e4SLinus Torvalds .extra1 = &minolduid, 6281da177e4SLinus Torvalds .extra2 = &maxolduid, 6291da177e4SLinus Torvalds }, 6301da177e4SLinus Torvalds { 6311da177e4SLinus Torvalds .procname = "overflowgid", 6321da177e4SLinus Torvalds .data = &overflowgid, 6331da177e4SLinus Torvalds .maxlen = sizeof(int), 6341da177e4SLinus Torvalds .mode = 0644, 6356d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6361da177e4SLinus Torvalds .extra1 = &minolduid, 6371da177e4SLinus Torvalds .extra2 = &maxolduid, 6381da177e4SLinus Torvalds }, 639347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6401da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6411da177e4SLinus Torvalds { 6421da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6431da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6441da177e4SLinus Torvalds .maxlen = sizeof(int), 6451da177e4SLinus Torvalds .mode = 0644, 6466d456111SEric W. Biederman .proc_handler = proc_dointvec, 6471da177e4SLinus Torvalds }, 6481da177e4SLinus Torvalds #endif 6491da177e4SLinus Torvalds { 6501da177e4SLinus Torvalds .procname = "userprocess_debug", 651ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 6521da177e4SLinus Torvalds .maxlen = sizeof(int), 6531da177e4SLinus Torvalds .mode = 0644, 6546d456111SEric W. Biederman .proc_handler = proc_dointvec, 6551da177e4SLinus Torvalds }, 6561da177e4SLinus Torvalds #endif 6571da177e4SLinus Torvalds { 6581da177e4SLinus Torvalds .procname = "pid_max", 6591da177e4SLinus Torvalds .data = &pid_max, 6601da177e4SLinus Torvalds .maxlen = sizeof (int), 6611da177e4SLinus Torvalds .mode = 0644, 6626d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6631da177e4SLinus Torvalds .extra1 = &pid_max_min, 6641da177e4SLinus Torvalds .extra2 = &pid_max_max, 6651da177e4SLinus Torvalds }, 6661da177e4SLinus Torvalds { 6671da177e4SLinus Torvalds .procname = "panic_on_oops", 6681da177e4SLinus Torvalds .data = &panic_on_oops, 6691da177e4SLinus Torvalds .maxlen = sizeof(int), 6701da177e4SLinus Torvalds .mode = 0644, 6716d456111SEric W. Biederman .proc_handler = proc_dointvec, 6721da177e4SLinus Torvalds }, 6737ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6747ef3d2fdSJoe Perches { 6757ef3d2fdSJoe Perches .procname = "printk", 6767ef3d2fdSJoe Perches .data = &console_loglevel, 6777ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6787ef3d2fdSJoe Perches .mode = 0644, 6796d456111SEric W. Biederman .proc_handler = proc_dointvec, 6807ef3d2fdSJoe Perches }, 6811da177e4SLinus Torvalds { 6821da177e4SLinus Torvalds .procname = "printk_ratelimit", 683717115e1SDave Young .data = &printk_ratelimit_state.interval, 6841da177e4SLinus Torvalds .maxlen = sizeof(int), 6851da177e4SLinus Torvalds .mode = 0644, 6866d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6871da177e4SLinus Torvalds }, 6881da177e4SLinus Torvalds { 6891da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 690717115e1SDave Young .data = &printk_ratelimit_state.burst, 6911da177e4SLinus Torvalds .maxlen = sizeof(int), 6921da177e4SLinus Torvalds .mode = 0644, 6936d456111SEric W. Biederman .proc_handler = proc_dointvec, 6941da177e4SLinus Torvalds }, 695af91322eSDave Young { 696af91322eSDave Young .procname = "printk_delay", 697af91322eSDave Young .data = &printk_delay_msec, 698af91322eSDave Young .maxlen = sizeof(int), 699af91322eSDave Young .mode = 0644, 7006d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 701af91322eSDave Young .extra1 = &zero, 702af91322eSDave Young .extra2 = &ten_thousand, 703af91322eSDave Young }, 7041da177e4SLinus Torvalds { 705eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 706eaf06b24SDan Rosenberg .data = &dmesg_restrict, 707eaf06b24SDan Rosenberg .maxlen = sizeof(int), 708eaf06b24SDan Rosenberg .mode = 0644, 709eaf06b24SDan Rosenberg .proc_handler = proc_dointvec_minmax, 710eaf06b24SDan Rosenberg .extra1 = &zero, 711eaf06b24SDan Rosenberg .extra2 = &one, 712eaf06b24SDan Rosenberg }, 713df6e61d4SJoe Perches #endif 714eaf06b24SDan Rosenberg { 7151da177e4SLinus Torvalds .procname = "ngroups_max", 7161da177e4SLinus Torvalds .data = &ngroups_max, 7171da177e4SLinus Torvalds .maxlen = sizeof (int), 7181da177e4SLinus Torvalds .mode = 0444, 7196d456111SEric W. Biederman .proc_handler = proc_dointvec, 7201da177e4SLinus Torvalds }, 72158687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 722504d7cf1SDon Zickus { 72358687acbSDon Zickus .procname = "watchdog", 72458687acbSDon Zickus .data = &watchdog_enabled, 725504d7cf1SDon Zickus .maxlen = sizeof (int), 726504d7cf1SDon Zickus .mode = 0644, 72758687acbSDon Zickus .proc_handler = proc_dowatchdog_enabled, 72858687acbSDon Zickus }, 72958687acbSDon Zickus { 73058687acbSDon Zickus .procname = "watchdog_thresh", 73158687acbSDon Zickus .data = &softlockup_thresh, 73258687acbSDon Zickus .maxlen = sizeof(int), 73358687acbSDon Zickus .mode = 0644, 73458687acbSDon Zickus .proc_handler = proc_dowatchdog_thresh, 73558687acbSDon Zickus .extra1 = &neg_one, 73658687acbSDon Zickus .extra2 = &sixty, 737504d7cf1SDon Zickus }, 7382508ce18SDon Zickus { 7392508ce18SDon Zickus .procname = "softlockup_panic", 7402508ce18SDon Zickus .data = &softlockup_panic, 7412508ce18SDon Zickus .maxlen = sizeof(int), 7422508ce18SDon Zickus .mode = 0644, 7432508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 7442508ce18SDon Zickus .extra1 = &zero, 7452508ce18SDon Zickus .extra2 = &one, 7462508ce18SDon Zickus }, 747504d7cf1SDon Zickus #endif 74858687acbSDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) && !defined(CONFIG_LOCKUP_DETECTOR) 7491da177e4SLinus Torvalds { 7501da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 7511da177e4SLinus Torvalds .data = &unknown_nmi_panic, 7521da177e4SLinus Torvalds .maxlen = sizeof (int), 7531da177e4SLinus Torvalds .mode = 0644, 7546d456111SEric W. Biederman .proc_handler = proc_dointvec, 7551da177e4SLinus Torvalds }, 756407984f1SDon Zickus { 757407984f1SDon Zickus .procname = "nmi_watchdog", 758407984f1SDon Zickus .data = &nmi_watchdog_enabled, 759407984f1SDon Zickus .maxlen = sizeof (int), 760407984f1SDon Zickus .mode = 0644, 7616d456111SEric W. Biederman .proc_handler = proc_nmi_enabled, 7621da177e4SLinus Torvalds }, 7631da177e4SLinus Torvalds #endif 7641da177e4SLinus Torvalds #if defined(CONFIG_X86) 7651da177e4SLinus Torvalds { 7668da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7678da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7688da5addaSDon Zickus .maxlen = sizeof(int), 7698da5addaSDon Zickus .mode = 0644, 7706d456111SEric W. Biederman .proc_handler = proc_dointvec, 7718da5addaSDon Zickus }, 7728da5addaSDon Zickus { 7735211a242SKurt Garloff .procname = "panic_on_io_nmi", 7745211a242SKurt Garloff .data = &panic_on_io_nmi, 7755211a242SKurt Garloff .maxlen = sizeof(int), 7765211a242SKurt Garloff .mode = 0644, 7776d456111SEric W. Biederman .proc_handler = proc_dointvec, 7785211a242SKurt Garloff }, 7795211a242SKurt Garloff { 7801da177e4SLinus Torvalds .procname = "bootloader_type", 7811da177e4SLinus Torvalds .data = &bootloader_type, 7821da177e4SLinus Torvalds .maxlen = sizeof (int), 7831da177e4SLinus Torvalds .mode = 0444, 7846d456111SEric W. Biederman .proc_handler = proc_dointvec, 7851da177e4SLinus Torvalds }, 7860741f4d2SChuck Ebbert { 7875031296cSH. Peter Anvin .procname = "bootloader_version", 7885031296cSH. Peter Anvin .data = &bootloader_version, 7895031296cSH. Peter Anvin .maxlen = sizeof (int), 7905031296cSH. Peter Anvin .mode = 0444, 7916d456111SEric W. Biederman .proc_handler = proc_dointvec, 7925031296cSH. Peter Anvin }, 7935031296cSH. Peter Anvin { 7940741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 7950741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 7960741f4d2SChuck Ebbert .maxlen = sizeof(int), 7970741f4d2SChuck Ebbert .mode = 0644, 7986d456111SEric W. Biederman .proc_handler = proc_dointvec, 7990741f4d2SChuck Ebbert }, 8006e7c4025SIngo Molnar { 8016e7c4025SIngo Molnar .procname = "io_delay_type", 8026e7c4025SIngo Molnar .data = &io_delay_type, 8036e7c4025SIngo Molnar .maxlen = sizeof(int), 8046e7c4025SIngo Molnar .mode = 0644, 8056d456111SEric W. Biederman .proc_handler = proc_dointvec, 8066e7c4025SIngo Molnar }, 8071da177e4SLinus Torvalds #endif 8087a9166e3SLuke Yang #if defined(CONFIG_MMU) 8091da177e4SLinus Torvalds { 8101da177e4SLinus Torvalds .procname = "randomize_va_space", 8111da177e4SLinus Torvalds .data = &randomize_va_space, 8121da177e4SLinus Torvalds .maxlen = sizeof(int), 8131da177e4SLinus Torvalds .mode = 0644, 8146d456111SEric W. Biederman .proc_handler = proc_dointvec, 8151da177e4SLinus Torvalds }, 8167a9166e3SLuke Yang #endif 8170152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 818951f22d5SMartin Schwidefsky { 819951f22d5SMartin Schwidefsky .procname = "spin_retry", 820951f22d5SMartin Schwidefsky .data = &spin_retry, 821951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 822951f22d5SMartin Schwidefsky .mode = 0644, 8236d456111SEric W. Biederman .proc_handler = proc_dointvec, 824951f22d5SMartin Schwidefsky }, 825951f22d5SMartin Schwidefsky #endif 826673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 827c255d844SPavel Machek { 828c255d844SPavel Machek .procname = "acpi_video_flags", 82977afcf78SPavel Machek .data = &acpi_realmode_flags, 830c255d844SPavel Machek .maxlen = sizeof (unsigned long), 831c255d844SPavel Machek .mode = 0644, 8326d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 833c255d844SPavel Machek }, 834c255d844SPavel Machek #endif 835d2b176edSJes Sorensen #ifdef CONFIG_IA64 836d2b176edSJes Sorensen { 837d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 838d2b176edSJes Sorensen .data = &no_unaligned_warning, 839d2b176edSJes Sorensen .maxlen = sizeof (int), 840d2b176edSJes Sorensen .mode = 0644, 8416d456111SEric W. Biederman .proc_handler = proc_dointvec, 842d2b176edSJes Sorensen }, 84388fc241fSDoug Chapman { 84488fc241fSDoug Chapman .procname = "unaligned-dump-stack", 84588fc241fSDoug Chapman .data = &unaligned_dump_stack, 84688fc241fSDoug Chapman .maxlen = sizeof (int), 84788fc241fSDoug Chapman .mode = 0644, 8486d456111SEric W. Biederman .proc_handler = proc_dointvec, 84988fc241fSDoug Chapman }, 850d2b176edSJes Sorensen #endif 851e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 852e162b39aSMandeep Singh Baines { 853e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 854e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 855e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 856e162b39aSMandeep Singh Baines .mode = 0644, 8576d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 858e162b39aSMandeep Singh Baines .extra1 = &zero, 859e162b39aSMandeep Singh Baines .extra2 = &one, 860e162b39aSMandeep Singh Baines }, 86182a1fcb9SIngo Molnar { 86282a1fcb9SIngo Molnar .procname = "hung_task_check_count", 86382a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 86490739081SIngo Molnar .maxlen = sizeof(unsigned long), 86582a1fcb9SIngo Molnar .mode = 0644, 8666d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 86782a1fcb9SIngo Molnar }, 86882a1fcb9SIngo Molnar { 86982a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 87082a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 87190739081SIngo Molnar .maxlen = sizeof(unsigned long), 87282a1fcb9SIngo Molnar .mode = 0644, 8736d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 87482a1fcb9SIngo Molnar }, 87582a1fcb9SIngo Molnar { 87682a1fcb9SIngo Molnar .procname = "hung_task_warnings", 87782a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 87890739081SIngo Molnar .maxlen = sizeof(unsigned long), 87982a1fcb9SIngo Molnar .mode = 0644, 8806d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 88182a1fcb9SIngo Molnar }, 882c4f3b63fSRavikiran G Thirumalai #endif 883bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 884bebfa101SAndi Kleen { 885bebfa101SAndi Kleen .procname = "compat-log", 886bebfa101SAndi Kleen .data = &compat_log, 887bebfa101SAndi Kleen .maxlen = sizeof (int), 888bebfa101SAndi Kleen .mode = 0644, 8896d456111SEric W. Biederman .proc_handler = proc_dointvec, 890bebfa101SAndi Kleen }, 891bebfa101SAndi Kleen #endif 89223f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 89323f78d4aSIngo Molnar { 89423f78d4aSIngo Molnar .procname = "max_lock_depth", 89523f78d4aSIngo Molnar .data = &max_lock_depth, 89623f78d4aSIngo Molnar .maxlen = sizeof(int), 89723f78d4aSIngo Molnar .mode = 0644, 8986d456111SEric W. Biederman .proc_handler = proc_dointvec, 89923f78d4aSIngo Molnar }, 90023f78d4aSIngo Molnar #endif 90110a0a8d4SJeremy Fitzhardinge { 90210a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 90310a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 90410a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 90510a0a8d4SJeremy Fitzhardinge .mode = 0644, 9066d456111SEric W. Biederman .proc_handler = proc_dostring, 90710a0a8d4SJeremy Fitzhardinge }, 9080b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9090b77f5bfSDavid Howells { 9100b77f5bfSDavid Howells .procname = "keys", 9110b77f5bfSDavid Howells .mode = 0555, 9120b77f5bfSDavid Howells .child = key_sysctls, 9130b77f5bfSDavid Howells }, 9140b77f5bfSDavid Howells #endif 91531a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 91631a72bceSPaul E. McKenney { 91731a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 91831a72bceSPaul E. McKenney .data = &rcutorture_runnable, 91931a72bceSPaul E. McKenney .maxlen = sizeof(int), 92031a72bceSPaul E. McKenney .mode = 0644, 9216d456111SEric W. Biederman .proc_handler = proc_dointvec, 92231a72bceSPaul E. McKenney }, 92331a72bceSPaul E. McKenney #endif 924cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 9251ccd1549SPeter Zijlstra { 926cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 927cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 928cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9291ccd1549SPeter Zijlstra .mode = 0644, 9306d456111SEric W. Biederman .proc_handler = proc_dointvec, 9311ccd1549SPeter Zijlstra }, 932c5078f78SPeter Zijlstra { 933cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 934cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 935cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 936c5078f78SPeter Zijlstra .mode = 0644, 9376d456111SEric W. Biederman .proc_handler = proc_dointvec, 938c5078f78SPeter Zijlstra }, 939a78ac325SPeter Zijlstra { 940cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 941cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 942cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 943a78ac325SPeter Zijlstra .mode = 0644, 9446d456111SEric W. Biederman .proc_handler = proc_dointvec, 945a78ac325SPeter Zijlstra }, 9461ccd1549SPeter Zijlstra #endif 947dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 948dfec072eSVegard Nossum { 949dfec072eSVegard Nossum .procname = "kmemcheck", 950dfec072eSVegard Nossum .data = &kmemcheck_enabled, 951dfec072eSVegard Nossum .maxlen = sizeof(int), 952dfec072eSVegard Nossum .mode = 0644, 9536d456111SEric W. Biederman .proc_handler = proc_dointvec, 954dfec072eSVegard Nossum }, 955dfec072eSVegard Nossum #endif 956cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9575e605b64SJens Axboe { 9585e605b64SJens Axboe .procname = "blk_iopoll", 9595e605b64SJens Axboe .data = &blk_iopoll_enabled, 9605e605b64SJens Axboe .maxlen = sizeof(int), 9615e605b64SJens Axboe .mode = 0644, 9626d456111SEric W. Biederman .proc_handler = proc_dointvec, 9635e605b64SJens Axboe }, 964cb684b5bSJens Axboe #endif 965ed2c12f3SAndrew Morton /* 966ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 967ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 968ed2c12f3SAndrew Morton */ 9696fce56ecSEric W. Biederman { } 9701da177e4SLinus Torvalds }; 9711da177e4SLinus Torvalds 972d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 9731da177e4SLinus Torvalds { 9741da177e4SLinus Torvalds .procname = "overcommit_memory", 9751da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 9761da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 9771da177e4SLinus Torvalds .mode = 0644, 9786d456111SEric W. Biederman .proc_handler = proc_dointvec, 9791da177e4SLinus Torvalds }, 9801da177e4SLinus Torvalds { 981fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 982fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 983fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 984fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 9856d456111SEric W. Biederman .proc_handler = proc_dointvec, 986fadd8fbdSKAMEZAWA Hiroyuki }, 987fadd8fbdSKAMEZAWA Hiroyuki { 988fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 989fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 990fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 991fe071d7eSDavid Rientjes .mode = 0644, 9926d456111SEric W. Biederman .proc_handler = proc_dointvec, 993fe071d7eSDavid Rientjes }, 994fe071d7eSDavid Rientjes { 995fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 996fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 997fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 998fef1bdd6SDavid Rientjes .mode = 0644, 9996d456111SEric W. Biederman .proc_handler = proc_dointvec, 1000fef1bdd6SDavid Rientjes }, 1001fef1bdd6SDavid Rientjes { 10021da177e4SLinus Torvalds .procname = "overcommit_ratio", 10031da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10041da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10051da177e4SLinus Torvalds .mode = 0644, 10066d456111SEric W. Biederman .proc_handler = proc_dointvec, 10071da177e4SLinus Torvalds }, 10081da177e4SLinus Torvalds { 10091da177e4SLinus Torvalds .procname = "page-cluster", 10101da177e4SLinus Torvalds .data = &page_cluster, 10111da177e4SLinus Torvalds .maxlen = sizeof(int), 10121da177e4SLinus Torvalds .mode = 0644, 10136d456111SEric W. Biederman .proc_handler = proc_dointvec, 10141da177e4SLinus Torvalds }, 10151da177e4SLinus Torvalds { 10161da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10171da177e4SLinus Torvalds .data = &dirty_background_ratio, 10181da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10191da177e4SLinus Torvalds .mode = 0644, 10206d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 10211da177e4SLinus Torvalds .extra1 = &zero, 10221da177e4SLinus Torvalds .extra2 = &one_hundred, 10231da177e4SLinus Torvalds }, 10241da177e4SLinus Torvalds { 10252da02997SDavid Rientjes .procname = "dirty_background_bytes", 10262da02997SDavid Rientjes .data = &dirty_background_bytes, 10272da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10282da02997SDavid Rientjes .mode = 0644, 10296d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1030fc3501d4SSven Wegener .extra1 = &one_ul, 10312da02997SDavid Rientjes }, 10322da02997SDavid Rientjes { 10331da177e4SLinus Torvalds .procname = "dirty_ratio", 10341da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10351da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10361da177e4SLinus Torvalds .mode = 0644, 10376d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10381da177e4SLinus Torvalds .extra1 = &zero, 10391da177e4SLinus Torvalds .extra2 = &one_hundred, 10401da177e4SLinus Torvalds }, 10411da177e4SLinus Torvalds { 10422da02997SDavid Rientjes .procname = "dirty_bytes", 10432da02997SDavid Rientjes .data = &vm_dirty_bytes, 10442da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10452da02997SDavid Rientjes .mode = 0644, 10466d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10479e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10482da02997SDavid Rientjes }, 10492da02997SDavid Rientjes { 10501da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1051f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1052f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10531da177e4SLinus Torvalds .mode = 0644, 10546d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10551da177e4SLinus Torvalds }, 10561da177e4SLinus Torvalds { 10571da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1058f6ef9438SBart Samwel .data = &dirty_expire_interval, 1059f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10601da177e4SLinus Torvalds .mode = 0644, 10616d456111SEric W. Biederman .proc_handler = proc_dointvec, 10621da177e4SLinus Torvalds }, 10631da177e4SLinus Torvalds { 10641da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10651da177e4SLinus Torvalds .data = &nr_pdflush_threads, 10661da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 10671da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 10686d456111SEric W. Biederman .proc_handler = proc_dointvec, 10691da177e4SLinus Torvalds }, 10701da177e4SLinus Torvalds { 10711da177e4SLinus Torvalds .procname = "swappiness", 10721da177e4SLinus Torvalds .data = &vm_swappiness, 10731da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 10741da177e4SLinus Torvalds .mode = 0644, 10756d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 10761da177e4SLinus Torvalds .extra1 = &zero, 10771da177e4SLinus Torvalds .extra2 = &one_hundred, 10781da177e4SLinus Torvalds }, 10791da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 10801da177e4SLinus Torvalds { 10811da177e4SLinus Torvalds .procname = "nr_hugepages", 1082e5ff2159SAndi Kleen .data = NULL, 10831da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 10841da177e4SLinus Torvalds .mode = 0644, 10856d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 10861da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 10871da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 10881da177e4SLinus Torvalds }, 108906808b08SLee Schermerhorn #ifdef CONFIG_NUMA 109006808b08SLee Schermerhorn { 109106808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 109206808b08SLee Schermerhorn .data = NULL, 109306808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 109406808b08SLee Schermerhorn .mode = 0644, 109506808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 109606808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 109706808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 109806808b08SLee Schermerhorn }, 109906808b08SLee Schermerhorn #endif 11001da177e4SLinus Torvalds { 11011da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11021da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11031da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11041da177e4SLinus Torvalds .mode = 0644, 11056d456111SEric W. Biederman .proc_handler = proc_dointvec, 11061da177e4SLinus Torvalds }, 1107396faf03SMel Gorman { 1108396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1109396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1110396faf03SMel Gorman .maxlen = sizeof(int), 1111396faf03SMel Gorman .mode = 0644, 11126d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1113396faf03SMel Gorman }, 111454f9f80dSAdam Litke { 1115d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1116e5ff2159SAndi Kleen .data = NULL, 1117e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1118d1c3fb1fSNishanth Aravamudan .mode = 0644, 11196d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1120e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1121e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1122d1c3fb1fSNishanth Aravamudan }, 11231da177e4SLinus Torvalds #endif 11241da177e4SLinus Torvalds { 11251da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11261da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11271da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11281da177e4SLinus Torvalds .mode = 0644, 11296d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11301da177e4SLinus Torvalds }, 11311da177e4SLinus Torvalds { 11329d0243bcSAndrew Morton .procname = "drop_caches", 11339d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11349d0243bcSAndrew Morton .maxlen = sizeof(int), 11359d0243bcSAndrew Morton .mode = 0644, 11369d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 11379d0243bcSAndrew Morton }, 113876ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 113976ab0f53SMel Gorman { 114076ab0f53SMel Gorman .procname = "compact_memory", 114176ab0f53SMel Gorman .data = &sysctl_compact_memory, 114276ab0f53SMel Gorman .maxlen = sizeof(int), 114376ab0f53SMel Gorman .mode = 0200, 114476ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 114576ab0f53SMel Gorman }, 11465e771905SMel Gorman { 11475e771905SMel Gorman .procname = "extfrag_threshold", 11485e771905SMel Gorman .data = &sysctl_extfrag_threshold, 11495e771905SMel Gorman .maxlen = sizeof(int), 11505e771905SMel Gorman .mode = 0644, 11515e771905SMel Gorman .proc_handler = sysctl_extfrag_handler, 11525e771905SMel Gorman .extra1 = &min_extfrag_threshold, 11535e771905SMel Gorman .extra2 = &max_extfrag_threshold, 11545e771905SMel Gorman }, 11555e771905SMel Gorman 115676ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 11579d0243bcSAndrew Morton { 11581da177e4SLinus Torvalds .procname = "min_free_kbytes", 11591da177e4SLinus Torvalds .data = &min_free_kbytes, 11601da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11611da177e4SLinus Torvalds .mode = 0644, 11626d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 11631da177e4SLinus Torvalds .extra1 = &zero, 11641da177e4SLinus Torvalds }, 11658ad4b1fbSRohit Seth { 11668ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 11678ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 11688ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 11698ad4b1fbSRohit Seth .mode = 0644, 11706d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 11718ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 11728ad4b1fbSRohit Seth }, 11731da177e4SLinus Torvalds #ifdef CONFIG_MMU 11741da177e4SLinus Torvalds { 11751da177e4SLinus Torvalds .procname = "max_map_count", 11761da177e4SLinus Torvalds .data = &sysctl_max_map_count, 11771da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 11781da177e4SLinus Torvalds .mode = 0644, 11793e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 118070da2340SAmerigo Wang .extra1 = &zero, 11811da177e4SLinus Torvalds }, 1182dd8632a1SPaul Mundt #else 1183dd8632a1SPaul Mundt { 1184dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1185dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1186dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1187dd8632a1SPaul Mundt .mode = 0644, 11886d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1189dd8632a1SPaul Mundt .extra1 = &zero, 1190dd8632a1SPaul Mundt }, 11911da177e4SLinus Torvalds #endif 11921da177e4SLinus Torvalds { 11931da177e4SLinus Torvalds .procname = "laptop_mode", 11941da177e4SLinus Torvalds .data = &laptop_mode, 11951da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 11961da177e4SLinus Torvalds .mode = 0644, 11976d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 11981da177e4SLinus Torvalds }, 11991da177e4SLinus Torvalds { 12001da177e4SLinus Torvalds .procname = "block_dump", 12011da177e4SLinus Torvalds .data = &block_dump, 12021da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12031da177e4SLinus Torvalds .mode = 0644, 12046d456111SEric W. Biederman .proc_handler = proc_dointvec, 12051da177e4SLinus Torvalds .extra1 = &zero, 12061da177e4SLinus Torvalds }, 12071da177e4SLinus Torvalds { 12081da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12091da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12101da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12111da177e4SLinus Torvalds .mode = 0644, 12126d456111SEric W. Biederman .proc_handler = proc_dointvec, 12131da177e4SLinus Torvalds .extra1 = &zero, 12141da177e4SLinus Torvalds }, 12151da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12161da177e4SLinus Torvalds { 12171da177e4SLinus Torvalds .procname = "legacy_va_layout", 12181da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12191da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12201da177e4SLinus Torvalds .mode = 0644, 12216d456111SEric W. Biederman .proc_handler = proc_dointvec, 12221da177e4SLinus Torvalds .extra1 = &zero, 12231da177e4SLinus Torvalds }, 12241da177e4SLinus Torvalds #endif 12251743660bSChristoph Lameter #ifdef CONFIG_NUMA 12261743660bSChristoph Lameter { 12271743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12281743660bSChristoph Lameter .data = &zone_reclaim_mode, 12291743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12301743660bSChristoph Lameter .mode = 0644, 12316d456111SEric W. Biederman .proc_handler = proc_dointvec, 1232c84db23cSChristoph Lameter .extra1 = &zero, 12331743660bSChristoph Lameter }, 12349614634fSChristoph Lameter { 12359614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12369614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12379614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12389614634fSChristoph Lameter .mode = 0644, 12396d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 12409614634fSChristoph Lameter .extra1 = &zero, 12419614634fSChristoph Lameter .extra2 = &one_hundred, 12429614634fSChristoph Lameter }, 12430ff38490SChristoph Lameter { 12440ff38490SChristoph Lameter .procname = "min_slab_ratio", 12450ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12460ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12470ff38490SChristoph Lameter .mode = 0644, 12486d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12490ff38490SChristoph Lameter .extra1 = &zero, 12500ff38490SChristoph Lameter .extra2 = &one_hundred, 12510ff38490SChristoph Lameter }, 12521743660bSChristoph Lameter #endif 125377461ab3SChristoph Lameter #ifdef CONFIG_SMP 125477461ab3SChristoph Lameter { 125577461ab3SChristoph Lameter .procname = "stat_interval", 125677461ab3SChristoph Lameter .data = &sysctl_stat_interval, 125777461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 125877461ab3SChristoph Lameter .mode = 0644, 12596d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 126077461ab3SChristoph Lameter }, 126177461ab3SChristoph Lameter #endif 12626e141546SDavid Howells #ifdef CONFIG_MMU 1263ed032189SEric Paris { 1264ed032189SEric Paris .procname = "mmap_min_addr", 1265788084abSEric Paris .data = &dac_mmap_min_addr, 1266ed032189SEric Paris .maxlen = sizeof(unsigned long), 1267ed032189SEric Paris .mode = 0644, 12686d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1269ed032189SEric Paris }, 12706e141546SDavid Howells #endif 1271f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1272f0c0b2b8SKAMEZAWA Hiroyuki { 1273f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1274f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1275f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1276f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 12776d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1278f0c0b2b8SKAMEZAWA Hiroyuki }, 1279f0c0b2b8SKAMEZAWA Hiroyuki #endif 12802b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 12815c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1282e6e5494cSIngo Molnar { 1283e6e5494cSIngo Molnar .procname = "vdso_enabled", 1284e6e5494cSIngo Molnar .data = &vdso_enabled, 1285e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1286e6e5494cSIngo Molnar .mode = 0644, 12876d456111SEric W. Biederman .proc_handler = proc_dointvec, 1288e6e5494cSIngo Molnar .extra1 = &zero, 1289e6e5494cSIngo Molnar }, 1290e6e5494cSIngo Molnar #endif 1291195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1292195cf453SBron Gondwana { 1293195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1294195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1295195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1296195cf453SBron Gondwana .mode = 0644, 12976d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1298195cf453SBron Gondwana .extra1 = &zero, 1299195cf453SBron Gondwana .extra2 = &one, 1300195cf453SBron Gondwana }, 1301195cf453SBron Gondwana #endif 13024be6f6bbSPeter Zijlstra { 13034be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13044be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13054be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13064be6f6bbSPeter Zijlstra .mode = 0644, 13076d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 13084be6f6bbSPeter Zijlstra }, 13096a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 13106a46079cSAndi Kleen { 13116a46079cSAndi Kleen .procname = "memory_failure_early_kill", 13126a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 13136a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 13146a46079cSAndi Kleen .mode = 0644, 13156d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13166a46079cSAndi Kleen .extra1 = &zero, 13176a46079cSAndi Kleen .extra2 = &one, 13186a46079cSAndi Kleen }, 13196a46079cSAndi Kleen { 13206a46079cSAndi Kleen .procname = "memory_failure_recovery", 13216a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 13226a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 13236a46079cSAndi Kleen .mode = 0644, 13246d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13256a46079cSAndi Kleen .extra1 = &zero, 13266a46079cSAndi Kleen .extra2 = &one, 13276a46079cSAndi Kleen }, 13286a46079cSAndi Kleen #endif 13296a46079cSAndi Kleen 13302be7fe07SAndrew Morton /* 13312be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 13322be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 13332be7fe07SAndrew Morton */ 13346fce56ecSEric W. Biederman { } 13351da177e4SLinus Torvalds }; 13361da177e4SLinus Torvalds 13372abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1338d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13396fce56ecSEric W. Biederman { } 13402abc26fcSEric W. Biederman }; 13412abc26fcSEric W. Biederman #endif 13422abc26fcSEric W. Biederman 1343d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13441da177e4SLinus Torvalds { 13451da177e4SLinus Torvalds .procname = "inode-nr", 13461da177e4SLinus Torvalds .data = &inodes_stat, 13471da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13481da177e4SLinus Torvalds .mode = 0444, 1349cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13501da177e4SLinus Torvalds }, 13511da177e4SLinus Torvalds { 13521da177e4SLinus Torvalds .procname = "inode-state", 13531da177e4SLinus Torvalds .data = &inodes_stat, 13541da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13551da177e4SLinus Torvalds .mode = 0444, 1356cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13571da177e4SLinus Torvalds }, 13581da177e4SLinus Torvalds { 13591da177e4SLinus Torvalds .procname = "file-nr", 13601da177e4SLinus Torvalds .data = &files_stat, 1361518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 13621da177e4SLinus Torvalds .mode = 0444, 13636d456111SEric W. Biederman .proc_handler = proc_nr_files, 13641da177e4SLinus Torvalds }, 13651da177e4SLinus Torvalds { 13661da177e4SLinus Torvalds .procname = "file-max", 13671da177e4SLinus Torvalds .data = &files_stat.max_files, 1368518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 13691da177e4SLinus Torvalds .mode = 0644, 1370518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 13711da177e4SLinus Torvalds }, 13721da177e4SLinus Torvalds { 13739cfe015aSEric Dumazet .procname = "nr_open", 13749cfe015aSEric Dumazet .data = &sysctl_nr_open, 13759cfe015aSEric Dumazet .maxlen = sizeof(int), 13769cfe015aSEric Dumazet .mode = 0644, 13776d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1378eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1379eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 13809cfe015aSEric Dumazet }, 13819cfe015aSEric Dumazet { 13821da177e4SLinus Torvalds .procname = "dentry-state", 13831da177e4SLinus Torvalds .data = &dentry_stat, 13841da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 13851da177e4SLinus Torvalds .mode = 0444, 1386312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 13871da177e4SLinus Torvalds }, 13881da177e4SLinus Torvalds { 13891da177e4SLinus Torvalds .procname = "overflowuid", 13901da177e4SLinus Torvalds .data = &fs_overflowuid, 13911da177e4SLinus Torvalds .maxlen = sizeof(int), 13921da177e4SLinus Torvalds .mode = 0644, 13936d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13941da177e4SLinus Torvalds .extra1 = &minolduid, 13951da177e4SLinus Torvalds .extra2 = &maxolduid, 13961da177e4SLinus Torvalds }, 13971da177e4SLinus Torvalds { 13981da177e4SLinus Torvalds .procname = "overflowgid", 13991da177e4SLinus Torvalds .data = &fs_overflowgid, 14001da177e4SLinus Torvalds .maxlen = sizeof(int), 14011da177e4SLinus Torvalds .mode = 0644, 14026d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14031da177e4SLinus Torvalds .extra1 = &minolduid, 14041da177e4SLinus Torvalds .extra2 = &maxolduid, 14051da177e4SLinus Torvalds }, 1406bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14071da177e4SLinus Torvalds { 14081da177e4SLinus Torvalds .procname = "leases-enable", 14091da177e4SLinus Torvalds .data = &leases_enable, 14101da177e4SLinus Torvalds .maxlen = sizeof(int), 14111da177e4SLinus Torvalds .mode = 0644, 14126d456111SEric W. Biederman .proc_handler = proc_dointvec, 14131da177e4SLinus Torvalds }, 1414bfcd17a6SThomas Petazzoni #endif 14151da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14161da177e4SLinus Torvalds { 14171da177e4SLinus Torvalds .procname = "dir-notify-enable", 14181da177e4SLinus Torvalds .data = &dir_notify_enable, 14191da177e4SLinus Torvalds .maxlen = sizeof(int), 14201da177e4SLinus Torvalds .mode = 0644, 14216d456111SEric W. Biederman .proc_handler = proc_dointvec, 14221da177e4SLinus Torvalds }, 14231da177e4SLinus Torvalds #endif 14241da177e4SLinus Torvalds #ifdef CONFIG_MMU 1425bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14261da177e4SLinus Torvalds { 14271da177e4SLinus Torvalds .procname = "lease-break-time", 14281da177e4SLinus Torvalds .data = &lease_break_time, 14291da177e4SLinus Torvalds .maxlen = sizeof(int), 14301da177e4SLinus Torvalds .mode = 0644, 14316d456111SEric W. Biederman .proc_handler = proc_dointvec, 14321da177e4SLinus Torvalds }, 1433bfcd17a6SThomas Petazzoni #endif 1434ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14351da177e4SLinus Torvalds { 14361da177e4SLinus Torvalds .procname = "aio-nr", 14371da177e4SLinus Torvalds .data = &aio_nr, 14381da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14391da177e4SLinus Torvalds .mode = 0444, 14406d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14411da177e4SLinus Torvalds }, 14421da177e4SLinus Torvalds { 14431da177e4SLinus Torvalds .procname = "aio-max-nr", 14441da177e4SLinus Torvalds .data = &aio_max_nr, 14451da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14461da177e4SLinus Torvalds .mode = 0644, 14476d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14481da177e4SLinus Torvalds }, 1449ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14502d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14510399cb08SRobert Love { 14520399cb08SRobert Love .procname = "inotify", 14530399cb08SRobert Love .mode = 0555, 14540399cb08SRobert Love .child = inotify_table, 14550399cb08SRobert Love }, 14560399cb08SRobert Love #endif 14577ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14587ef9964eSDavide Libenzi { 14597ef9964eSDavide Libenzi .procname = "epoll", 14607ef9964eSDavide Libenzi .mode = 0555, 14617ef9964eSDavide Libenzi .child = epoll_table, 14627ef9964eSDavide Libenzi }, 14637ef9964eSDavide Libenzi #endif 14641da177e4SLinus Torvalds #endif 1465d6e71144SAlan Cox { 1466d6e71144SAlan Cox .procname = "suid_dumpable", 1467d6e71144SAlan Cox .data = &suid_dumpable, 1468d6e71144SAlan Cox .maxlen = sizeof(int), 1469d6e71144SAlan Cox .mode = 0644, 14706d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14718e654fbaSMatthew Wilcox .extra1 = &zero, 14728e654fbaSMatthew Wilcox .extra2 = &two, 1473d6e71144SAlan Cox }, 14742abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14752abc26fcSEric W. Biederman { 14762abc26fcSEric W. Biederman .procname = "binfmt_misc", 14772abc26fcSEric W. Biederman .mode = 0555, 14782abc26fcSEric W. Biederman .child = binfmt_misc_table, 14792abc26fcSEric W. Biederman }, 14802abc26fcSEric W. Biederman #endif 1481b492e95bSJens Axboe { 1482ff9da691SJens Axboe .procname = "pipe-max-size", 1483ff9da691SJens Axboe .data = &pipe_max_size, 1484b492e95bSJens Axboe .maxlen = sizeof(int), 1485b492e95bSJens Axboe .mode = 0644, 1486ff9da691SJens Axboe .proc_handler = &pipe_proc_fn, 1487ff9da691SJens Axboe .extra1 = &pipe_min_size, 1488b492e95bSJens Axboe }, 14892be7fe07SAndrew Morton /* 14902be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14912be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14922be7fe07SAndrew Morton */ 14936fce56ecSEric W. Biederman { } 14941da177e4SLinus Torvalds }; 14951da177e4SLinus Torvalds 1496d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1497ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ 1498ab3c68eeSHeiko Carstens defined(CONFIG_S390) 1499abd4f750SMasoud Asgharifard Sharbiani { 1500abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1501abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1502abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1503abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1504abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1505abd4f750SMasoud Asgharifard Sharbiani }, 1506abd4f750SMasoud Asgharifard Sharbiani #endif 1507b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1508b2be84dfSMasami Hiramatsu { 1509b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1510b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1511b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1512b2be84dfSMasami Hiramatsu .mode = 0644, 1513b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1514b2be84dfSMasami Hiramatsu .extra1 = &zero, 1515b2be84dfSMasami Hiramatsu .extra2 = &one, 1516b2be84dfSMasami Hiramatsu }, 1517b2be84dfSMasami Hiramatsu #endif 15186fce56ecSEric W. Biederman { } 15191da177e4SLinus Torvalds }; 15201da177e4SLinus Torvalds 1521d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15226fce56ecSEric W. Biederman { } 15231da177e4SLinus Torvalds }; 15241da177e4SLinus Torvalds 1525330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1526330d57fbSAl Viro 1527330d57fbSAl Viro /* called under sysctl_lock */ 1528330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1529330d57fbSAl Viro { 1530330d57fbSAl Viro if (unlikely(p->unregistering)) 1531330d57fbSAl Viro return 0; 1532330d57fbSAl Viro p->used++; 1533330d57fbSAl Viro return 1; 1534330d57fbSAl Viro } 1535330d57fbSAl Viro 1536330d57fbSAl Viro /* called under sysctl_lock */ 1537330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1538330d57fbSAl Viro { 1539330d57fbSAl Viro if (!--p->used) 1540330d57fbSAl Viro if (unlikely(p->unregistering)) 1541330d57fbSAl Viro complete(p->unregistering); 1542330d57fbSAl Viro } 1543330d57fbSAl Viro 1544330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1545330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1546330d57fbSAl Viro { 1547330d57fbSAl Viro /* 1548330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1549330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1550330d57fbSAl Viro */ 1551330d57fbSAl Viro if (unlikely(p->used)) { 1552330d57fbSAl Viro struct completion wait; 1553330d57fbSAl Viro init_completion(&wait); 1554330d57fbSAl Viro p->unregistering = &wait; 1555330d57fbSAl Viro spin_unlock(&sysctl_lock); 1556330d57fbSAl Viro wait_for_completion(&wait); 1557330d57fbSAl Viro spin_lock(&sysctl_lock); 1558f7e6ced4SAl Viro } else { 1559f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1560f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1561330d57fbSAl Viro } 1562330d57fbSAl Viro /* 1563330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1564330d57fbSAl Viro * list in do_sysctl() relies on that. 1565330d57fbSAl Viro */ 1566330d57fbSAl Viro list_del_init(&p->ctl_entry); 1567330d57fbSAl Viro } 1568330d57fbSAl Viro 1569f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1570f7e6ced4SAl Viro { 1571f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1572f7e6ced4SAl Viro head->count++; 1573f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1574f7e6ced4SAl Viro } 1575f7e6ced4SAl Viro 1576f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1577f7e6ced4SAl Viro { 1578f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1579f7e6ced4SAl Viro if (!--head->count) 1580f7e6ced4SAl Viro kfree(head); 1581f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1582f7e6ced4SAl Viro } 1583f7e6ced4SAl Viro 1584f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1585f7e6ced4SAl Viro { 1586f7e6ced4SAl Viro if (!head) 1587f7e6ced4SAl Viro BUG(); 1588f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1589f7e6ced4SAl Viro if (!use_table(head)) 1590f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1591f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1592f7e6ced4SAl Viro return head; 1593f7e6ced4SAl Viro } 1594f7e6ced4SAl Viro 1595805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1596805b5d5eSEric W. Biederman { 1597805b5d5eSEric W. Biederman if (!head) 1598805b5d5eSEric W. Biederman return; 1599805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1600805b5d5eSEric W. Biederman unuse_table(head); 1601805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1602805b5d5eSEric W. Biederman } 1603805b5d5eSEric W. Biederman 160473455092SAl Viro static struct ctl_table_set * 160573455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 160673455092SAl Viro { 160773455092SAl Viro struct ctl_table_set *set = &root->default_set; 160873455092SAl Viro if (root->lookup) 160973455092SAl Viro set = root->lookup(root, namespaces); 161073455092SAl Viro return set; 161173455092SAl Viro } 161273455092SAl Viro 1613e51b6ba0SEric W. Biederman static struct list_head * 1614e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1615805b5d5eSEric W. Biederman { 161673455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 161773455092SAl Viro return &set->list; 1618e51b6ba0SEric W. Biederman } 1619e51b6ba0SEric W. Biederman 1620e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1621e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1622e51b6ba0SEric W. Biederman { 1623e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1624e51b6ba0SEric W. Biederman struct list_head *header_list; 1625805b5d5eSEric W. Biederman struct ctl_table_header *head; 1626805b5d5eSEric W. Biederman struct list_head *tmp; 1627e51b6ba0SEric W. Biederman 1628805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1629805b5d5eSEric W. Biederman if (prev) { 1630e51b6ba0SEric W. Biederman head = prev; 1631805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1632805b5d5eSEric W. Biederman unuse_table(prev); 1633805b5d5eSEric W. Biederman goto next; 1634805b5d5eSEric W. Biederman } 1635805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1636805b5d5eSEric W. Biederman for (;;) { 1637805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1638805b5d5eSEric W. Biederman 1639805b5d5eSEric W. Biederman if (!use_table(head)) 1640805b5d5eSEric W. Biederman goto next; 1641805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1642805b5d5eSEric W. Biederman return head; 1643805b5d5eSEric W. Biederman next: 1644e51b6ba0SEric W. Biederman root = head->root; 1645805b5d5eSEric W. Biederman tmp = tmp->next; 1646e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1647e51b6ba0SEric W. Biederman if (tmp != header_list) 1648e51b6ba0SEric W. Biederman continue; 1649e51b6ba0SEric W. Biederman 1650e51b6ba0SEric W. Biederman do { 1651e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1652e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1653e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1654e51b6ba0SEric W. Biederman goto out; 1655e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1656e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1657e51b6ba0SEric W. Biederman tmp = header_list->next; 1658805b5d5eSEric W. Biederman } 1659e51b6ba0SEric W. Biederman out: 1660805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1661805b5d5eSEric W. Biederman return NULL; 1662805b5d5eSEric W. Biederman } 1663805b5d5eSEric W. Biederman 1664e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1665e51b6ba0SEric W. Biederman { 1666e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1667e51b6ba0SEric W. Biederman } 1668e51b6ba0SEric W. Biederman 1669e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1670e51b6ba0SEric W. Biederman { 1671e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1672e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1673e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1674e51b6ba0SEric W. Biederman } 1675e51b6ba0SEric W. Biederman 16761da177e4SLinus Torvalds /* 16771ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 16781da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 16791da177e4SLinus Torvalds */ 16801da177e4SLinus Torvalds 16811da177e4SLinus Torvalds static int test_perm(int mode, int op) 16821da177e4SLinus Torvalds { 168376aac0e9SDavid Howells if (!current_euid()) 16841da177e4SLinus Torvalds mode >>= 6; 16851da177e4SLinus Torvalds else if (in_egroup_p(0)) 16861da177e4SLinus Torvalds mode >>= 3; 1687e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 16881da177e4SLinus Torvalds return 0; 16891da177e4SLinus Torvalds return -EACCES; 16901da177e4SLinus Torvalds } 16911da177e4SLinus Torvalds 1692d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 16931da177e4SLinus Torvalds { 16941da177e4SLinus Torvalds int error; 1695d7321cd6SPavel Emelyanov int mode; 1696d7321cd6SPavel Emelyanov 1697e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 16981da177e4SLinus Torvalds if (error) 16991da177e4SLinus Torvalds return error; 1700d7321cd6SPavel Emelyanov 1701d7321cd6SPavel Emelyanov if (root->permissions) 1702d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1703d7321cd6SPavel Emelyanov else 1704d7321cd6SPavel Emelyanov mode = table->mode; 1705d7321cd6SPavel Emelyanov 1706d7321cd6SPavel Emelyanov return test_perm(mode, op); 17071da177e4SLinus Torvalds } 17081da177e4SLinus Torvalds 1709d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1710d912b0ccSEric W. Biederman { 17112315ffa0SEric W. Biederman for (; table->procname; table++) { 1712d912b0ccSEric W. Biederman table->parent = parent; 1713d912b0ccSEric W. Biederman if (table->child) 1714d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1715d912b0ccSEric W. Biederman } 1716d912b0ccSEric W. Biederman } 1717d912b0ccSEric W. Biederman 1718d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1719d912b0ccSEric W. Biederman { 1720d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 172188f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1722b3bd3de6SAndi Kleen sysctl_check_table(current->nsproxy, root_table); 172388f458e4SHolger Schurig #endif 1724d912b0ccSEric W. Biederman return 0; 1725d912b0ccSEric W. Biederman } 1726d912b0ccSEric W. Biederman 1727d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1728d912b0ccSEric W. Biederman 1729bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1730bfbcf034SAl Viro struct ctl_table *table) 1731ae7edeccSAl Viro { 1732ae7edeccSAl Viro struct ctl_table *p; 1733ae7edeccSAl Viro const char *s = branch->procname; 1734ae7edeccSAl Viro 1735ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1736ae7edeccSAl Viro if (!s || !branch->child) 1737bfbcf034SAl Viro return NULL; 1738ae7edeccSAl Viro 1739ae7edeccSAl Viro /* ... and nothing else */ 17402315ffa0SEric W. Biederman if (branch[1].procname) 1741bfbcf034SAl Viro return NULL; 1742ae7edeccSAl Viro 1743ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 17442315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1745ae7edeccSAl Viro if (!p->child) 1746ae7edeccSAl Viro continue; 1747ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1748bfbcf034SAl Viro return p; 1749ae7edeccSAl Viro } 1750bfbcf034SAl Viro return NULL; 1751ae7edeccSAl Viro } 1752ae7edeccSAl Viro 1753ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1754ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1755ae7edeccSAl Viro { 1756ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1757bfbcf034SAl Viro struct ctl_table *next; 1758ae7edeccSAl Viro int is_better = 0; 1759ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1760ae7edeccSAl Viro 1761bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1762ae7edeccSAl Viro if (by == q->attached_by) 1763ae7edeccSAl Viro is_better = 1; 1764ae7edeccSAl Viro if (to == p->attached_by) 1765ae7edeccSAl Viro not_in_parent = 1; 1766ae7edeccSAl Viro by = by->child; 1767bfbcf034SAl Viro to = next->child; 1768ae7edeccSAl Viro } 1769ae7edeccSAl Viro 1770ae7edeccSAl Viro if (is_better && not_in_parent) { 1771ae7edeccSAl Viro q->attached_by = by; 1772ae7edeccSAl Viro q->attached_to = to; 1773ae7edeccSAl Viro q->parent = p; 1774ae7edeccSAl Viro } 1775ae7edeccSAl Viro } 1776ae7edeccSAl Viro 17771da177e4SLinus Torvalds /** 1778e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1779e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1780e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 178129e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 17821da177e4SLinus Torvalds * @table: the top-level table structure 17831da177e4SLinus Torvalds * 17841da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 178529e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 17861da177e4SLinus Torvalds * 1787d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 17881da177e4SLinus Torvalds * 17891da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 17901da177e4SLinus Torvalds * enter a sysctl file 17911da177e4SLinus Torvalds * 17921da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 17931da177e4SLinus Torvalds * 17941da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 17951da177e4SLinus Torvalds * 17961da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 17971da177e4SLinus Torvalds * 17981da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 17991da177e4SLinus Torvalds * %NULL. 18001da177e4SLinus Torvalds * 18011da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 18021da177e4SLinus Torvalds * 18031da177e4SLinus Torvalds * de - for internal use by the sysctl routines 18041da177e4SLinus Torvalds * 18051da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 18061da177e4SLinus Torvalds * 18071da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 18081da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 18091da177e4SLinus Torvalds * 18101da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 18111da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 18121da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 18131da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 18141da177e4SLinus Torvalds * 18151da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 18161da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 18171da177e4SLinus Torvalds * directory handler). Several default handlers are available to 18181da177e4SLinus Torvalds * cover common cases - 18191da177e4SLinus Torvalds * 18201da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 18211da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 18221da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 18231da177e4SLinus Torvalds * 18241da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 18251da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 18261da177e4SLinus Torvalds * 18271da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 18281da177e4SLinus Torvalds * to the table header on success. 18291da177e4SLinus Torvalds */ 1830e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1831e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1832e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1833e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 18341da177e4SLinus Torvalds { 183529e796fdSEric W. Biederman struct ctl_table_header *header; 183629e796fdSEric W. Biederman struct ctl_table *new, **prevp; 183729e796fdSEric W. Biederman unsigned int n, npath; 1838ae7edeccSAl Viro struct ctl_table_set *set; 183929e796fdSEric W. Biederman 184029e796fdSEric W. Biederman /* Count the path components */ 18412315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 184229e796fdSEric W. Biederman ; 184329e796fdSEric W. Biederman 184429e796fdSEric W. Biederman /* 184529e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 184629e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 18472315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 184829e796fdSEric W. Biederman * 184929e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 185029e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 185129e796fdSEric W. Biederman */ 185229e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 185329e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 185429e796fdSEric W. Biederman if (!header) 18551da177e4SLinus Torvalds return NULL; 185629e796fdSEric W. Biederman 185729e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 185829e796fdSEric W. Biederman 185929e796fdSEric W. Biederman /* Now connect the dots */ 186029e796fdSEric W. Biederman prevp = &header->ctl_table; 186129e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 186229e796fdSEric W. Biederman /* Copy the procname */ 186329e796fdSEric W. Biederman new->procname = path->procname; 186429e796fdSEric W. Biederman new->mode = 0555; 186529e796fdSEric W. Biederman 186629e796fdSEric W. Biederman *prevp = new; 186729e796fdSEric W. Biederman prevp = &new->child; 186829e796fdSEric W. Biederman 186929e796fdSEric W. Biederman new += 2; 187029e796fdSEric W. Biederman } 187129e796fdSEric W. Biederman *prevp = table; 187223eb06deSEric W. Biederman header->ctl_table_arg = table; 187329e796fdSEric W. Biederman 187429e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 187529e796fdSEric W. Biederman header->used = 0; 187629e796fdSEric W. Biederman header->unregistering = NULL; 1877e51b6ba0SEric W. Biederman header->root = root; 187829e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1879f7e6ced4SAl Viro header->count = 1; 188088f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1881e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 188229e796fdSEric W. Biederman kfree(header); 1883fc6cd25bSEric W. Biederman return NULL; 1884fc6cd25bSEric W. Biederman } 188588f458e4SHolger Schurig #endif 1886330d57fbSAl Viro spin_lock(&sysctl_lock); 188773455092SAl Viro header->set = lookup_header_set(root, namespaces); 1888ae7edeccSAl Viro header->attached_by = header->ctl_table; 1889ae7edeccSAl Viro header->attached_to = root_table; 1890ae7edeccSAl Viro header->parent = &root_table_header; 1891ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1892ae7edeccSAl Viro struct ctl_table_header *p; 1893ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1894ae7edeccSAl Viro if (p->unregistering) 1895ae7edeccSAl Viro continue; 1896ae7edeccSAl Viro try_attach(p, header); 1897ae7edeccSAl Viro } 1898ae7edeccSAl Viro } 1899ae7edeccSAl Viro header->parent->count++; 190073455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1901330d57fbSAl Viro spin_unlock(&sysctl_lock); 190229e796fdSEric W. Biederman 190329e796fdSEric W. Biederman return header; 190429e796fdSEric W. Biederman } 190529e796fdSEric W. Biederman 190629e796fdSEric W. Biederman /** 1907e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1908e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1909e51b6ba0SEric W. Biederman * @table: the top-level table structure 1910e51b6ba0SEric W. Biederman * 1911e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1912e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1913e51b6ba0SEric W. Biederman * 1914e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1915e51b6ba0SEric W. Biederman */ 1916e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1917e51b6ba0SEric W. Biederman struct ctl_table *table) 1918e51b6ba0SEric W. Biederman { 1919e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1920e51b6ba0SEric W. Biederman path, table); 1921e51b6ba0SEric W. Biederman } 1922e51b6ba0SEric W. Biederman 1923e51b6ba0SEric W. Biederman /** 192429e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 192529e796fdSEric W. Biederman * @table: the top-level table structure 192629e796fdSEric W. Biederman * 192729e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 192829e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 192929e796fdSEric W. Biederman * 193029e796fdSEric W. Biederman * See register_sysctl_paths for more details. 193129e796fdSEric W. Biederman */ 193229e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 193329e796fdSEric W. Biederman { 193429e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 193529e796fdSEric W. Biederman 193629e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 19371da177e4SLinus Torvalds } 19381da177e4SLinus Torvalds 19391da177e4SLinus Torvalds /** 19401da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 19411da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 19421da177e4SLinus Torvalds * 19431da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 19441da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 19451da177e4SLinus Torvalds */ 19461da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 19471da177e4SLinus Torvalds { 1948330d57fbSAl Viro might_sleep(); 1949f1dad166SPavel Emelyanov 1950f1dad166SPavel Emelyanov if (header == NULL) 1951f1dad166SPavel Emelyanov return; 1952f1dad166SPavel Emelyanov 1953330d57fbSAl Viro spin_lock(&sysctl_lock); 1954330d57fbSAl Viro start_unregistering(header); 1955ae7edeccSAl Viro if (!--header->parent->count) { 1956ae7edeccSAl Viro WARN_ON(1); 1957ae7edeccSAl Viro kfree(header->parent); 1958ae7edeccSAl Viro } 1959f7e6ced4SAl Viro if (!--header->count) 19601da177e4SLinus Torvalds kfree(header); 1961f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19621da177e4SLinus Torvalds } 19631da177e4SLinus Torvalds 19649043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19659043476fSAl Viro { 19669043476fSAl Viro struct ctl_table_set *set = p->set; 19679043476fSAl Viro int res; 19689043476fSAl Viro spin_lock(&sysctl_lock); 19699043476fSAl Viro if (p->unregistering) 19709043476fSAl Viro res = 0; 19719043476fSAl Viro else if (!set->is_seen) 19729043476fSAl Viro res = 1; 19739043476fSAl Viro else 19749043476fSAl Viro res = set->is_seen(set); 19759043476fSAl Viro spin_unlock(&sysctl_lock); 19769043476fSAl Viro return res; 19779043476fSAl Viro } 19789043476fSAl Viro 197973455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 198073455092SAl Viro struct ctl_table_set *parent, 198173455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 198273455092SAl Viro { 198373455092SAl Viro INIT_LIST_HEAD(&p->list); 198473455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 198573455092SAl Viro p->is_seen = is_seen; 198673455092SAl Viro } 198773455092SAl Viro 1988b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 1989d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1990b89a8171SEric W. Biederman { 1991b89a8171SEric W. Biederman return NULL; 1992b89a8171SEric W. Biederman } 1993b89a8171SEric W. Biederman 199429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 199529e796fdSEric W. Biederman struct ctl_table *table) 199629e796fdSEric W. Biederman { 199729e796fdSEric W. Biederman return NULL; 199829e796fdSEric W. Biederman } 199929e796fdSEric W. Biederman 2000b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 2001b89a8171SEric W. Biederman { 2002b89a8171SEric W. Biederman } 2003b89a8171SEric W. Biederman 200473455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 200573455092SAl Viro struct ctl_table_set *parent, 200673455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 200773455092SAl Viro { 200873455092SAl Viro } 200973455092SAl Viro 2010f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 2011f7e6ced4SAl Viro { 2012f7e6ced4SAl Viro } 2013f7e6ced4SAl Viro 2014b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 2015b89a8171SEric W. Biederman 20161da177e4SLinus Torvalds /* 20171da177e4SLinus Torvalds * /proc/sys support 20181da177e4SLinus Torvalds */ 20191da177e4SLinus Torvalds 2020b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 20211da177e4SLinus Torvalds 2022b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 20238d65af78SAlexey Dobriyan void __user *buffer, 2024b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 2025f5dd3d6fSSam Vilain { 2026f5dd3d6fSSam Vilain size_t len; 2027f5dd3d6fSSam Vilain char __user *p; 2028f5dd3d6fSSam Vilain char c; 2029f5dd3d6fSSam Vilain 20308d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 2031f5dd3d6fSSam Vilain *lenp = 0; 2032f5dd3d6fSSam Vilain return 0; 2033f5dd3d6fSSam Vilain } 2034f5dd3d6fSSam Vilain 2035f5dd3d6fSSam Vilain if (write) { 2036f5dd3d6fSSam Vilain len = 0; 2037f5dd3d6fSSam Vilain p = buffer; 2038f5dd3d6fSSam Vilain while (len < *lenp) { 2039f5dd3d6fSSam Vilain if (get_user(c, p++)) 2040f5dd3d6fSSam Vilain return -EFAULT; 2041f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 2042f5dd3d6fSSam Vilain break; 2043f5dd3d6fSSam Vilain len++; 2044f5dd3d6fSSam Vilain } 2045f5dd3d6fSSam Vilain if (len >= maxlen) 2046f5dd3d6fSSam Vilain len = maxlen-1; 2047f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 2048f5dd3d6fSSam Vilain return -EFAULT; 2049f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 2050f5dd3d6fSSam Vilain *ppos += *lenp; 2051f5dd3d6fSSam Vilain } else { 2052f5dd3d6fSSam Vilain len = strlen(data); 2053f5dd3d6fSSam Vilain if (len > maxlen) 2054f5dd3d6fSSam Vilain len = maxlen; 20558d060877SOleg Nesterov 20568d060877SOleg Nesterov if (*ppos > len) { 20578d060877SOleg Nesterov *lenp = 0; 20588d060877SOleg Nesterov return 0; 20598d060877SOleg Nesterov } 20608d060877SOleg Nesterov 20618d060877SOleg Nesterov data += *ppos; 20628d060877SOleg Nesterov len -= *ppos; 20638d060877SOleg Nesterov 2064f5dd3d6fSSam Vilain if (len > *lenp) 2065f5dd3d6fSSam Vilain len = *lenp; 2066f5dd3d6fSSam Vilain if (len) 2067f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2068f5dd3d6fSSam Vilain return -EFAULT; 2069f5dd3d6fSSam Vilain if (len < *lenp) { 2070f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2071f5dd3d6fSSam Vilain return -EFAULT; 2072f5dd3d6fSSam Vilain len++; 2073f5dd3d6fSSam Vilain } 2074f5dd3d6fSSam Vilain *lenp = len; 2075f5dd3d6fSSam Vilain *ppos += len; 2076f5dd3d6fSSam Vilain } 2077f5dd3d6fSSam Vilain return 0; 2078f5dd3d6fSSam Vilain } 2079f5dd3d6fSSam Vilain 20801da177e4SLinus Torvalds /** 20811da177e4SLinus Torvalds * proc_dostring - read a string sysctl 20821da177e4SLinus Torvalds * @table: the sysctl table 20831da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20841da177e4SLinus Torvalds * @buffer: the user buffer 20851da177e4SLinus Torvalds * @lenp: the size of the user buffer 20861da177e4SLinus Torvalds * @ppos: file position 20871da177e4SLinus Torvalds * 20881da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 20891da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 20901da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 20911da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 20921da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 20931da177e4SLinus Torvalds * not large enough. 20941da177e4SLinus Torvalds * 20951da177e4SLinus Torvalds * Returns 0 on success. 20961da177e4SLinus Torvalds */ 20978d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 20981da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20991da177e4SLinus Torvalds { 21008d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2101f5dd3d6fSSam Vilain buffer, lenp, ppos); 21021da177e4SLinus Torvalds } 21031da177e4SLinus Torvalds 210400b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 210500b7c339SAmerigo Wang { 210600b7c339SAmerigo Wang size_t ret; 210700b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 210800b7c339SAmerigo Wang ret = tmp - *buf; 210900b7c339SAmerigo Wang *buf = tmp; 211000b7c339SAmerigo Wang return ret; 211100b7c339SAmerigo Wang } 21121da177e4SLinus Torvalds 21139f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v) 21149f977fb7SOctavian Purdila { 21159f977fb7SOctavian Purdila while (*size) { 21169f977fb7SOctavian Purdila if (**buf != v) 21179f977fb7SOctavian Purdila break; 21189f977fb7SOctavian Purdila (*size)--; 21199f977fb7SOctavian Purdila (*buf)++; 21209f977fb7SOctavian Purdila } 21219f977fb7SOctavian Purdila } 21229f977fb7SOctavian Purdila 212300b7c339SAmerigo Wang #define TMPBUFLEN 22 212400b7c339SAmerigo Wang /** 21250fc377bdSRandy Dunlap * proc_get_long - reads an ASCII formatted integer from a user buffer 212600b7c339SAmerigo Wang * 21270fc377bdSRandy Dunlap * @buf: a kernel buffer 21280fc377bdSRandy Dunlap * @size: size of the kernel buffer 21290fc377bdSRandy Dunlap * @val: this is where the number will be stored 21300fc377bdSRandy Dunlap * @neg: set to %TRUE if number is negative 21310fc377bdSRandy Dunlap * @perm_tr: a vector which contains the allowed trailers 21320fc377bdSRandy Dunlap * @perm_tr_len: size of the perm_tr vector 21330fc377bdSRandy Dunlap * @tr: pointer to store the trailer character 213400b7c339SAmerigo Wang * 21350fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 21360fc377bdSRandy Dunlap * the amount of bytes read. If @tr is non-NULL and a trailing 21370fc377bdSRandy Dunlap * character exists (size is non-zero after returning from this 21380fc377bdSRandy Dunlap * function), @tr is updated with the trailing character. 213900b7c339SAmerigo Wang */ 214000b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 214100b7c339SAmerigo Wang unsigned long *val, bool *neg, 214200b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 214300b7c339SAmerigo Wang { 214400b7c339SAmerigo Wang int len; 214500b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 214600b7c339SAmerigo Wang 214700b7c339SAmerigo Wang if (!*size) 214800b7c339SAmerigo Wang return -EINVAL; 214900b7c339SAmerigo Wang 215000b7c339SAmerigo Wang len = *size; 215100b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 215200b7c339SAmerigo Wang len = TMPBUFLEN - 1; 215300b7c339SAmerigo Wang 215400b7c339SAmerigo Wang memcpy(tmp, *buf, len); 215500b7c339SAmerigo Wang 215600b7c339SAmerigo Wang tmp[len] = 0; 215700b7c339SAmerigo Wang p = tmp; 215800b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 215900b7c339SAmerigo Wang *neg = true; 216000b7c339SAmerigo Wang p++; 216100b7c339SAmerigo Wang } else 216200b7c339SAmerigo Wang *neg = false; 216300b7c339SAmerigo Wang if (!isdigit(*p)) 216400b7c339SAmerigo Wang return -EINVAL; 216500b7c339SAmerigo Wang 216600b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 216700b7c339SAmerigo Wang 216800b7c339SAmerigo Wang len = p - tmp; 216900b7c339SAmerigo Wang 217000b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 217100b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 217200b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 217300b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 217400b7c339SAmerigo Wang return -EINVAL; 217500b7c339SAmerigo Wang 217600b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 217700b7c339SAmerigo Wang return -EINVAL; 217800b7c339SAmerigo Wang 217900b7c339SAmerigo Wang if (tr && (len < *size)) 218000b7c339SAmerigo Wang *tr = *p; 218100b7c339SAmerigo Wang 218200b7c339SAmerigo Wang *buf += len; 218300b7c339SAmerigo Wang *size -= len; 218400b7c339SAmerigo Wang 218500b7c339SAmerigo Wang return 0; 218600b7c339SAmerigo Wang } 218700b7c339SAmerigo Wang 218800b7c339SAmerigo Wang /** 21890fc377bdSRandy Dunlap * proc_put_long - converts an integer to a decimal ASCII formatted string 219000b7c339SAmerigo Wang * 21910fc377bdSRandy Dunlap * @buf: the user buffer 21920fc377bdSRandy Dunlap * @size: the size of the user buffer 21930fc377bdSRandy Dunlap * @val: the integer to be converted 21940fc377bdSRandy Dunlap * @neg: sign of the number, %TRUE for negative 219500b7c339SAmerigo Wang * 21960fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 21970fc377bdSRandy Dunlap * the amount of bytes written. 219800b7c339SAmerigo Wang */ 219900b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 220000b7c339SAmerigo Wang bool neg) 220100b7c339SAmerigo Wang { 220200b7c339SAmerigo Wang int len; 220300b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 220400b7c339SAmerigo Wang 220500b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 220600b7c339SAmerigo Wang len = strlen(tmp); 220700b7c339SAmerigo Wang if (len > *size) 220800b7c339SAmerigo Wang len = *size; 220900b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 221000b7c339SAmerigo Wang return -EFAULT; 221100b7c339SAmerigo Wang *size -= len; 221200b7c339SAmerigo Wang *buf += len; 221300b7c339SAmerigo Wang return 0; 221400b7c339SAmerigo Wang } 221500b7c339SAmerigo Wang #undef TMPBUFLEN 221600b7c339SAmerigo Wang 221700b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 221800b7c339SAmerigo Wang { 221900b7c339SAmerigo Wang if (*size) { 222000b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 222100b7c339SAmerigo Wang if (put_user(c, *buffer)) 222200b7c339SAmerigo Wang return -EFAULT; 222300b7c339SAmerigo Wang (*size)--, (*buffer)++; 222400b7c339SAmerigo Wang *buf = *buffer; 222500b7c339SAmerigo Wang } 222600b7c339SAmerigo Wang return 0; 222700b7c339SAmerigo Wang } 222800b7c339SAmerigo Wang 222900b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 22301da177e4SLinus Torvalds int *valp, 22311da177e4SLinus Torvalds int write, void *data) 22321da177e4SLinus Torvalds { 22331da177e4SLinus Torvalds if (write) { 22341da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 22351da177e4SLinus Torvalds } else { 22361da177e4SLinus Torvalds int val = *valp; 22371da177e4SLinus Torvalds if (val < 0) { 223800b7c339SAmerigo Wang *negp = true; 22391da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 22401da177e4SLinus Torvalds } else { 224100b7c339SAmerigo Wang *negp = false; 22421da177e4SLinus Torvalds *lvalp = (unsigned long)val; 22431da177e4SLinus Torvalds } 22441da177e4SLinus Torvalds } 22451da177e4SLinus Torvalds return 0; 22461da177e4SLinus Torvalds } 22471da177e4SLinus Torvalds 224800b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 224900b7c339SAmerigo Wang 2250d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 22518d65af78SAlexey Dobriyan int write, void __user *buffer, 2252fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 225300b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 22541da177e4SLinus Torvalds int write, void *data), 22551da177e4SLinus Torvalds void *data) 22561da177e4SLinus Torvalds { 225700b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 225800b7c339SAmerigo Wang unsigned long page = 0; 225900b7c339SAmerigo Wang size_t left; 226000b7c339SAmerigo Wang char *kbuf; 22611da177e4SLinus Torvalds 226200b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 22631da177e4SLinus Torvalds *lenp = 0; 22641da177e4SLinus Torvalds return 0; 22651da177e4SLinus Torvalds } 22661da177e4SLinus Torvalds 2267fcfbd547SKirill Korotaev i = (int *) tbl_data; 22681da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 22691da177e4SLinus Torvalds left = *lenp; 22701da177e4SLinus Torvalds 22711da177e4SLinus Torvalds if (!conv) 22721da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 22731da177e4SLinus Torvalds 227400b7c339SAmerigo Wang if (write) { 227500b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 227600b7c339SAmerigo Wang left = PAGE_SIZE - 1; 227700b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 227800b7c339SAmerigo Wang kbuf = (char *) page; 227900b7c339SAmerigo Wang if (!kbuf) 228000b7c339SAmerigo Wang return -ENOMEM; 228100b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 228200b7c339SAmerigo Wang err = -EFAULT; 228300b7c339SAmerigo Wang goto free; 228400b7c339SAmerigo Wang } 228500b7c339SAmerigo Wang kbuf[left] = 0; 228600b7c339SAmerigo Wang } 228700b7c339SAmerigo Wang 22881da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 228900b7c339SAmerigo Wang unsigned long lval; 229000b7c339SAmerigo Wang bool neg; 229100b7c339SAmerigo Wang 22921da177e4SLinus Torvalds if (write) { 229300b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 229400b7c339SAmerigo Wang 2295563b0467SJ. R. Okajima if (!left) 2296563b0467SJ. R. Okajima break; 229700b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 229800b7c339SAmerigo Wang proc_wspace_sep, 229900b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 230000b7c339SAmerigo Wang if (err) 23011da177e4SLinus Torvalds break; 230200b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 230300b7c339SAmerigo Wang err = -EINVAL; 230400b7c339SAmerigo Wang break; 23051da177e4SLinus Torvalds } 23061da177e4SLinus Torvalds } else { 230700b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 230800b7c339SAmerigo Wang err = -EINVAL; 230900b7c339SAmerigo Wang break; 231000b7c339SAmerigo Wang } 23111da177e4SLinus Torvalds if (!first) 231200b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 231300b7c339SAmerigo Wang if (err) 23141da177e4SLinus Torvalds break; 231500b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 231600b7c339SAmerigo Wang if (err) 231700b7c339SAmerigo Wang break; 23181da177e4SLinus Torvalds } 23191da177e4SLinus Torvalds } 23201da177e4SLinus Torvalds 232100b7c339SAmerigo Wang if (!write && !first && left && !err) 232200b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 2323563b0467SJ. R. Okajima if (write && !err && left) 232400b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 232500b7c339SAmerigo Wang free: 23261da177e4SLinus Torvalds if (write) { 232700b7c339SAmerigo Wang free_page(page); 232800b7c339SAmerigo Wang if (first) 232900b7c339SAmerigo Wang return err ? : -EINVAL; 23301da177e4SLinus Torvalds } 23311da177e4SLinus Torvalds *lenp -= left; 23321da177e4SLinus Torvalds *ppos += *lenp; 233300b7c339SAmerigo Wang return err; 23341da177e4SLinus Torvalds } 23351da177e4SLinus Torvalds 23368d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2337fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 233800b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 2339fcfbd547SKirill Korotaev int write, void *data), 2340fcfbd547SKirill Korotaev void *data) 2341fcfbd547SKirill Korotaev { 23428d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2343fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2344fcfbd547SKirill Korotaev } 2345fcfbd547SKirill Korotaev 23461da177e4SLinus Torvalds /** 23471da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 23481da177e4SLinus Torvalds * @table: the sysctl table 23491da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23501da177e4SLinus Torvalds * @buffer: the user buffer 23511da177e4SLinus Torvalds * @lenp: the size of the user buffer 23521da177e4SLinus Torvalds * @ppos: file position 23531da177e4SLinus Torvalds * 23541da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23551da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23561da177e4SLinus Torvalds * 23571da177e4SLinus Torvalds * Returns 0 on success. 23581da177e4SLinus Torvalds */ 23598d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 23601da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23611da177e4SLinus Torvalds { 23628d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 23631da177e4SLinus Torvalds NULL,NULL); 23641da177e4SLinus Torvalds } 23651da177e4SLinus Torvalds 236634f5a398STheodore Ts'o /* 236734f5a398STheodore Ts'o * Taint values can only be increased 236825ddbb18SAndi Kleen * This means we can safely use a temporary. 236934f5a398STheodore Ts'o */ 23708d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 237134f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 237234f5a398STheodore Ts'o { 237325ddbb18SAndi Kleen struct ctl_table t; 237425ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 237525ddbb18SAndi Kleen int err; 237634f5a398STheodore Ts'o 237791fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 237834f5a398STheodore Ts'o return -EPERM; 237934f5a398STheodore Ts'o 238025ddbb18SAndi Kleen t = *table; 238125ddbb18SAndi Kleen t.data = &tmptaint; 23828d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 238325ddbb18SAndi Kleen if (err < 0) 238425ddbb18SAndi Kleen return err; 238525ddbb18SAndi Kleen 238625ddbb18SAndi Kleen if (write) { 238725ddbb18SAndi Kleen /* 238825ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 238925ddbb18SAndi Kleen * to everyone's atomic.h for this 239025ddbb18SAndi Kleen */ 239125ddbb18SAndi Kleen int i; 239225ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 239325ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 239425ddbb18SAndi Kleen add_taint(i); 239525ddbb18SAndi Kleen } 239625ddbb18SAndi Kleen } 239725ddbb18SAndi Kleen 239825ddbb18SAndi Kleen return err; 239934f5a398STheodore Ts'o } 240034f5a398STheodore Ts'o 24011da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 24021da177e4SLinus Torvalds int *min; 24031da177e4SLinus Torvalds int *max; 24041da177e4SLinus Torvalds }; 24051da177e4SLinus Torvalds 240600b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 24071da177e4SLinus Torvalds int *valp, 24081da177e4SLinus Torvalds int write, void *data) 24091da177e4SLinus Torvalds { 24101da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 24111da177e4SLinus Torvalds if (write) { 24121da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 24131da177e4SLinus Torvalds if ((param->min && *param->min > val) || 24141da177e4SLinus Torvalds (param->max && *param->max < val)) 24151da177e4SLinus Torvalds return -EINVAL; 24161da177e4SLinus Torvalds *valp = val; 24171da177e4SLinus Torvalds } else { 24181da177e4SLinus Torvalds int val = *valp; 24191da177e4SLinus Torvalds if (val < 0) { 242000b7c339SAmerigo Wang *negp = true; 24211da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 24221da177e4SLinus Torvalds } else { 242300b7c339SAmerigo Wang *negp = false; 24241da177e4SLinus Torvalds *lvalp = (unsigned long)val; 24251da177e4SLinus Torvalds } 24261da177e4SLinus Torvalds } 24271da177e4SLinus Torvalds return 0; 24281da177e4SLinus Torvalds } 24291da177e4SLinus Torvalds 24301da177e4SLinus Torvalds /** 24311da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 24321da177e4SLinus Torvalds * @table: the sysctl table 24331da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24341da177e4SLinus Torvalds * @buffer: the user buffer 24351da177e4SLinus Torvalds * @lenp: the size of the user buffer 24361da177e4SLinus Torvalds * @ppos: file position 24371da177e4SLinus Torvalds * 24381da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 24391da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24401da177e4SLinus Torvalds * 24411da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24421da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24431da177e4SLinus Torvalds * 24441da177e4SLinus Torvalds * Returns 0 on success. 24451da177e4SLinus Torvalds */ 24468d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 24471da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24481da177e4SLinus Torvalds { 24491da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 24501da177e4SLinus Torvalds .min = (int *) table->extra1, 24511da177e4SLinus Torvalds .max = (int *) table->extra2, 24521da177e4SLinus Torvalds }; 24538d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 24541da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 24551da177e4SLinus Torvalds } 24561da177e4SLinus Torvalds 2457d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 24581da177e4SLinus Torvalds void __user *buffer, 24591da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 24601da177e4SLinus Torvalds unsigned long convmul, 24611da177e4SLinus Torvalds unsigned long convdiv) 24621da177e4SLinus Torvalds { 246300b7c339SAmerigo Wang unsigned long *i, *min, *max; 246400b7c339SAmerigo Wang int vleft, first = 1, err = 0; 246500b7c339SAmerigo Wang unsigned long page = 0; 246600b7c339SAmerigo Wang size_t left; 246700b7c339SAmerigo Wang char *kbuf; 24681da177e4SLinus Torvalds 246900b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 24701da177e4SLinus Torvalds *lenp = 0; 24711da177e4SLinus Torvalds return 0; 24721da177e4SLinus Torvalds } 24731da177e4SLinus Torvalds 2474fcfbd547SKirill Korotaev i = (unsigned long *) data; 24751da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 24761da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 24771da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 24781da177e4SLinus Torvalds left = *lenp; 24791da177e4SLinus Torvalds 24801da177e4SLinus Torvalds if (write) { 248100b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 248200b7c339SAmerigo Wang left = PAGE_SIZE - 1; 248300b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 248400b7c339SAmerigo Wang kbuf = (char *) page; 248500b7c339SAmerigo Wang if (!kbuf) 248600b7c339SAmerigo Wang return -ENOMEM; 248700b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 248800b7c339SAmerigo Wang err = -EFAULT; 248900b7c339SAmerigo Wang goto free; 24901da177e4SLinus Torvalds } 249100b7c339SAmerigo Wang kbuf[left] = 0; 24921da177e4SLinus Torvalds } 24931da177e4SLinus Torvalds 249427b3d80aSEric Dumazet for (; left && vleft--; i++, first = 0) { 249500b7c339SAmerigo Wang unsigned long val; 249600b7c339SAmerigo Wang 249700b7c339SAmerigo Wang if (write) { 249800b7c339SAmerigo Wang bool neg; 249900b7c339SAmerigo Wang 250000b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 250100b7c339SAmerigo Wang 250200b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 250300b7c339SAmerigo Wang proc_wspace_sep, 250400b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 250500b7c339SAmerigo Wang if (err) 250600b7c339SAmerigo Wang break; 25071da177e4SLinus Torvalds if (neg) 25081da177e4SLinus Torvalds continue; 25091da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 25101da177e4SLinus Torvalds continue; 25111da177e4SLinus Torvalds *i = val; 25121da177e4SLinus Torvalds } else { 251300b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 25141da177e4SLinus Torvalds if (!first) 251500b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 251600b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 251700b7c339SAmerigo Wang if (err) 251800b7c339SAmerigo Wang break; 25191da177e4SLinus Torvalds } 25201da177e4SLinus Torvalds } 25211da177e4SLinus Torvalds 252200b7c339SAmerigo Wang if (!write && !first && left && !err) 252300b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 252400b7c339SAmerigo Wang if (write && !err) 252500b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 252600b7c339SAmerigo Wang free: 25271da177e4SLinus Torvalds if (write) { 252800b7c339SAmerigo Wang free_page(page); 252900b7c339SAmerigo Wang if (first) 253000b7c339SAmerigo Wang return err ? : -EINVAL; 25311da177e4SLinus Torvalds } 25321da177e4SLinus Torvalds *lenp -= left; 25331da177e4SLinus Torvalds *ppos += *lenp; 253400b7c339SAmerigo Wang return err; 25351da177e4SLinus Torvalds } 25361da177e4SLinus Torvalds 2537d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2538fcfbd547SKirill Korotaev void __user *buffer, 2539fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2540fcfbd547SKirill Korotaev unsigned long convmul, 2541fcfbd547SKirill Korotaev unsigned long convdiv) 2542fcfbd547SKirill Korotaev { 2543fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 25448d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2545fcfbd547SKirill Korotaev } 2546fcfbd547SKirill Korotaev 25471da177e4SLinus Torvalds /** 25481da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 25491da177e4SLinus Torvalds * @table: the sysctl table 25501da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25511da177e4SLinus Torvalds * @buffer: the user buffer 25521da177e4SLinus Torvalds * @lenp: the size of the user buffer 25531da177e4SLinus Torvalds * @ppos: file position 25541da177e4SLinus Torvalds * 25551da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 25561da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25571da177e4SLinus Torvalds * 25581da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25591da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25601da177e4SLinus Torvalds * 25611da177e4SLinus Torvalds * Returns 0 on success. 25621da177e4SLinus Torvalds */ 25638d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 25641da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25651da177e4SLinus Torvalds { 25668d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 25671da177e4SLinus Torvalds } 25681da177e4SLinus Torvalds 25691da177e4SLinus Torvalds /** 25701da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 25711da177e4SLinus Torvalds * @table: the sysctl table 25721da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25731da177e4SLinus Torvalds * @buffer: the user buffer 25741da177e4SLinus Torvalds * @lenp: the size of the user buffer 25751da177e4SLinus Torvalds * @ppos: file position 25761da177e4SLinus Torvalds * 25771da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 25781da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 25791da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 25801da177e4SLinus Torvalds * 25811da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25821da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25831da177e4SLinus Torvalds * 25841da177e4SLinus Torvalds * Returns 0 on success. 25851da177e4SLinus Torvalds */ 2586d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 25871da177e4SLinus Torvalds void __user *buffer, 25881da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 25891da177e4SLinus Torvalds { 25908d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 25911da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 25921da177e4SLinus Torvalds } 25931da177e4SLinus Torvalds 25941da177e4SLinus Torvalds 259500b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 25961da177e4SLinus Torvalds int *valp, 25971da177e4SLinus Torvalds int write, void *data) 25981da177e4SLinus Torvalds { 25991da177e4SLinus Torvalds if (write) { 2600cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2601cba9f33dSBart Samwel return 1; 26021da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 26031da177e4SLinus Torvalds } else { 26041da177e4SLinus Torvalds int val = *valp; 26051da177e4SLinus Torvalds unsigned long lval; 26061da177e4SLinus Torvalds if (val < 0) { 260700b7c339SAmerigo Wang *negp = true; 26081da177e4SLinus Torvalds lval = (unsigned long)-val; 26091da177e4SLinus Torvalds } else { 261000b7c339SAmerigo Wang *negp = false; 26111da177e4SLinus Torvalds lval = (unsigned long)val; 26121da177e4SLinus Torvalds } 26131da177e4SLinus Torvalds *lvalp = lval / HZ; 26141da177e4SLinus Torvalds } 26151da177e4SLinus Torvalds return 0; 26161da177e4SLinus Torvalds } 26171da177e4SLinus Torvalds 261800b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 26191da177e4SLinus Torvalds int *valp, 26201da177e4SLinus Torvalds int write, void *data) 26211da177e4SLinus Torvalds { 26221da177e4SLinus Torvalds if (write) { 2623cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2624cba9f33dSBart Samwel return 1; 26251da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 26261da177e4SLinus Torvalds } else { 26271da177e4SLinus Torvalds int val = *valp; 26281da177e4SLinus Torvalds unsigned long lval; 26291da177e4SLinus Torvalds if (val < 0) { 263000b7c339SAmerigo Wang *negp = true; 26311da177e4SLinus Torvalds lval = (unsigned long)-val; 26321da177e4SLinus Torvalds } else { 263300b7c339SAmerigo Wang *negp = false; 26341da177e4SLinus Torvalds lval = (unsigned long)val; 26351da177e4SLinus Torvalds } 26361da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 26371da177e4SLinus Torvalds } 26381da177e4SLinus Torvalds return 0; 26391da177e4SLinus Torvalds } 26401da177e4SLinus Torvalds 264100b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 26421da177e4SLinus Torvalds int *valp, 26431da177e4SLinus Torvalds int write, void *data) 26441da177e4SLinus Torvalds { 26451da177e4SLinus Torvalds if (write) { 26461da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 26471da177e4SLinus Torvalds } else { 26481da177e4SLinus Torvalds int val = *valp; 26491da177e4SLinus Torvalds unsigned long lval; 26501da177e4SLinus Torvalds if (val < 0) { 265100b7c339SAmerigo Wang *negp = true; 26521da177e4SLinus Torvalds lval = (unsigned long)-val; 26531da177e4SLinus Torvalds } else { 265400b7c339SAmerigo Wang *negp = false; 26551da177e4SLinus Torvalds lval = (unsigned long)val; 26561da177e4SLinus Torvalds } 26571da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 26581da177e4SLinus Torvalds } 26591da177e4SLinus Torvalds return 0; 26601da177e4SLinus Torvalds } 26611da177e4SLinus Torvalds 26621da177e4SLinus Torvalds /** 26631da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 26641da177e4SLinus Torvalds * @table: the sysctl table 26651da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26661da177e4SLinus Torvalds * @buffer: the user buffer 26671da177e4SLinus Torvalds * @lenp: the size of the user buffer 26681da177e4SLinus Torvalds * @ppos: file position 26691da177e4SLinus Torvalds * 26701da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 26711da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 26721da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 26731da177e4SLinus Torvalds * jiffies. 26741da177e4SLinus Torvalds * 26751da177e4SLinus Torvalds * Returns 0 on success. 26761da177e4SLinus Torvalds */ 26778d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 26781da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26791da177e4SLinus Torvalds { 26808d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 26811da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 26821da177e4SLinus Torvalds } 26831da177e4SLinus Torvalds 26841da177e4SLinus Torvalds /** 26851da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 26861da177e4SLinus Torvalds * @table: the sysctl table 26871da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26881da177e4SLinus Torvalds * @buffer: the user buffer 26891da177e4SLinus Torvalds * @lenp: the size of the user buffer 26901e5d5331SRandy Dunlap * @ppos: pointer to the file position 26911da177e4SLinus Torvalds * 26921da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 26931da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 26941da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 26951da177e4SLinus Torvalds * are converted into jiffies. 26961da177e4SLinus Torvalds * 26971da177e4SLinus Torvalds * Returns 0 on success. 26981da177e4SLinus Torvalds */ 26998d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 27001da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27011da177e4SLinus Torvalds { 27028d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 27031da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 27041da177e4SLinus Torvalds } 27051da177e4SLinus Torvalds 27061da177e4SLinus Torvalds /** 27071da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 27081da177e4SLinus Torvalds * @table: the sysctl table 27091da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 27101da177e4SLinus Torvalds * @buffer: the user buffer 27111da177e4SLinus Torvalds * @lenp: the size of the user buffer 271267be2dd1SMartin Waitz * @ppos: file position 271367be2dd1SMartin Waitz * @ppos: the current position in the file 27141da177e4SLinus Torvalds * 27151da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 27161da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 27171da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 27181da177e4SLinus Torvalds * are converted into jiffies. 27191da177e4SLinus Torvalds * 27201da177e4SLinus Torvalds * Returns 0 on success. 27211da177e4SLinus Torvalds */ 27228d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 27231da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27241da177e4SLinus Torvalds { 27258d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 27261da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 27271da177e4SLinus Torvalds } 27281da177e4SLinus Torvalds 27298d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 27309ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 27319ec52099SCedric Le Goater { 27329ec52099SCedric Le Goater struct pid *new_pid; 27339ec52099SCedric Le Goater pid_t tmp; 27349ec52099SCedric Le Goater int r; 27359ec52099SCedric Le Goater 27366c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 27379ec52099SCedric Le Goater 27388d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 27399ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 27409ec52099SCedric Le Goater if (r || !write) 27419ec52099SCedric Le Goater return r; 27429ec52099SCedric Le Goater 27439ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 27449ec52099SCedric Le Goater if (!new_pid) 27459ec52099SCedric Le Goater return -ESRCH; 27469ec52099SCedric Le Goater 27479ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 27489ec52099SCedric Le Goater return 0; 27499ec52099SCedric Le Goater } 27509ec52099SCedric Le Goater 27519f977fb7SOctavian Purdila /** 27529f977fb7SOctavian Purdila * proc_do_large_bitmap - read/write from/to a large bitmap 27539f977fb7SOctavian Purdila * @table: the sysctl table 27549f977fb7SOctavian Purdila * @write: %TRUE if this is a write to the sysctl file 27559f977fb7SOctavian Purdila * @buffer: the user buffer 27569f977fb7SOctavian Purdila * @lenp: the size of the user buffer 27579f977fb7SOctavian Purdila * @ppos: file position 27589f977fb7SOctavian Purdila * 27599f977fb7SOctavian Purdila * The bitmap is stored at table->data and the bitmap length (in bits) 27609f977fb7SOctavian Purdila * in table->maxlen. 27619f977fb7SOctavian Purdila * 27629f977fb7SOctavian Purdila * We use a range comma separated format (e.g. 1,3-4,10-10) so that 27639f977fb7SOctavian Purdila * large bitmaps may be represented in a compact manner. Writing into 27649f977fb7SOctavian Purdila * the file will clear the bitmap then update it with the given input. 27659f977fb7SOctavian Purdila * 27669f977fb7SOctavian Purdila * Returns 0 on success. 27679f977fb7SOctavian Purdila */ 27689f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write, 27699f977fb7SOctavian Purdila void __user *buffer, size_t *lenp, loff_t *ppos) 27709f977fb7SOctavian Purdila { 27719f977fb7SOctavian Purdila int err = 0; 27729f977fb7SOctavian Purdila bool first = 1; 27739f977fb7SOctavian Purdila size_t left = *lenp; 27749f977fb7SOctavian Purdila unsigned long bitmap_len = table->maxlen; 27759f977fb7SOctavian Purdila unsigned long *bitmap = (unsigned long *) table->data; 27769f977fb7SOctavian Purdila unsigned long *tmp_bitmap = NULL; 27779f977fb7SOctavian Purdila char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 27789f977fb7SOctavian Purdila 27799f977fb7SOctavian Purdila if (!bitmap_len || !left || (*ppos && !write)) { 27809f977fb7SOctavian Purdila *lenp = 0; 27819f977fb7SOctavian Purdila return 0; 27829f977fb7SOctavian Purdila } 27839f977fb7SOctavian Purdila 27849f977fb7SOctavian Purdila if (write) { 27859f977fb7SOctavian Purdila unsigned long page = 0; 27869f977fb7SOctavian Purdila char *kbuf; 27879f977fb7SOctavian Purdila 27889f977fb7SOctavian Purdila if (left > PAGE_SIZE - 1) 27899f977fb7SOctavian Purdila left = PAGE_SIZE - 1; 27909f977fb7SOctavian Purdila 27919f977fb7SOctavian Purdila page = __get_free_page(GFP_TEMPORARY); 27929f977fb7SOctavian Purdila kbuf = (char *) page; 27939f977fb7SOctavian Purdila if (!kbuf) 27949f977fb7SOctavian Purdila return -ENOMEM; 27959f977fb7SOctavian Purdila if (copy_from_user(kbuf, buffer, left)) { 27969f977fb7SOctavian Purdila free_page(page); 27979f977fb7SOctavian Purdila return -EFAULT; 27989f977fb7SOctavian Purdila } 27999f977fb7SOctavian Purdila kbuf[left] = 0; 28009f977fb7SOctavian Purdila 28019f977fb7SOctavian Purdila tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), 28029f977fb7SOctavian Purdila GFP_KERNEL); 28039f977fb7SOctavian Purdila if (!tmp_bitmap) { 28049f977fb7SOctavian Purdila free_page(page); 28059f977fb7SOctavian Purdila return -ENOMEM; 28069f977fb7SOctavian Purdila } 28079f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28089f977fb7SOctavian Purdila while (!err && left) { 28099f977fb7SOctavian Purdila unsigned long val_a, val_b; 28109f977fb7SOctavian Purdila bool neg; 28119f977fb7SOctavian Purdila 28129f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, 28139f977fb7SOctavian Purdila sizeof(tr_a), &c); 28149f977fb7SOctavian Purdila if (err) 28159f977fb7SOctavian Purdila break; 28169f977fb7SOctavian Purdila if (val_a >= bitmap_len || neg) { 28179f977fb7SOctavian Purdila err = -EINVAL; 28189f977fb7SOctavian Purdila break; 28199f977fb7SOctavian Purdila } 28209f977fb7SOctavian Purdila 28219f977fb7SOctavian Purdila val_b = val_a; 28229f977fb7SOctavian Purdila if (left) { 28239f977fb7SOctavian Purdila kbuf++; 28249f977fb7SOctavian Purdila left--; 28259f977fb7SOctavian Purdila } 28269f977fb7SOctavian Purdila 28279f977fb7SOctavian Purdila if (c == '-') { 28289f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_b, 28299f977fb7SOctavian Purdila &neg, tr_b, sizeof(tr_b), 28309f977fb7SOctavian Purdila &c); 28319f977fb7SOctavian Purdila if (err) 28329f977fb7SOctavian Purdila break; 28339f977fb7SOctavian Purdila if (val_b >= bitmap_len || neg || 28349f977fb7SOctavian Purdila val_a > val_b) { 28359f977fb7SOctavian Purdila err = -EINVAL; 28369f977fb7SOctavian Purdila break; 28379f977fb7SOctavian Purdila } 28389f977fb7SOctavian Purdila if (left) { 28399f977fb7SOctavian Purdila kbuf++; 28409f977fb7SOctavian Purdila left--; 28419f977fb7SOctavian Purdila } 28429f977fb7SOctavian Purdila } 28439f977fb7SOctavian Purdila 28449f977fb7SOctavian Purdila while (val_a <= val_b) 28459f977fb7SOctavian Purdila set_bit(val_a++, tmp_bitmap); 28469f977fb7SOctavian Purdila 28479f977fb7SOctavian Purdila first = 0; 28489f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 28499f977fb7SOctavian Purdila } 28509f977fb7SOctavian Purdila free_page(page); 28519f977fb7SOctavian Purdila } else { 28529f977fb7SOctavian Purdila unsigned long bit_a, bit_b = 0; 28539f977fb7SOctavian Purdila 28549f977fb7SOctavian Purdila while (left) { 28559f977fb7SOctavian Purdila bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 28569f977fb7SOctavian Purdila if (bit_a >= bitmap_len) 28579f977fb7SOctavian Purdila break; 28589f977fb7SOctavian Purdila bit_b = find_next_zero_bit(bitmap, bitmap_len, 28599f977fb7SOctavian Purdila bit_a + 1) - 1; 28609f977fb7SOctavian Purdila 28619f977fb7SOctavian Purdila if (!first) { 28629f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, ','); 28639f977fb7SOctavian Purdila if (err) 28649f977fb7SOctavian Purdila break; 28659f977fb7SOctavian Purdila } 28669f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_a, false); 28679f977fb7SOctavian Purdila if (err) 28689f977fb7SOctavian Purdila break; 28699f977fb7SOctavian Purdila if (bit_a != bit_b) { 28709f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '-'); 28719f977fb7SOctavian Purdila if (err) 28729f977fb7SOctavian Purdila break; 28739f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_b, false); 28749f977fb7SOctavian Purdila if (err) 28759f977fb7SOctavian Purdila break; 28769f977fb7SOctavian Purdila } 28779f977fb7SOctavian Purdila 28789f977fb7SOctavian Purdila first = 0; bit_b++; 28799f977fb7SOctavian Purdila } 28809f977fb7SOctavian Purdila if (!err) 28819f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '\n'); 28829f977fb7SOctavian Purdila } 28839f977fb7SOctavian Purdila 28849f977fb7SOctavian Purdila if (!err) { 28859f977fb7SOctavian Purdila if (write) { 28869f977fb7SOctavian Purdila if (*ppos) 28879f977fb7SOctavian Purdila bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 28889f977fb7SOctavian Purdila else 28899f977fb7SOctavian Purdila memcpy(bitmap, tmp_bitmap, 28909f977fb7SOctavian Purdila BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long)); 28919f977fb7SOctavian Purdila } 28929f977fb7SOctavian Purdila kfree(tmp_bitmap); 28939f977fb7SOctavian Purdila *lenp -= left; 28949f977fb7SOctavian Purdila *ppos += *lenp; 28959f977fb7SOctavian Purdila return 0; 28969f977fb7SOctavian Purdila } else { 28979f977fb7SOctavian Purdila kfree(tmp_bitmap); 28989f977fb7SOctavian Purdila return err; 28999f977fb7SOctavian Purdila } 29009f977fb7SOctavian Purdila } 29019f977fb7SOctavian Purdila 29021da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 29031da177e4SLinus Torvalds 29048d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 29051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29061da177e4SLinus Torvalds { 29071da177e4SLinus Torvalds return -ENOSYS; 29081da177e4SLinus Torvalds } 29091da177e4SLinus Torvalds 29108d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 29111da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29121da177e4SLinus Torvalds { 29131da177e4SLinus Torvalds return -ENOSYS; 29141da177e4SLinus Torvalds } 29151da177e4SLinus Torvalds 29168d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 29171da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29181da177e4SLinus Torvalds { 29191da177e4SLinus Torvalds return -ENOSYS; 29201da177e4SLinus Torvalds } 29211da177e4SLinus Torvalds 29228d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 29231da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29241da177e4SLinus Torvalds { 29251da177e4SLinus Torvalds return -ENOSYS; 29261da177e4SLinus Torvalds } 29271da177e4SLinus Torvalds 29288d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 29291da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29301da177e4SLinus Torvalds { 29311da177e4SLinus Torvalds return -ENOSYS; 29321da177e4SLinus Torvalds } 29331da177e4SLinus Torvalds 29348d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 29351da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29361da177e4SLinus Torvalds { 29371da177e4SLinus Torvalds return -ENOSYS; 29381da177e4SLinus Torvalds } 29391da177e4SLinus Torvalds 29408d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 29411da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 29421da177e4SLinus Torvalds { 29431da177e4SLinus Torvalds return -ENOSYS; 29441da177e4SLinus Torvalds } 29451da177e4SLinus Torvalds 2946d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 29471da177e4SLinus Torvalds void __user *buffer, 29481da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 29491da177e4SLinus Torvalds { 29501da177e4SLinus Torvalds return -ENOSYS; 29511da177e4SLinus Torvalds } 29521da177e4SLinus Torvalds 29531da177e4SLinus Torvalds 29541da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 29551da177e4SLinus Torvalds 29561da177e4SLinus Torvalds /* 29571da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 29581da177e4SLinus Torvalds * exception granted :-) 29591da177e4SLinus Torvalds */ 29601da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 29611da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 29621da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 29631da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 29641da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 29651da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 29661da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 29671da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 29681da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 296929e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 29701da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2971