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> 265a04cca6SAkinobu Mita #include <linux/bitmap.h> 27d33ed52dSDave Young #include <linux/signal.h> 28455cd5abSDan Rosenberg #include <linux/printk.h> 291da177e4SLinus Torvalds #include <linux/proc_fs.h> 3072c2d582SAndrew Morgan #include <linux/security.h> 311da177e4SLinus Torvalds #include <linux/ctype.h> 32dfec072eSVegard Nossum #include <linux/kmemcheck.h> 33fd4b616bSSteven Rostedt #include <linux/kmemleak.h> 3462239ac2SAdrian Bunk #include <linux/fs.h> 351da177e4SLinus Torvalds #include <linux/init.h> 361da177e4SLinus Torvalds #include <linux/kernel.h> 370296b228SKay Sievers #include <linux/kobject.h> 3820380731SArnaldo Carvalho de Melo #include <linux/net.h> 391da177e4SLinus Torvalds #include <linux/sysrq.h> 401da177e4SLinus Torvalds #include <linux/highuid.h> 411da177e4SLinus Torvalds #include <linux/writeback.h> 423fff4c42SIngo Molnar #include <linux/ratelimit.h> 4376ab0f53SMel Gorman #include <linux/compaction.h> 441da177e4SLinus Torvalds #include <linux/hugetlb.h> 451da177e4SLinus Torvalds #include <linux/initrd.h> 460b77f5bfSDavid Howells #include <linux/key.h> 471da177e4SLinus Torvalds #include <linux/times.h> 481da177e4SLinus Torvalds #include <linux/limits.h> 491da177e4SLinus Torvalds #include <linux/dcache.h> 506e006701SAlexey Dobriyan #include <linux/dnotify.h> 511da177e4SLinus Torvalds #include <linux/syscalls.h> 52c748e134SAdrian Bunk #include <linux/vmstat.h> 53c255d844SPavel Machek #include <linux/nfs_fs.h> 54c255d844SPavel Machek #include <linux/acpi.h> 5510a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 56b0fc494fSSteven Rostedt #include <linux/ftrace.h> 57cdd6c482SIngo Molnar #include <linux/perf_event.h> 58b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 59b492e95bSJens Axboe #include <linux/pipe_fs_i.h> 608e4228e1SDavid Rientjes #include <linux/oom.h> 6117f60a7dSEric Paris #include <linux/kmod.h> 6273efc039SDan Ballard #include <linux/capability.h> 6340401530SAl Viro #include <linux/binfmts.h> 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds #include <asm/uaccess.h> 661da177e4SLinus Torvalds #include <asm/processor.h> 671da177e4SLinus Torvalds 6829cbc78bSAndi Kleen #ifdef CONFIG_X86 6929cbc78bSAndi Kleen #include <asm/nmi.h> 700741f4d2SChuck Ebbert #include <asm/stacktrace.h> 716e7c4025SIngo Molnar #include <asm/io.h> 7229cbc78bSAndi Kleen #endif 73d550bbd4SDavid Howells #ifdef CONFIG_SPARC 74d550bbd4SDavid Howells #include <asm/setup.h> 75d550bbd4SDavid Howells #endif 76c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 77c55b7c3eSDave Young #include <linux/acct.h> 78c55b7c3eSDave Young #endif 794f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 804f0e056fSDave Young #include <linux/rtmutex.h> 814f0e056fSDave Young #endif 822edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 832edf5e49SDave Young #include <linux/lockdep.h> 842edf5e49SDave Young #endif 8515485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 8615485a46SDave Young #include <scsi/sg.h> 8715485a46SDave Young #endif 8829cbc78bSAndi Kleen 8958687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 90504d7cf1SDon Zickus #include <linux/nmi.h> 91504d7cf1SDon Zickus #endif 92504d7cf1SDon Zickus 937058cb02SEric W. Biederman 941da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 951da177e4SLinus Torvalds 961da177e4SLinus Torvalds /* External variables not in a header file. */ 971da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 981da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 991da177e4SLinus Torvalds extern int max_threads; 1001da177e4SLinus Torvalds extern int core_uses_pid; 101d6e71144SAlan Cox extern int suid_dumpable; 1021da177e4SLinus Torvalds extern char core_pattern[]; 103a293980cSNeil Horman extern unsigned int core_pipe_limit; 1041da177e4SLinus Torvalds extern int pid_max; 1051da177e4SLinus Torvalds extern int min_free_kbytes; 1061da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 1079d0243bcSAndrew Morton extern int sysctl_drop_caches; 1088ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 109bebfa101SAndi Kleen extern int compat_log; 1109745512cSArjan van de Ven extern int latencytop_enabled; 111eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 112dd8632a1SPaul Mundt #ifndef CONFIG_MMU 113dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 114dd8632a1SPaul Mundt #endif 115cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 1165e605b64SJens Axboe extern int blk_iopoll_enabled; 117cb684b5bSJens Axboe #endif 1181da177e4SLinus Torvalds 119c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1202508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 121c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1229383d967SDimitri Sivanich static int neg_one = -1; 123c4f3b63fSRavikiran G Thirumalai #endif 124c4f3b63fSRavikiran G Thirumalai 125c4f3b63fSRavikiran G Thirumalai static int zero; 126cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 127cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 128cb16e95fSPetr Holasek static int __maybe_unused three = 3; 129fc3501d4SSven Wegener static unsigned long one_ul = 1; 130c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 131af91322eSDave Young #ifdef CONFIG_PRINTK 132af91322eSDave Young static int ten_thousand = 10000; 133af91322eSDave Young #endif 134c4f3b63fSRavikiran G Thirumalai 1359e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1369e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1379e4a5bdaSAndrea Righi 1381da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1391da177e4SLinus Torvalds static int maxolduid = 65535; 1401da177e4SLinus Torvalds static int minolduid; 1418ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1421da177e4SLinus Torvalds 1431da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 14473efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1451da177e4SLinus Torvalds 146d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 147d14f1729SDave Young #include <linux/inotify.h> 148d14f1729SDave Young #endif 14972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 1501da177e4SLinus Torvalds #endif 1511da177e4SLinus Torvalds 1520871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1530871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1540871420fSDavid S. Miller #endif 1550871420fSDavid S. Miller 1561da177e4SLinus Torvalds #ifdef __hppa__ 1571da177e4SLinus Torvalds extern int pwrsw_enabled; 1581da177e4SLinus Torvalds extern int unaligned_enabled; 1591da177e4SLinus Torvalds #endif 1601da177e4SLinus Torvalds 161d2b176edSJes Sorensen #ifdef CONFIG_IA64 162d2b176edSJes Sorensen extern int no_unaligned_warning; 16388fc241fSDoug Chapman extern int unaligned_dump_stack; 164d2b176edSJes Sorensen #endif 165d2b176edSJes Sorensen 166d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1678d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1689ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1698d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 17034f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 171d6f8ff73SRandy Dunlap #endif 1729ec52099SCedric Le Goater 173bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 174620f6e8eSKees Cook static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 175bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos); 176bfdc0b49SRichard Weinberger #endif 177bfdc0b49SRichard Weinberger 17854b50199SKees Cook static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 17954b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos); 18054b50199SKees Cook static int proc_dostring_coredump(struct ctl_table *table, int write, 18154b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos); 18254b50199SKees Cook 18397f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ 1848c6a98b2SAndy Whitcroft /* Note: sysrq code uses it's own private copy */ 1858c6a98b2SAndy Whitcroft static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; 18697f5f0cdSDmitry Torokhov 18797f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write, 18897f5f0cdSDmitry Torokhov void __user *buffer, size_t *lenp, 18997f5f0cdSDmitry Torokhov loff_t *ppos) 19097f5f0cdSDmitry Torokhov { 19197f5f0cdSDmitry Torokhov int error; 19297f5f0cdSDmitry Torokhov 19397f5f0cdSDmitry Torokhov error = proc_dointvec(table, write, buffer, lenp, ppos); 19497f5f0cdSDmitry Torokhov if (error) 19597f5f0cdSDmitry Torokhov return error; 19697f5f0cdSDmitry Torokhov 19797f5f0cdSDmitry Torokhov if (write) 19897f5f0cdSDmitry Torokhov sysrq_toggle_support(__sysrq_enabled); 19997f5f0cdSDmitry Torokhov 20097f5f0cdSDmitry Torokhov return 0; 20197f5f0cdSDmitry Torokhov } 20297f5f0cdSDmitry Torokhov 20397f5f0cdSDmitry Torokhov #endif 20497f5f0cdSDmitry Torokhov 205d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 206d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 207d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 208d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 209d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 210d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 2117ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 2127ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 2137ef9964eSDavide Libenzi #endif 2141da177e4SLinus Torvalds 2151da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2161da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2171da177e4SLinus Torvalds #endif 2181da177e4SLinus Torvalds 2191da177e4SLinus Torvalds /* The default sysctl tables: */ 2201da177e4SLinus Torvalds 221de4e83bdSEric W. Biederman static struct ctl_table sysctl_base_table[] = { 2221da177e4SLinus Torvalds { 2231da177e4SLinus Torvalds .procname = "kernel", 2241da177e4SLinus Torvalds .mode = 0555, 2251da177e4SLinus Torvalds .child = kern_table, 2261da177e4SLinus Torvalds }, 2271da177e4SLinus Torvalds { 2281da177e4SLinus Torvalds .procname = "vm", 2291da177e4SLinus Torvalds .mode = 0555, 2301da177e4SLinus Torvalds .child = vm_table, 2311da177e4SLinus Torvalds }, 2321da177e4SLinus Torvalds { 2331da177e4SLinus Torvalds .procname = "fs", 2341da177e4SLinus Torvalds .mode = 0555, 2351da177e4SLinus Torvalds .child = fs_table, 2361da177e4SLinus Torvalds }, 2371da177e4SLinus Torvalds { 2381da177e4SLinus Torvalds .procname = "debug", 2391da177e4SLinus Torvalds .mode = 0555, 2401da177e4SLinus Torvalds .child = debug_table, 2411da177e4SLinus Torvalds }, 2421da177e4SLinus Torvalds { 2431da177e4SLinus Torvalds .procname = "dev", 2441da177e4SLinus Torvalds .mode = 0555, 2451da177e4SLinus Torvalds .child = dev_table, 2461da177e4SLinus Torvalds }, 2476fce56ecSEric W. Biederman { } 2481da177e4SLinus Torvalds }; 2491da177e4SLinus Torvalds 25077e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 25173c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 25273c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 25373c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 25473c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2551983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2561983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 25777e54a1fSIngo Molnar #endif 25877e54a1fSIngo Molnar 2595e771905SMel Gorman #ifdef CONFIG_COMPACTION 2605e771905SMel Gorman static int min_extfrag_threshold; 2615e771905SMel Gorman static int max_extfrag_threshold = 1000; 2625e771905SMel Gorman #endif 2635e771905SMel Gorman 264d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2652bba22c5SMike Galbraith { 2662bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2672bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2682bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2692bba22c5SMike Galbraith .mode = 0644, 2706d456111SEric W. Biederman .proc_handler = proc_dointvec, 2712bba22c5SMike Galbraith }, 27277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 27377e54a1fSIngo Molnar { 274b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 275b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 27677e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 27777e54a1fSIngo Molnar .mode = 0644, 278702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 279b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 280b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28177e54a1fSIngo Molnar }, 28277e54a1fSIngo Molnar { 28321805085SPeter Zijlstra .procname = "sched_latency_ns", 28421805085SPeter Zijlstra .data = &sysctl_sched_latency, 28521805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 28621805085SPeter Zijlstra .mode = 0644, 287702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 28821805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 28921805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 29021805085SPeter Zijlstra }, 29121805085SPeter Zijlstra { 29277e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 29377e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 29477e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 29577e54a1fSIngo Molnar .mode = 0644, 296702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 29777e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 29877e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 29977e54a1fSIngo Molnar }, 30077e54a1fSIngo Molnar { 3011983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3021983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3031983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3041983a922SChristian Ehrhardt .mode = 0644, 305702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3061983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3071983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3082398f2c6SPeter Zijlstra }, 3092398f2c6SPeter Zijlstra { 310*d00535dbSNamhyung Kim .procname = "sched_migration_cost_ns", 311da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 312da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 313da84d961SIngo Molnar .mode = 0644, 3146d456111SEric W. Biederman .proc_handler = proc_dointvec, 315da84d961SIngo Molnar }, 316b82d9fddSPeter Zijlstra { 317b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 318b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 319b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 320fa85ae24SPeter Zijlstra .mode = 0644, 3216d456111SEric W. Biederman .proc_handler = proc_dointvec, 322fa85ae24SPeter Zijlstra }, 323cd1bb94bSArun R Bharadwaj { 324*d00535dbSNamhyung Kim .procname = "sched_time_avg_ms", 325e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 326e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 327e9e9250bSPeter Zijlstra .mode = 0644, 3286d456111SEric W. Biederman .proc_handler = proc_dointvec, 329e9e9250bSPeter Zijlstra }, 330e9e9250bSPeter Zijlstra { 331*d00535dbSNamhyung Kim .procname = "sched_shares_window_ns", 332a7a4f8a7SPaul Turner .data = &sysctl_sched_shares_window, 333a7a4f8a7SPaul Turner .maxlen = sizeof(unsigned int), 334a7a4f8a7SPaul Turner .mode = 0644, 335a7a4f8a7SPaul Turner .proc_handler = proc_dointvec, 336a7a4f8a7SPaul Turner }, 337a7a4f8a7SPaul Turner { 338cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 339cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 340cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 341cd1bb94bSArun R Bharadwaj .mode = 0644, 3426d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 343bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 344bfdb4d9fSArun R Bharadwaj .extra2 = &one, 345cd1bb94bSArun R Bharadwaj }, 3461fc84aaaSPeter Zijlstra #endif 3471799e35dSIngo Molnar { 3489f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3499f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3509f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3519f0c1e56SPeter Zijlstra .mode = 0644, 3526d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3539f0c1e56SPeter Zijlstra }, 3549f0c1e56SPeter Zijlstra { 3559f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3569f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3579f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3589f0c1e56SPeter Zijlstra .mode = 0644, 3596d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3609f0c1e56SPeter Zijlstra }, 3615091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 3625091faa4SMike Galbraith { 3635091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 3645091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 3655091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 3665091faa4SMike Galbraith .mode = 0644, 3671747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 3685091faa4SMike Galbraith .extra1 = &zero, 3695091faa4SMike Galbraith .extra2 = &one, 3705091faa4SMike Galbraith }, 3715091faa4SMike Galbraith #endif 372ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 373ec12cb7fSPaul Turner { 374ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 375ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 376ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 377ec12cb7fSPaul Turner .mode = 0644, 378ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 379ec12cb7fSPaul Turner .extra1 = &one, 380ec12cb7fSPaul Turner }, 381ec12cb7fSPaul Turner #endif 382f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 383f20786ffSPeter Zijlstra { 384f20786ffSPeter Zijlstra .procname = "prove_locking", 385f20786ffSPeter Zijlstra .data = &prove_locking, 386f20786ffSPeter Zijlstra .maxlen = sizeof(int), 387f20786ffSPeter Zijlstra .mode = 0644, 3886d456111SEric W. Biederman .proc_handler = proc_dointvec, 389f20786ffSPeter Zijlstra }, 390f20786ffSPeter Zijlstra #endif 391f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 392f20786ffSPeter Zijlstra { 393f20786ffSPeter Zijlstra .procname = "lock_stat", 394f20786ffSPeter Zijlstra .data = &lock_stat, 395f20786ffSPeter Zijlstra .maxlen = sizeof(int), 396f20786ffSPeter Zijlstra .mode = 0644, 3976d456111SEric W. Biederman .proc_handler = proc_dointvec, 398f20786ffSPeter Zijlstra }, 399f20786ffSPeter Zijlstra #endif 40077e54a1fSIngo Molnar { 4011da177e4SLinus Torvalds .procname = "panic", 4021da177e4SLinus Torvalds .data = &panic_timeout, 4031da177e4SLinus Torvalds .maxlen = sizeof(int), 4041da177e4SLinus Torvalds .mode = 0644, 4056d456111SEric W. Biederman .proc_handler = proc_dointvec, 4061da177e4SLinus Torvalds }, 4071da177e4SLinus Torvalds { 4081da177e4SLinus Torvalds .procname = "core_uses_pid", 4091da177e4SLinus Torvalds .data = &core_uses_pid, 4101da177e4SLinus Torvalds .maxlen = sizeof(int), 4111da177e4SLinus Torvalds .mode = 0644, 4126d456111SEric W. Biederman .proc_handler = proc_dointvec, 4131da177e4SLinus Torvalds }, 4141da177e4SLinus Torvalds { 4151da177e4SLinus Torvalds .procname = "core_pattern", 4161da177e4SLinus Torvalds .data = core_pattern, 41771ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4181da177e4SLinus Torvalds .mode = 0644, 41954b50199SKees Cook .proc_handler = proc_dostring_coredump, 4201da177e4SLinus Torvalds }, 421a293980cSNeil Horman { 422a293980cSNeil Horman .procname = "core_pipe_limit", 423a293980cSNeil Horman .data = &core_pipe_limit, 424a293980cSNeil Horman .maxlen = sizeof(unsigned int), 425a293980cSNeil Horman .mode = 0644, 4266d456111SEric W. Biederman .proc_handler = proc_dointvec, 427a293980cSNeil Horman }, 42834f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4291da177e4SLinus Torvalds { 4301da177e4SLinus Torvalds .procname = "tainted", 43125ddbb18SAndi Kleen .maxlen = sizeof(long), 43234f5a398STheodore Ts'o .mode = 0644, 4336d456111SEric W. Biederman .proc_handler = proc_taint, 4341da177e4SLinus Torvalds }, 43534f5a398STheodore Ts'o #endif 4369745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4379745512cSArjan van de Ven { 4389745512cSArjan van de Ven .procname = "latencytop", 4399745512cSArjan van de Ven .data = &latencytop_enabled, 4409745512cSArjan van de Ven .maxlen = sizeof(int), 4419745512cSArjan van de Ven .mode = 0644, 4426d456111SEric W. Biederman .proc_handler = proc_dointvec, 4439745512cSArjan van de Ven }, 4449745512cSArjan van de Ven #endif 4451da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4461da177e4SLinus Torvalds { 4471da177e4SLinus Torvalds .procname = "real-root-dev", 4481da177e4SLinus Torvalds .data = &real_root_dev, 4491da177e4SLinus Torvalds .maxlen = sizeof(int), 4501da177e4SLinus Torvalds .mode = 0644, 4516d456111SEric W. Biederman .proc_handler = proc_dointvec, 4521da177e4SLinus Torvalds }, 4531da177e4SLinus Torvalds #endif 45445807a1dSIngo Molnar { 45545807a1dSIngo Molnar .procname = "print-fatal-signals", 45645807a1dSIngo Molnar .data = &print_fatal_signals, 45745807a1dSIngo Molnar .maxlen = sizeof(int), 45845807a1dSIngo Molnar .mode = 0644, 4596d456111SEric W. Biederman .proc_handler = proc_dointvec, 46045807a1dSIngo Molnar }, 46172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4621da177e4SLinus Torvalds { 4631da177e4SLinus Torvalds .procname = "reboot-cmd", 4641da177e4SLinus Torvalds .data = reboot_command, 4651da177e4SLinus Torvalds .maxlen = 256, 4661da177e4SLinus Torvalds .mode = 0644, 4676d456111SEric W. Biederman .proc_handler = proc_dostring, 4681da177e4SLinus Torvalds }, 4691da177e4SLinus Torvalds { 4701da177e4SLinus Torvalds .procname = "stop-a", 4711da177e4SLinus Torvalds .data = &stop_a_enabled, 4721da177e4SLinus Torvalds .maxlen = sizeof (int), 4731da177e4SLinus Torvalds .mode = 0644, 4746d456111SEric W. Biederman .proc_handler = proc_dointvec, 4751da177e4SLinus Torvalds }, 4761da177e4SLinus Torvalds { 4771da177e4SLinus Torvalds .procname = "scons-poweroff", 4781da177e4SLinus Torvalds .data = &scons_pwroff, 4791da177e4SLinus Torvalds .maxlen = sizeof (int), 4801da177e4SLinus Torvalds .mode = 0644, 4816d456111SEric W. Biederman .proc_handler = proc_dointvec, 4821da177e4SLinus Torvalds }, 4831da177e4SLinus Torvalds #endif 4840871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4850871420fSDavid S. Miller { 4860871420fSDavid S. Miller .procname = "tsb-ratio", 4870871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4880871420fSDavid S. Miller .maxlen = sizeof (int), 4890871420fSDavid S. Miller .mode = 0644, 4906d456111SEric W. Biederman .proc_handler = proc_dointvec, 4910871420fSDavid S. Miller }, 4920871420fSDavid S. Miller #endif 4931da177e4SLinus Torvalds #ifdef __hppa__ 4941da177e4SLinus Torvalds { 4951da177e4SLinus Torvalds .procname = "soft-power", 4961da177e4SLinus Torvalds .data = &pwrsw_enabled, 4971da177e4SLinus Torvalds .maxlen = sizeof (int), 4981da177e4SLinus Torvalds .mode = 0644, 4996d456111SEric W. Biederman .proc_handler = proc_dointvec, 5001da177e4SLinus Torvalds }, 5011da177e4SLinus Torvalds { 5021da177e4SLinus Torvalds .procname = "unaligned-trap", 5031da177e4SLinus Torvalds .data = &unaligned_enabled, 5041da177e4SLinus Torvalds .maxlen = sizeof (int), 5051da177e4SLinus Torvalds .mode = 0644, 5066d456111SEric W. Biederman .proc_handler = proc_dointvec, 5071da177e4SLinus Torvalds }, 5081da177e4SLinus Torvalds #endif 5091da177e4SLinus Torvalds { 5101da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5111da177e4SLinus Torvalds .data = &C_A_D, 5121da177e4SLinus Torvalds .maxlen = sizeof(int), 5131da177e4SLinus Torvalds .mode = 0644, 5146d456111SEric W. Biederman .proc_handler = proc_dointvec, 5151da177e4SLinus Torvalds }, 516606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 517b0fc494fSSteven Rostedt { 518b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 519b0fc494fSSteven Rostedt .data = &ftrace_enabled, 520b0fc494fSSteven Rostedt .maxlen = sizeof(int), 521b0fc494fSSteven Rostedt .mode = 0644, 5226d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 523b0fc494fSSteven Rostedt }, 524b0fc494fSSteven Rostedt #endif 525f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 526f38f1d2aSSteven Rostedt { 527f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 528f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 529f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 530f38f1d2aSSteven Rostedt .mode = 0644, 5316d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 532f38f1d2aSSteven Rostedt }, 533f38f1d2aSSteven Rostedt #endif 534944ac425SSteven Rostedt #ifdef CONFIG_TRACING 535944ac425SSteven Rostedt { 5363299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 537944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 538944ac425SSteven Rostedt .maxlen = sizeof(int), 539944ac425SSteven Rostedt .mode = 0644, 5406d456111SEric W. Biederman .proc_handler = proc_dointvec, 541944ac425SSteven Rostedt }, 542944ac425SSteven Rostedt #endif 543a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5441da177e4SLinus Torvalds { 5451da177e4SLinus Torvalds .procname = "modprobe", 5461da177e4SLinus Torvalds .data = &modprobe_path, 5471da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5481da177e4SLinus Torvalds .mode = 0644, 5496d456111SEric W. Biederman .proc_handler = proc_dostring, 5501da177e4SLinus Torvalds }, 5513d43321bSKees Cook { 5523d43321bSKees Cook .procname = "modules_disabled", 5533d43321bSKees Cook .data = &modules_disabled, 5543d43321bSKees Cook .maxlen = sizeof(int), 5553d43321bSKees Cook .mode = 0644, 5563d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5576d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5583d43321bSKees Cook .extra1 = &one, 5593d43321bSKees Cook .extra2 = &one, 5603d43321bSKees Cook }, 5611da177e4SLinus Torvalds #endif 56294f17cd7SIan Abbott #ifdef CONFIG_HOTPLUG 5631da177e4SLinus Torvalds { 5641da177e4SLinus Torvalds .procname = "hotplug", 565312c004dSKay Sievers .data = &uevent_helper, 566312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5671da177e4SLinus Torvalds .mode = 0644, 5686d456111SEric W. Biederman .proc_handler = proc_dostring, 5691da177e4SLinus Torvalds }, 5701da177e4SLinus Torvalds #endif 5711da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5721da177e4SLinus Torvalds { 5731da177e4SLinus Torvalds .procname = "sg-big-buff", 5741da177e4SLinus Torvalds .data = &sg_big_buff, 5751da177e4SLinus Torvalds .maxlen = sizeof (int), 5761da177e4SLinus Torvalds .mode = 0444, 5776d456111SEric W. Biederman .proc_handler = proc_dointvec, 5781da177e4SLinus Torvalds }, 5791da177e4SLinus Torvalds #endif 5801da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5811da177e4SLinus Torvalds { 5821da177e4SLinus Torvalds .procname = "acct", 5831da177e4SLinus Torvalds .data = &acct_parm, 5841da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5851da177e4SLinus Torvalds .mode = 0644, 5866d456111SEric W. Biederman .proc_handler = proc_dointvec, 5871da177e4SLinus Torvalds }, 5881da177e4SLinus Torvalds #endif 5891da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5901da177e4SLinus Torvalds { 5911da177e4SLinus Torvalds .procname = "sysrq", 5925d6f647fSIngo Molnar .data = &__sysrq_enabled, 5931da177e4SLinus Torvalds .maxlen = sizeof (int), 5941da177e4SLinus Torvalds .mode = 0644, 59597f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 5961da177e4SLinus Torvalds }, 5971da177e4SLinus Torvalds #endif 598d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5991da177e4SLinus Torvalds { 6001da177e4SLinus Torvalds .procname = "cad_pid", 6019ec52099SCedric Le Goater .data = NULL, 6021da177e4SLinus Torvalds .maxlen = sizeof (int), 6031da177e4SLinus Torvalds .mode = 0600, 6046d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 6051da177e4SLinus Torvalds }, 606d6f8ff73SRandy Dunlap #endif 6071da177e4SLinus Torvalds { 6081da177e4SLinus Torvalds .procname = "threads-max", 6091da177e4SLinus Torvalds .data = &max_threads, 6101da177e4SLinus Torvalds .maxlen = sizeof(int), 6111da177e4SLinus Torvalds .mode = 0644, 6126d456111SEric W. Biederman .proc_handler = proc_dointvec, 6131da177e4SLinus Torvalds }, 6141da177e4SLinus Torvalds { 6151da177e4SLinus Torvalds .procname = "random", 6161da177e4SLinus Torvalds .mode = 0555, 6171da177e4SLinus Torvalds .child = random_table, 6181da177e4SLinus Torvalds }, 6191da177e4SLinus Torvalds { 62017f60a7dSEric Paris .procname = "usermodehelper", 62117f60a7dSEric Paris .mode = 0555, 62217f60a7dSEric Paris .child = usermodehelper_table, 62317f60a7dSEric Paris }, 62417f60a7dSEric Paris { 6251da177e4SLinus Torvalds .procname = "overflowuid", 6261da177e4SLinus Torvalds .data = &overflowuid, 6271da177e4SLinus Torvalds .maxlen = sizeof(int), 6281da177e4SLinus Torvalds .mode = 0644, 6296d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6301da177e4SLinus Torvalds .extra1 = &minolduid, 6311da177e4SLinus Torvalds .extra2 = &maxolduid, 6321da177e4SLinus Torvalds }, 6331da177e4SLinus Torvalds { 6341da177e4SLinus Torvalds .procname = "overflowgid", 6351da177e4SLinus Torvalds .data = &overflowgid, 6361da177e4SLinus Torvalds .maxlen = sizeof(int), 6371da177e4SLinus Torvalds .mode = 0644, 6386d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6391da177e4SLinus Torvalds .extra1 = &minolduid, 6401da177e4SLinus Torvalds .extra2 = &maxolduid, 6411da177e4SLinus Torvalds }, 642347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6431da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6441da177e4SLinus Torvalds { 6451da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6461da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6471da177e4SLinus Torvalds .maxlen = sizeof(int), 6481da177e4SLinus Torvalds .mode = 0644, 6496d456111SEric W. Biederman .proc_handler = proc_dointvec, 6501da177e4SLinus Torvalds }, 6511da177e4SLinus Torvalds #endif 6521da177e4SLinus Torvalds { 6531da177e4SLinus Torvalds .procname = "userprocess_debug", 654ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 6551da177e4SLinus Torvalds .maxlen = sizeof(int), 6561da177e4SLinus Torvalds .mode = 0644, 6576d456111SEric W. Biederman .proc_handler = proc_dointvec, 6581da177e4SLinus Torvalds }, 6591da177e4SLinus Torvalds #endif 6601da177e4SLinus Torvalds { 6611da177e4SLinus Torvalds .procname = "pid_max", 6621da177e4SLinus Torvalds .data = &pid_max, 6631da177e4SLinus Torvalds .maxlen = sizeof (int), 6641da177e4SLinus Torvalds .mode = 0644, 6656d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6661da177e4SLinus Torvalds .extra1 = &pid_max_min, 6671da177e4SLinus Torvalds .extra2 = &pid_max_max, 6681da177e4SLinus Torvalds }, 6691da177e4SLinus Torvalds { 6701da177e4SLinus Torvalds .procname = "panic_on_oops", 6711da177e4SLinus Torvalds .data = &panic_on_oops, 6721da177e4SLinus Torvalds .maxlen = sizeof(int), 6731da177e4SLinus Torvalds .mode = 0644, 6746d456111SEric W. Biederman .proc_handler = proc_dointvec, 6751da177e4SLinus Torvalds }, 6767ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6777ef3d2fdSJoe Perches { 6787ef3d2fdSJoe Perches .procname = "printk", 6797ef3d2fdSJoe Perches .data = &console_loglevel, 6807ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6817ef3d2fdSJoe Perches .mode = 0644, 6826d456111SEric W. Biederman .proc_handler = proc_dointvec, 6837ef3d2fdSJoe Perches }, 6841da177e4SLinus Torvalds { 6851da177e4SLinus Torvalds .procname = "printk_ratelimit", 686717115e1SDave Young .data = &printk_ratelimit_state.interval, 6871da177e4SLinus Torvalds .maxlen = sizeof(int), 6881da177e4SLinus Torvalds .mode = 0644, 6896d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6901da177e4SLinus Torvalds }, 6911da177e4SLinus Torvalds { 6921da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 693717115e1SDave Young .data = &printk_ratelimit_state.burst, 6941da177e4SLinus Torvalds .maxlen = sizeof(int), 6951da177e4SLinus Torvalds .mode = 0644, 6966d456111SEric W. Biederman .proc_handler = proc_dointvec, 6971da177e4SLinus Torvalds }, 698af91322eSDave Young { 699af91322eSDave Young .procname = "printk_delay", 700af91322eSDave Young .data = &printk_delay_msec, 701af91322eSDave Young .maxlen = sizeof(int), 702af91322eSDave Young .mode = 0644, 7036d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 704af91322eSDave Young .extra1 = &zero, 705af91322eSDave Young .extra2 = &ten_thousand, 706af91322eSDave Young }, 7071da177e4SLinus Torvalds { 708eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 709eaf06b24SDan Rosenberg .data = &dmesg_restrict, 710eaf06b24SDan Rosenberg .maxlen = sizeof(int), 711eaf06b24SDan Rosenberg .mode = 0644, 712620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 713eaf06b24SDan Rosenberg .extra1 = &zero, 714eaf06b24SDan Rosenberg .extra2 = &one, 715eaf06b24SDan Rosenberg }, 716455cd5abSDan Rosenberg { 717455cd5abSDan Rosenberg .procname = "kptr_restrict", 718455cd5abSDan Rosenberg .data = &kptr_restrict, 719455cd5abSDan Rosenberg .maxlen = sizeof(int), 720455cd5abSDan Rosenberg .mode = 0644, 721620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 722455cd5abSDan Rosenberg .extra1 = &zero, 723455cd5abSDan Rosenberg .extra2 = &two, 724455cd5abSDan Rosenberg }, 725df6e61d4SJoe Perches #endif 726eaf06b24SDan Rosenberg { 7271da177e4SLinus Torvalds .procname = "ngroups_max", 7281da177e4SLinus Torvalds .data = &ngroups_max, 7291da177e4SLinus Torvalds .maxlen = sizeof (int), 7301da177e4SLinus Torvalds .mode = 0444, 7316d456111SEric W. Biederman .proc_handler = proc_dointvec, 7321da177e4SLinus Torvalds }, 73373efc039SDan Ballard { 73473efc039SDan Ballard .procname = "cap_last_cap", 73573efc039SDan Ballard .data = (void *)&cap_last_cap, 73673efc039SDan Ballard .maxlen = sizeof(int), 73773efc039SDan Ballard .mode = 0444, 73873efc039SDan Ballard .proc_handler = proc_dointvec, 73973efc039SDan Ballard }, 74058687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 741504d7cf1SDon Zickus { 74258687acbSDon Zickus .procname = "watchdog", 74358687acbSDon Zickus .data = &watchdog_enabled, 744504d7cf1SDon Zickus .maxlen = sizeof (int), 745504d7cf1SDon Zickus .mode = 0644, 746586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 747586692a5SMandeep Singh Baines .extra1 = &zero, 748586692a5SMandeep Singh Baines .extra2 = &one, 74958687acbSDon Zickus }, 75058687acbSDon Zickus { 75158687acbSDon Zickus .procname = "watchdog_thresh", 752586692a5SMandeep Singh Baines .data = &watchdog_thresh, 75358687acbSDon Zickus .maxlen = sizeof(int), 75458687acbSDon Zickus .mode = 0644, 755586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 75658687acbSDon Zickus .extra1 = &neg_one, 75758687acbSDon Zickus .extra2 = &sixty, 758504d7cf1SDon Zickus }, 7592508ce18SDon Zickus { 7602508ce18SDon Zickus .procname = "softlockup_panic", 7612508ce18SDon Zickus .data = &softlockup_panic, 7622508ce18SDon Zickus .maxlen = sizeof(int), 7632508ce18SDon Zickus .mode = 0644, 7642508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 7652508ce18SDon Zickus .extra1 = &zero, 7662508ce18SDon Zickus .extra2 = &one, 7672508ce18SDon Zickus }, 7685dc30558SDon Zickus { 7695dc30558SDon Zickus .procname = "nmi_watchdog", 7705dc30558SDon Zickus .data = &watchdog_enabled, 7715dc30558SDon Zickus .maxlen = sizeof (int), 7725dc30558SDon Zickus .mode = 0644, 773586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 774586692a5SMandeep Singh Baines .extra1 = &zero, 775586692a5SMandeep Singh Baines .extra2 = &one, 7765dc30558SDon Zickus }, 7775dc30558SDon Zickus #endif 7785dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7795dc30558SDon Zickus { 7805dc30558SDon Zickus .procname = "unknown_nmi_panic", 7815dc30558SDon Zickus .data = &unknown_nmi_panic, 7825dc30558SDon Zickus .maxlen = sizeof (int), 7835dc30558SDon Zickus .mode = 0644, 7845dc30558SDon Zickus .proc_handler = proc_dointvec, 7855dc30558SDon Zickus }, 786504d7cf1SDon Zickus #endif 7871da177e4SLinus Torvalds #if defined(CONFIG_X86) 7881da177e4SLinus Torvalds { 7898da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7908da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7918da5addaSDon Zickus .maxlen = sizeof(int), 7928da5addaSDon Zickus .mode = 0644, 7936d456111SEric W. Biederman .proc_handler = proc_dointvec, 7948da5addaSDon Zickus }, 7958da5addaSDon Zickus { 7965211a242SKurt Garloff .procname = "panic_on_io_nmi", 7975211a242SKurt Garloff .data = &panic_on_io_nmi, 7985211a242SKurt Garloff .maxlen = sizeof(int), 7995211a242SKurt Garloff .mode = 0644, 8006d456111SEric W. Biederman .proc_handler = proc_dointvec, 8015211a242SKurt Garloff }, 80255af7796SMitsuo Hayasaka #ifdef CONFIG_DEBUG_STACKOVERFLOW 80355af7796SMitsuo Hayasaka { 80455af7796SMitsuo Hayasaka .procname = "panic_on_stackoverflow", 80555af7796SMitsuo Hayasaka .data = &sysctl_panic_on_stackoverflow, 80655af7796SMitsuo Hayasaka .maxlen = sizeof(int), 80755af7796SMitsuo Hayasaka .mode = 0644, 80855af7796SMitsuo Hayasaka .proc_handler = proc_dointvec, 80955af7796SMitsuo Hayasaka }, 81055af7796SMitsuo Hayasaka #endif 8115211a242SKurt Garloff { 8121da177e4SLinus Torvalds .procname = "bootloader_type", 8131da177e4SLinus Torvalds .data = &bootloader_type, 8141da177e4SLinus Torvalds .maxlen = sizeof (int), 8151da177e4SLinus Torvalds .mode = 0444, 8166d456111SEric W. Biederman .proc_handler = proc_dointvec, 8171da177e4SLinus Torvalds }, 8180741f4d2SChuck Ebbert { 8195031296cSH. Peter Anvin .procname = "bootloader_version", 8205031296cSH. Peter Anvin .data = &bootloader_version, 8215031296cSH. Peter Anvin .maxlen = sizeof (int), 8225031296cSH. Peter Anvin .mode = 0444, 8236d456111SEric W. Biederman .proc_handler = proc_dointvec, 8245031296cSH. Peter Anvin }, 8255031296cSH. Peter Anvin { 8260741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 8270741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 8280741f4d2SChuck Ebbert .maxlen = sizeof(int), 8290741f4d2SChuck Ebbert .mode = 0644, 8306d456111SEric W. Biederman .proc_handler = proc_dointvec, 8310741f4d2SChuck Ebbert }, 8326e7c4025SIngo Molnar { 8336e7c4025SIngo Molnar .procname = "io_delay_type", 8346e7c4025SIngo Molnar .data = &io_delay_type, 8356e7c4025SIngo Molnar .maxlen = sizeof(int), 8366e7c4025SIngo Molnar .mode = 0644, 8376d456111SEric W. Biederman .proc_handler = proc_dointvec, 8386e7c4025SIngo Molnar }, 8391da177e4SLinus Torvalds #endif 8407a9166e3SLuke Yang #if defined(CONFIG_MMU) 8411da177e4SLinus Torvalds { 8421da177e4SLinus Torvalds .procname = "randomize_va_space", 8431da177e4SLinus Torvalds .data = &randomize_va_space, 8441da177e4SLinus Torvalds .maxlen = sizeof(int), 8451da177e4SLinus Torvalds .mode = 0644, 8466d456111SEric W. Biederman .proc_handler = proc_dointvec, 8471da177e4SLinus Torvalds }, 8487a9166e3SLuke Yang #endif 8490152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 850951f22d5SMartin Schwidefsky { 851951f22d5SMartin Schwidefsky .procname = "spin_retry", 852951f22d5SMartin Schwidefsky .data = &spin_retry, 853951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 854951f22d5SMartin Schwidefsky .mode = 0644, 8556d456111SEric W. Biederman .proc_handler = proc_dointvec, 856951f22d5SMartin Schwidefsky }, 857951f22d5SMartin Schwidefsky #endif 858673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 859c255d844SPavel Machek { 860c255d844SPavel Machek .procname = "acpi_video_flags", 86177afcf78SPavel Machek .data = &acpi_realmode_flags, 862c255d844SPavel Machek .maxlen = sizeof (unsigned long), 863c255d844SPavel Machek .mode = 0644, 8646d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 865c255d844SPavel Machek }, 866c255d844SPavel Machek #endif 867d2b176edSJes Sorensen #ifdef CONFIG_IA64 868d2b176edSJes Sorensen { 869d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 870d2b176edSJes Sorensen .data = &no_unaligned_warning, 871d2b176edSJes Sorensen .maxlen = sizeof (int), 872d2b176edSJes Sorensen .mode = 0644, 8736d456111SEric W. Biederman .proc_handler = proc_dointvec, 874d2b176edSJes Sorensen }, 87588fc241fSDoug Chapman { 87688fc241fSDoug Chapman .procname = "unaligned-dump-stack", 87788fc241fSDoug Chapman .data = &unaligned_dump_stack, 87888fc241fSDoug Chapman .maxlen = sizeof (int), 87988fc241fSDoug Chapman .mode = 0644, 8806d456111SEric W. Biederman .proc_handler = proc_dointvec, 88188fc241fSDoug Chapman }, 882d2b176edSJes Sorensen #endif 883e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 884e162b39aSMandeep Singh Baines { 885e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 886e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 887e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 888e162b39aSMandeep Singh Baines .mode = 0644, 8896d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 890e162b39aSMandeep Singh Baines .extra1 = &zero, 891e162b39aSMandeep Singh Baines .extra2 = &one, 892e162b39aSMandeep Singh Baines }, 89382a1fcb9SIngo Molnar { 89482a1fcb9SIngo Molnar .procname = "hung_task_check_count", 89582a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 89690739081SIngo Molnar .maxlen = sizeof(unsigned long), 89782a1fcb9SIngo Molnar .mode = 0644, 8986d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 89982a1fcb9SIngo Molnar }, 90082a1fcb9SIngo Molnar { 90182a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 90282a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 90390739081SIngo Molnar .maxlen = sizeof(unsigned long), 90482a1fcb9SIngo Molnar .mode = 0644, 9056d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 90682a1fcb9SIngo Molnar }, 90782a1fcb9SIngo Molnar { 90882a1fcb9SIngo Molnar .procname = "hung_task_warnings", 90982a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 91090739081SIngo Molnar .maxlen = sizeof(unsigned long), 91182a1fcb9SIngo Molnar .mode = 0644, 9126d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 91382a1fcb9SIngo Molnar }, 914c4f3b63fSRavikiran G Thirumalai #endif 915bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 916bebfa101SAndi Kleen { 917bebfa101SAndi Kleen .procname = "compat-log", 918bebfa101SAndi Kleen .data = &compat_log, 919bebfa101SAndi Kleen .maxlen = sizeof (int), 920bebfa101SAndi Kleen .mode = 0644, 9216d456111SEric W. Biederman .proc_handler = proc_dointvec, 922bebfa101SAndi Kleen }, 923bebfa101SAndi Kleen #endif 92423f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 92523f78d4aSIngo Molnar { 92623f78d4aSIngo Molnar .procname = "max_lock_depth", 92723f78d4aSIngo Molnar .data = &max_lock_depth, 92823f78d4aSIngo Molnar .maxlen = sizeof(int), 92923f78d4aSIngo Molnar .mode = 0644, 9306d456111SEric W. Biederman .proc_handler = proc_dointvec, 93123f78d4aSIngo Molnar }, 93223f78d4aSIngo Molnar #endif 93310a0a8d4SJeremy Fitzhardinge { 93410a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 93510a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 93610a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 93710a0a8d4SJeremy Fitzhardinge .mode = 0644, 9386d456111SEric W. Biederman .proc_handler = proc_dostring, 93910a0a8d4SJeremy Fitzhardinge }, 9400b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9410b77f5bfSDavid Howells { 9420b77f5bfSDavid Howells .procname = "keys", 9430b77f5bfSDavid Howells .mode = 0555, 9440b77f5bfSDavid Howells .child = key_sysctls, 9450b77f5bfSDavid Howells }, 9460b77f5bfSDavid Howells #endif 94731a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 94831a72bceSPaul E. McKenney { 94931a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 95031a72bceSPaul E. McKenney .data = &rcutorture_runnable, 95131a72bceSPaul E. McKenney .maxlen = sizeof(int), 95231a72bceSPaul E. McKenney .mode = 0644, 9536d456111SEric W. Biederman .proc_handler = proc_dointvec, 95431a72bceSPaul E. McKenney }, 95531a72bceSPaul E. McKenney #endif 956cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 957aa4a2218SVince Weaver /* 958aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 959aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 960aa4a2218SVince Weaver * 961aa4a2218SVince Weaver * So it's an ABI, do not remove! 962aa4a2218SVince Weaver */ 9631ccd1549SPeter Zijlstra { 964cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 965cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 966cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9671ccd1549SPeter Zijlstra .mode = 0644, 9686d456111SEric W. Biederman .proc_handler = proc_dointvec, 9691ccd1549SPeter Zijlstra }, 970c5078f78SPeter Zijlstra { 971cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 972cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 973cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 974c5078f78SPeter Zijlstra .mode = 0644, 9756d456111SEric W. Biederman .proc_handler = proc_dointvec, 976c5078f78SPeter Zijlstra }, 977a78ac325SPeter Zijlstra { 978cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 979cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 980cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 981a78ac325SPeter Zijlstra .mode = 0644, 982163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 983a78ac325SPeter Zijlstra }, 9841ccd1549SPeter Zijlstra #endif 985dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 986dfec072eSVegard Nossum { 987dfec072eSVegard Nossum .procname = "kmemcheck", 988dfec072eSVegard Nossum .data = &kmemcheck_enabled, 989dfec072eSVegard Nossum .maxlen = sizeof(int), 990dfec072eSVegard Nossum .mode = 0644, 9916d456111SEric W. Biederman .proc_handler = proc_dointvec, 992dfec072eSVegard Nossum }, 993dfec072eSVegard Nossum #endif 994cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9955e605b64SJens Axboe { 9965e605b64SJens Axboe .procname = "blk_iopoll", 9975e605b64SJens Axboe .data = &blk_iopoll_enabled, 9985e605b64SJens Axboe .maxlen = sizeof(int), 9995e605b64SJens Axboe .mode = 0644, 10006d456111SEric W. Biederman .proc_handler = proc_dointvec, 10015e605b64SJens Axboe }, 1002cb684b5bSJens Axboe #endif 10036fce56ecSEric W. Biederman { } 10041da177e4SLinus Torvalds }; 10051da177e4SLinus Torvalds 1006d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 10071da177e4SLinus Torvalds { 10081da177e4SLinus Torvalds .procname = "overcommit_memory", 10091da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 10101da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 10111da177e4SLinus Torvalds .mode = 0644, 1012cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1013cb16e95fSPetr Holasek .extra1 = &zero, 1014cb16e95fSPetr Holasek .extra2 = &two, 10151da177e4SLinus Torvalds }, 10161da177e4SLinus Torvalds { 1017fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1018fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1019fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1020fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1021cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1022cb16e95fSPetr Holasek .extra1 = &zero, 1023cb16e95fSPetr Holasek .extra2 = &two, 1024fadd8fbdSKAMEZAWA Hiroyuki }, 1025fadd8fbdSKAMEZAWA Hiroyuki { 1026fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1027fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1028fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1029fe071d7eSDavid Rientjes .mode = 0644, 10306d456111SEric W. Biederman .proc_handler = proc_dointvec, 1031fe071d7eSDavid Rientjes }, 1032fe071d7eSDavid Rientjes { 1033fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1034fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1035fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1036fef1bdd6SDavid Rientjes .mode = 0644, 10376d456111SEric W. Biederman .proc_handler = proc_dointvec, 1038fef1bdd6SDavid Rientjes }, 1039fef1bdd6SDavid Rientjes { 10401da177e4SLinus Torvalds .procname = "overcommit_ratio", 10411da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10421da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10431da177e4SLinus Torvalds .mode = 0644, 10446d456111SEric W. Biederman .proc_handler = proc_dointvec, 10451da177e4SLinus Torvalds }, 10461da177e4SLinus Torvalds { 10471da177e4SLinus Torvalds .procname = "page-cluster", 10481da177e4SLinus Torvalds .data = &page_cluster, 10491da177e4SLinus Torvalds .maxlen = sizeof(int), 10501da177e4SLinus Torvalds .mode = 0644, 1051cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1052cb16e95fSPetr Holasek .extra1 = &zero, 10531da177e4SLinus Torvalds }, 10541da177e4SLinus Torvalds { 10551da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10561da177e4SLinus Torvalds .data = &dirty_background_ratio, 10571da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10581da177e4SLinus Torvalds .mode = 0644, 10596d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 10601da177e4SLinus Torvalds .extra1 = &zero, 10611da177e4SLinus Torvalds .extra2 = &one_hundred, 10621da177e4SLinus Torvalds }, 10631da177e4SLinus Torvalds { 10642da02997SDavid Rientjes .procname = "dirty_background_bytes", 10652da02997SDavid Rientjes .data = &dirty_background_bytes, 10662da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10672da02997SDavid Rientjes .mode = 0644, 10686d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1069fc3501d4SSven Wegener .extra1 = &one_ul, 10702da02997SDavid Rientjes }, 10712da02997SDavid Rientjes { 10721da177e4SLinus Torvalds .procname = "dirty_ratio", 10731da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10741da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10751da177e4SLinus Torvalds .mode = 0644, 10766d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10771da177e4SLinus Torvalds .extra1 = &zero, 10781da177e4SLinus Torvalds .extra2 = &one_hundred, 10791da177e4SLinus Torvalds }, 10801da177e4SLinus Torvalds { 10812da02997SDavid Rientjes .procname = "dirty_bytes", 10822da02997SDavid Rientjes .data = &vm_dirty_bytes, 10832da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10842da02997SDavid Rientjes .mode = 0644, 10856d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10869e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10872da02997SDavid Rientjes }, 10882da02997SDavid Rientjes { 10891da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1090f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1091f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10921da177e4SLinus Torvalds .mode = 0644, 10936d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10941da177e4SLinus Torvalds }, 10951da177e4SLinus Torvalds { 10961da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1097f6ef9438SBart Samwel .data = &dirty_expire_interval, 1098f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10991da177e4SLinus Torvalds .mode = 0644, 1100cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1101cb16e95fSPetr Holasek .extra1 = &zero, 11021da177e4SLinus Torvalds }, 11031da177e4SLinus Torvalds { 11041da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 11051da177e4SLinus Torvalds .mode = 0444 /* read-only */, 11063965c9aeSWanpeng Li .proc_handler = pdflush_proc_obsolete, 11071da177e4SLinus Torvalds }, 11081da177e4SLinus Torvalds { 11091da177e4SLinus Torvalds .procname = "swappiness", 11101da177e4SLinus Torvalds .data = &vm_swappiness, 11111da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 11121da177e4SLinus Torvalds .mode = 0644, 11136d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 11141da177e4SLinus Torvalds .extra1 = &zero, 11151da177e4SLinus Torvalds .extra2 = &one_hundred, 11161da177e4SLinus Torvalds }, 11171da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11181da177e4SLinus Torvalds { 11191da177e4SLinus Torvalds .procname = "nr_hugepages", 1120e5ff2159SAndi Kleen .data = NULL, 11211da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11221da177e4SLinus Torvalds .mode = 0644, 11236d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 11241da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11251da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11261da177e4SLinus Torvalds }, 112706808b08SLee Schermerhorn #ifdef CONFIG_NUMA 112806808b08SLee Schermerhorn { 112906808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 113006808b08SLee Schermerhorn .data = NULL, 113106808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 113206808b08SLee Schermerhorn .mode = 0644, 113306808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 113406808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 113506808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 113606808b08SLee Schermerhorn }, 113706808b08SLee Schermerhorn #endif 11381da177e4SLinus Torvalds { 11391da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11401da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11411da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11421da177e4SLinus Torvalds .mode = 0644, 11436d456111SEric W. Biederman .proc_handler = proc_dointvec, 11441da177e4SLinus Torvalds }, 1145396faf03SMel Gorman { 1146396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1147396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1148396faf03SMel Gorman .maxlen = sizeof(int), 1149396faf03SMel Gorman .mode = 0644, 11506d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1151396faf03SMel Gorman }, 115254f9f80dSAdam Litke { 1153d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1154e5ff2159SAndi Kleen .data = NULL, 1155e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1156d1c3fb1fSNishanth Aravamudan .mode = 0644, 11576d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1158e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1159e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1160d1c3fb1fSNishanth Aravamudan }, 11611da177e4SLinus Torvalds #endif 11621da177e4SLinus Torvalds { 11631da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11641da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11651da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11661da177e4SLinus Torvalds .mode = 0644, 11676d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11681da177e4SLinus Torvalds }, 11691da177e4SLinus Torvalds { 11709d0243bcSAndrew Morton .procname = "drop_caches", 11719d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11729d0243bcSAndrew Morton .maxlen = sizeof(int), 11739d0243bcSAndrew Morton .mode = 0644, 11749d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 1175cb16e95fSPetr Holasek .extra1 = &one, 1176cb16e95fSPetr Holasek .extra2 = &three, 11779d0243bcSAndrew Morton }, 117876ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 117976ab0f53SMel Gorman { 118076ab0f53SMel Gorman .procname = "compact_memory", 118176ab0f53SMel Gorman .data = &sysctl_compact_memory, 118276ab0f53SMel Gorman .maxlen = sizeof(int), 118376ab0f53SMel Gorman .mode = 0200, 118476ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 118576ab0f53SMel Gorman }, 11865e771905SMel Gorman { 11875e771905SMel Gorman .procname = "extfrag_threshold", 11885e771905SMel Gorman .data = &sysctl_extfrag_threshold, 11895e771905SMel Gorman .maxlen = sizeof(int), 11905e771905SMel Gorman .mode = 0644, 11915e771905SMel Gorman .proc_handler = sysctl_extfrag_handler, 11925e771905SMel Gorman .extra1 = &min_extfrag_threshold, 11935e771905SMel Gorman .extra2 = &max_extfrag_threshold, 11945e771905SMel Gorman }, 11955e771905SMel Gorman 119676ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 11979d0243bcSAndrew Morton { 11981da177e4SLinus Torvalds .procname = "min_free_kbytes", 11991da177e4SLinus Torvalds .data = &min_free_kbytes, 12001da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 12011da177e4SLinus Torvalds .mode = 0644, 12026d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 12031da177e4SLinus Torvalds .extra1 = &zero, 12041da177e4SLinus Torvalds }, 12058ad4b1fbSRohit Seth { 12068ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 12078ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 12088ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 12098ad4b1fbSRohit Seth .mode = 0644, 12106d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 12118ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 12128ad4b1fbSRohit Seth }, 12131da177e4SLinus Torvalds #ifdef CONFIG_MMU 12141da177e4SLinus Torvalds { 12151da177e4SLinus Torvalds .procname = "max_map_count", 12161da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12171da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12181da177e4SLinus Torvalds .mode = 0644, 12193e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 122070da2340SAmerigo Wang .extra1 = &zero, 12211da177e4SLinus Torvalds }, 1222dd8632a1SPaul Mundt #else 1223dd8632a1SPaul Mundt { 1224dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1225dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1226dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1227dd8632a1SPaul Mundt .mode = 0644, 12286d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1229dd8632a1SPaul Mundt .extra1 = &zero, 1230dd8632a1SPaul Mundt }, 12311da177e4SLinus Torvalds #endif 12321da177e4SLinus Torvalds { 12331da177e4SLinus Torvalds .procname = "laptop_mode", 12341da177e4SLinus Torvalds .data = &laptop_mode, 12351da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12361da177e4SLinus Torvalds .mode = 0644, 12376d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 12381da177e4SLinus Torvalds }, 12391da177e4SLinus Torvalds { 12401da177e4SLinus Torvalds .procname = "block_dump", 12411da177e4SLinus Torvalds .data = &block_dump, 12421da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12431da177e4SLinus Torvalds .mode = 0644, 12446d456111SEric W. Biederman .proc_handler = proc_dointvec, 12451da177e4SLinus Torvalds .extra1 = &zero, 12461da177e4SLinus Torvalds }, 12471da177e4SLinus Torvalds { 12481da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12491da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12501da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12511da177e4SLinus Torvalds .mode = 0644, 12526d456111SEric W. Biederman .proc_handler = proc_dointvec, 12531da177e4SLinus Torvalds .extra1 = &zero, 12541da177e4SLinus Torvalds }, 12551da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12561da177e4SLinus Torvalds { 12571da177e4SLinus Torvalds .procname = "legacy_va_layout", 12581da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12591da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12601da177e4SLinus Torvalds .mode = 0644, 12616d456111SEric W. Biederman .proc_handler = proc_dointvec, 12621da177e4SLinus Torvalds .extra1 = &zero, 12631da177e4SLinus Torvalds }, 12641da177e4SLinus Torvalds #endif 12651743660bSChristoph Lameter #ifdef CONFIG_NUMA 12661743660bSChristoph Lameter { 12671743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12681743660bSChristoph Lameter .data = &zone_reclaim_mode, 12691743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12701743660bSChristoph Lameter .mode = 0644, 12716d456111SEric W. Biederman .proc_handler = proc_dointvec, 1272c84db23cSChristoph Lameter .extra1 = &zero, 12731743660bSChristoph Lameter }, 12749614634fSChristoph Lameter { 12759614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12769614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12779614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12789614634fSChristoph Lameter .mode = 0644, 12796d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 12809614634fSChristoph Lameter .extra1 = &zero, 12819614634fSChristoph Lameter .extra2 = &one_hundred, 12829614634fSChristoph Lameter }, 12830ff38490SChristoph Lameter { 12840ff38490SChristoph Lameter .procname = "min_slab_ratio", 12850ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12860ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12870ff38490SChristoph Lameter .mode = 0644, 12886d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12890ff38490SChristoph Lameter .extra1 = &zero, 12900ff38490SChristoph Lameter .extra2 = &one_hundred, 12910ff38490SChristoph Lameter }, 12921743660bSChristoph Lameter #endif 129377461ab3SChristoph Lameter #ifdef CONFIG_SMP 129477461ab3SChristoph Lameter { 129577461ab3SChristoph Lameter .procname = "stat_interval", 129677461ab3SChristoph Lameter .data = &sysctl_stat_interval, 129777461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 129877461ab3SChristoph Lameter .mode = 0644, 12996d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 130077461ab3SChristoph Lameter }, 130177461ab3SChristoph Lameter #endif 13026e141546SDavid Howells #ifdef CONFIG_MMU 1303ed032189SEric Paris { 1304ed032189SEric Paris .procname = "mmap_min_addr", 1305788084abSEric Paris .data = &dac_mmap_min_addr, 1306ed032189SEric Paris .maxlen = sizeof(unsigned long), 1307ed032189SEric Paris .mode = 0644, 13086d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1309ed032189SEric Paris }, 13106e141546SDavid Howells #endif 1311f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1312f0c0b2b8SKAMEZAWA Hiroyuki { 1313f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1314f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1315f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1316f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 13176d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1318f0c0b2b8SKAMEZAWA Hiroyuki }, 1319f0c0b2b8SKAMEZAWA Hiroyuki #endif 13202b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13215c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1322e6e5494cSIngo Molnar { 1323e6e5494cSIngo Molnar .procname = "vdso_enabled", 1324e6e5494cSIngo Molnar .data = &vdso_enabled, 1325e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1326e6e5494cSIngo Molnar .mode = 0644, 13276d456111SEric W. Biederman .proc_handler = proc_dointvec, 1328e6e5494cSIngo Molnar .extra1 = &zero, 1329e6e5494cSIngo Molnar }, 1330e6e5494cSIngo Molnar #endif 1331195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1332195cf453SBron Gondwana { 1333195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1334195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1335195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1336195cf453SBron Gondwana .mode = 0644, 13376d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1338195cf453SBron Gondwana .extra1 = &zero, 1339195cf453SBron Gondwana .extra2 = &one, 1340195cf453SBron Gondwana }, 1341195cf453SBron Gondwana #endif 13424be6f6bbSPeter Zijlstra { 13434be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13444be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13454be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13464be6f6bbSPeter Zijlstra .mode = 0644, 13476d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 13484be6f6bbSPeter Zijlstra }, 13496a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 13506a46079cSAndi Kleen { 13516a46079cSAndi Kleen .procname = "memory_failure_early_kill", 13526a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 13536a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 13546a46079cSAndi Kleen .mode = 0644, 13556d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13566a46079cSAndi Kleen .extra1 = &zero, 13576a46079cSAndi Kleen .extra2 = &one, 13586a46079cSAndi Kleen }, 13596a46079cSAndi Kleen { 13606a46079cSAndi Kleen .procname = "memory_failure_recovery", 13616a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 13626a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 13636a46079cSAndi Kleen .mode = 0644, 13646d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13656a46079cSAndi Kleen .extra1 = &zero, 13666a46079cSAndi Kleen .extra2 = &one, 13676a46079cSAndi Kleen }, 13686a46079cSAndi Kleen #endif 13696fce56ecSEric W. Biederman { } 13701da177e4SLinus Torvalds }; 13711da177e4SLinus Torvalds 13722abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1373d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13746fce56ecSEric W. Biederman { } 13752abc26fcSEric W. Biederman }; 13762abc26fcSEric W. Biederman #endif 13772abc26fcSEric W. Biederman 1378d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13791da177e4SLinus Torvalds { 13801da177e4SLinus Torvalds .procname = "inode-nr", 13811da177e4SLinus Torvalds .data = &inodes_stat, 13821da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13831da177e4SLinus Torvalds .mode = 0444, 1384cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13851da177e4SLinus Torvalds }, 13861da177e4SLinus Torvalds { 13871da177e4SLinus Torvalds .procname = "inode-state", 13881da177e4SLinus Torvalds .data = &inodes_stat, 13891da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13901da177e4SLinus Torvalds .mode = 0444, 1391cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13921da177e4SLinus Torvalds }, 13931da177e4SLinus Torvalds { 13941da177e4SLinus Torvalds .procname = "file-nr", 13951da177e4SLinus Torvalds .data = &files_stat, 1396518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 13971da177e4SLinus Torvalds .mode = 0444, 13986d456111SEric W. Biederman .proc_handler = proc_nr_files, 13991da177e4SLinus Torvalds }, 14001da177e4SLinus Torvalds { 14011da177e4SLinus Torvalds .procname = "file-max", 14021da177e4SLinus Torvalds .data = &files_stat.max_files, 1403518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 14041da177e4SLinus Torvalds .mode = 0644, 1405518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 14061da177e4SLinus Torvalds }, 14071da177e4SLinus Torvalds { 14089cfe015aSEric Dumazet .procname = "nr_open", 14099cfe015aSEric Dumazet .data = &sysctl_nr_open, 14109cfe015aSEric Dumazet .maxlen = sizeof(int), 14119cfe015aSEric Dumazet .mode = 0644, 14126d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1413eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1414eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14159cfe015aSEric Dumazet }, 14169cfe015aSEric Dumazet { 14171da177e4SLinus Torvalds .procname = "dentry-state", 14181da177e4SLinus Torvalds .data = &dentry_stat, 14191da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14201da177e4SLinus Torvalds .mode = 0444, 1421312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 14221da177e4SLinus Torvalds }, 14231da177e4SLinus Torvalds { 14241da177e4SLinus Torvalds .procname = "overflowuid", 14251da177e4SLinus Torvalds .data = &fs_overflowuid, 14261da177e4SLinus Torvalds .maxlen = sizeof(int), 14271da177e4SLinus Torvalds .mode = 0644, 14286d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14291da177e4SLinus Torvalds .extra1 = &minolduid, 14301da177e4SLinus Torvalds .extra2 = &maxolduid, 14311da177e4SLinus Torvalds }, 14321da177e4SLinus Torvalds { 14331da177e4SLinus Torvalds .procname = "overflowgid", 14341da177e4SLinus Torvalds .data = &fs_overflowgid, 14351da177e4SLinus Torvalds .maxlen = sizeof(int), 14361da177e4SLinus Torvalds .mode = 0644, 14376d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14381da177e4SLinus Torvalds .extra1 = &minolduid, 14391da177e4SLinus Torvalds .extra2 = &maxolduid, 14401da177e4SLinus Torvalds }, 1441bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14421da177e4SLinus Torvalds { 14431da177e4SLinus Torvalds .procname = "leases-enable", 14441da177e4SLinus Torvalds .data = &leases_enable, 14451da177e4SLinus Torvalds .maxlen = sizeof(int), 14461da177e4SLinus Torvalds .mode = 0644, 14476d456111SEric W. Biederman .proc_handler = proc_dointvec, 14481da177e4SLinus Torvalds }, 1449bfcd17a6SThomas Petazzoni #endif 14501da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14511da177e4SLinus Torvalds { 14521da177e4SLinus Torvalds .procname = "dir-notify-enable", 14531da177e4SLinus Torvalds .data = &dir_notify_enable, 14541da177e4SLinus Torvalds .maxlen = sizeof(int), 14551da177e4SLinus Torvalds .mode = 0644, 14566d456111SEric W. Biederman .proc_handler = proc_dointvec, 14571da177e4SLinus Torvalds }, 14581da177e4SLinus Torvalds #endif 14591da177e4SLinus Torvalds #ifdef CONFIG_MMU 1460bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14611da177e4SLinus Torvalds { 14621da177e4SLinus Torvalds .procname = "lease-break-time", 14631da177e4SLinus Torvalds .data = &lease_break_time, 14641da177e4SLinus Torvalds .maxlen = sizeof(int), 14651da177e4SLinus Torvalds .mode = 0644, 14666d456111SEric W. Biederman .proc_handler = proc_dointvec, 14671da177e4SLinus Torvalds }, 1468bfcd17a6SThomas Petazzoni #endif 1469ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14701da177e4SLinus Torvalds { 14711da177e4SLinus Torvalds .procname = "aio-nr", 14721da177e4SLinus Torvalds .data = &aio_nr, 14731da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14741da177e4SLinus Torvalds .mode = 0444, 14756d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14761da177e4SLinus Torvalds }, 14771da177e4SLinus Torvalds { 14781da177e4SLinus Torvalds .procname = "aio-max-nr", 14791da177e4SLinus Torvalds .data = &aio_max_nr, 14801da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14811da177e4SLinus Torvalds .mode = 0644, 14826d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14831da177e4SLinus Torvalds }, 1484ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14852d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14860399cb08SRobert Love { 14870399cb08SRobert Love .procname = "inotify", 14880399cb08SRobert Love .mode = 0555, 14890399cb08SRobert Love .child = inotify_table, 14900399cb08SRobert Love }, 14910399cb08SRobert Love #endif 14927ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14937ef9964eSDavide Libenzi { 14947ef9964eSDavide Libenzi .procname = "epoll", 14957ef9964eSDavide Libenzi .mode = 0555, 14967ef9964eSDavide Libenzi .child = epoll_table, 14977ef9964eSDavide Libenzi }, 14987ef9964eSDavide Libenzi #endif 14991da177e4SLinus Torvalds #endif 1500d6e71144SAlan Cox { 1501800179c9SKees Cook .procname = "protected_symlinks", 1502800179c9SKees Cook .data = &sysctl_protected_symlinks, 1503800179c9SKees Cook .maxlen = sizeof(int), 1504800179c9SKees Cook .mode = 0600, 1505800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 1506800179c9SKees Cook .extra1 = &zero, 1507800179c9SKees Cook .extra2 = &one, 1508800179c9SKees Cook }, 1509800179c9SKees Cook { 1510800179c9SKees Cook .procname = "protected_hardlinks", 1511800179c9SKees Cook .data = &sysctl_protected_hardlinks, 1512800179c9SKees Cook .maxlen = sizeof(int), 1513800179c9SKees Cook .mode = 0600, 1514800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 1515800179c9SKees Cook .extra1 = &zero, 1516800179c9SKees Cook .extra2 = &one, 1517800179c9SKees Cook }, 1518800179c9SKees Cook { 1519d6e71144SAlan Cox .procname = "suid_dumpable", 1520d6e71144SAlan Cox .data = &suid_dumpable, 1521d6e71144SAlan Cox .maxlen = sizeof(int), 1522d6e71144SAlan Cox .mode = 0644, 152354b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 15248e654fbaSMatthew Wilcox .extra1 = &zero, 15258e654fbaSMatthew Wilcox .extra2 = &two, 1526d6e71144SAlan Cox }, 15272abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 15282abc26fcSEric W. Biederman { 15292abc26fcSEric W. Biederman .procname = "binfmt_misc", 15302abc26fcSEric W. Biederman .mode = 0555, 15312abc26fcSEric W. Biederman .child = binfmt_misc_table, 15322abc26fcSEric W. Biederman }, 15332abc26fcSEric W. Biederman #endif 1534b492e95bSJens Axboe { 1535ff9da691SJens Axboe .procname = "pipe-max-size", 1536ff9da691SJens Axboe .data = &pipe_max_size, 1537b492e95bSJens Axboe .maxlen = sizeof(int), 1538b492e95bSJens Axboe .mode = 0644, 1539ff9da691SJens Axboe .proc_handler = &pipe_proc_fn, 1540ff9da691SJens Axboe .extra1 = &pipe_min_size, 1541b492e95bSJens Axboe }, 15426fce56ecSEric W. Biederman { } 15431da177e4SLinus Torvalds }; 15441da177e4SLinus Torvalds 1545d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 1546ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \ 1547571d76acSChris Metcalf defined(CONFIG_S390) || defined(CONFIG_TILE) 1548abd4f750SMasoud Asgharifard Sharbiani { 1549abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1550abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1551abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1552abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1553abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1554abd4f750SMasoud Asgharifard Sharbiani }, 1555abd4f750SMasoud Asgharifard Sharbiani #endif 1556b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1557b2be84dfSMasami Hiramatsu { 1558b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1559b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1560b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1561b2be84dfSMasami Hiramatsu .mode = 0644, 1562b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1563b2be84dfSMasami Hiramatsu .extra1 = &zero, 1564b2be84dfSMasami Hiramatsu .extra2 = &one, 1565b2be84dfSMasami Hiramatsu }, 1566b2be84dfSMasami Hiramatsu #endif 15676fce56ecSEric W. Biederman { } 15681da177e4SLinus Torvalds }; 15691da177e4SLinus Torvalds 1570d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15716fce56ecSEric W. Biederman { } 15721da177e4SLinus Torvalds }; 15731da177e4SLinus Torvalds 1574de4e83bdSEric W. Biederman int __init sysctl_init(void) 1575330d57fbSAl Viro { 1576fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 1577fd4b616bSSteven Rostedt 1578fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 1579fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 1580330d57fbSAl Viro return 0; 1581f7e6ced4SAl Viro } 1582f7e6ced4SAl Viro 1583b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1584b89a8171SEric W. Biederman 15851da177e4SLinus Torvalds /* 15861da177e4SLinus Torvalds * /proc/sys support 15871da177e4SLinus Torvalds */ 15881da177e4SLinus Torvalds 1589b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 15901da177e4SLinus Torvalds 1591b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 15928d65af78SAlexey Dobriyan void __user *buffer, 1593b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1594f5dd3d6fSSam Vilain { 1595f5dd3d6fSSam Vilain size_t len; 1596f5dd3d6fSSam Vilain char __user *p; 1597f5dd3d6fSSam Vilain char c; 1598f5dd3d6fSSam Vilain 15998d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1600f5dd3d6fSSam Vilain *lenp = 0; 1601f5dd3d6fSSam Vilain return 0; 1602f5dd3d6fSSam Vilain } 1603f5dd3d6fSSam Vilain 1604f5dd3d6fSSam Vilain if (write) { 1605f5dd3d6fSSam Vilain len = 0; 1606f5dd3d6fSSam Vilain p = buffer; 1607f5dd3d6fSSam Vilain while (len < *lenp) { 1608f5dd3d6fSSam Vilain if (get_user(c, p++)) 1609f5dd3d6fSSam Vilain return -EFAULT; 1610f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1611f5dd3d6fSSam Vilain break; 1612f5dd3d6fSSam Vilain len++; 1613f5dd3d6fSSam Vilain } 1614f5dd3d6fSSam Vilain if (len >= maxlen) 1615f5dd3d6fSSam Vilain len = maxlen-1; 1616f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1617f5dd3d6fSSam Vilain return -EFAULT; 1618f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 1619f5dd3d6fSSam Vilain *ppos += *lenp; 1620f5dd3d6fSSam Vilain } else { 1621f5dd3d6fSSam Vilain len = strlen(data); 1622f5dd3d6fSSam Vilain if (len > maxlen) 1623f5dd3d6fSSam Vilain len = maxlen; 16248d060877SOleg Nesterov 16258d060877SOleg Nesterov if (*ppos > len) { 16268d060877SOleg Nesterov *lenp = 0; 16278d060877SOleg Nesterov return 0; 16288d060877SOleg Nesterov } 16298d060877SOleg Nesterov 16308d060877SOleg Nesterov data += *ppos; 16318d060877SOleg Nesterov len -= *ppos; 16328d060877SOleg Nesterov 1633f5dd3d6fSSam Vilain if (len > *lenp) 1634f5dd3d6fSSam Vilain len = *lenp; 1635f5dd3d6fSSam Vilain if (len) 1636f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 1637f5dd3d6fSSam Vilain return -EFAULT; 1638f5dd3d6fSSam Vilain if (len < *lenp) { 1639f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 1640f5dd3d6fSSam Vilain return -EFAULT; 1641f5dd3d6fSSam Vilain len++; 1642f5dd3d6fSSam Vilain } 1643f5dd3d6fSSam Vilain *lenp = len; 1644f5dd3d6fSSam Vilain *ppos += len; 1645f5dd3d6fSSam Vilain } 1646f5dd3d6fSSam Vilain return 0; 1647f5dd3d6fSSam Vilain } 1648f5dd3d6fSSam Vilain 16491da177e4SLinus Torvalds /** 16501da177e4SLinus Torvalds * proc_dostring - read a string sysctl 16511da177e4SLinus Torvalds * @table: the sysctl table 16521da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 16531da177e4SLinus Torvalds * @buffer: the user buffer 16541da177e4SLinus Torvalds * @lenp: the size of the user buffer 16551da177e4SLinus Torvalds * @ppos: file position 16561da177e4SLinus Torvalds * 16571da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 16581da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 16591da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 16601da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 16611da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 16621da177e4SLinus Torvalds * not large enough. 16631da177e4SLinus Torvalds * 16641da177e4SLinus Torvalds * Returns 0 on success. 16651da177e4SLinus Torvalds */ 16668d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 16671da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 16681da177e4SLinus Torvalds { 16698d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 1670f5dd3d6fSSam Vilain buffer, lenp, ppos); 16711da177e4SLinus Torvalds } 16721da177e4SLinus Torvalds 167300b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 167400b7c339SAmerigo Wang { 167500b7c339SAmerigo Wang size_t ret; 167600b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 167700b7c339SAmerigo Wang ret = tmp - *buf; 167800b7c339SAmerigo Wang *buf = tmp; 167900b7c339SAmerigo Wang return ret; 168000b7c339SAmerigo Wang } 16811da177e4SLinus Torvalds 16829f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v) 16839f977fb7SOctavian Purdila { 16849f977fb7SOctavian Purdila while (*size) { 16859f977fb7SOctavian Purdila if (**buf != v) 16869f977fb7SOctavian Purdila break; 16879f977fb7SOctavian Purdila (*size)--; 16889f977fb7SOctavian Purdila (*buf)++; 16899f977fb7SOctavian Purdila } 16909f977fb7SOctavian Purdila } 16919f977fb7SOctavian Purdila 169200b7c339SAmerigo Wang #define TMPBUFLEN 22 169300b7c339SAmerigo Wang /** 16940fc377bdSRandy Dunlap * proc_get_long - reads an ASCII formatted integer from a user buffer 169500b7c339SAmerigo Wang * 16960fc377bdSRandy Dunlap * @buf: a kernel buffer 16970fc377bdSRandy Dunlap * @size: size of the kernel buffer 16980fc377bdSRandy Dunlap * @val: this is where the number will be stored 16990fc377bdSRandy Dunlap * @neg: set to %TRUE if number is negative 17000fc377bdSRandy Dunlap * @perm_tr: a vector which contains the allowed trailers 17010fc377bdSRandy Dunlap * @perm_tr_len: size of the perm_tr vector 17020fc377bdSRandy Dunlap * @tr: pointer to store the trailer character 170300b7c339SAmerigo Wang * 17040fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 17050fc377bdSRandy Dunlap * the amount of bytes read. If @tr is non-NULL and a trailing 17060fc377bdSRandy Dunlap * character exists (size is non-zero after returning from this 17070fc377bdSRandy Dunlap * function), @tr is updated with the trailing character. 170800b7c339SAmerigo Wang */ 170900b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 171000b7c339SAmerigo Wang unsigned long *val, bool *neg, 171100b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 171200b7c339SAmerigo Wang { 171300b7c339SAmerigo Wang int len; 171400b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 171500b7c339SAmerigo Wang 171600b7c339SAmerigo Wang if (!*size) 171700b7c339SAmerigo Wang return -EINVAL; 171800b7c339SAmerigo Wang 171900b7c339SAmerigo Wang len = *size; 172000b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 172100b7c339SAmerigo Wang len = TMPBUFLEN - 1; 172200b7c339SAmerigo Wang 172300b7c339SAmerigo Wang memcpy(tmp, *buf, len); 172400b7c339SAmerigo Wang 172500b7c339SAmerigo Wang tmp[len] = 0; 172600b7c339SAmerigo Wang p = tmp; 172700b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 172800b7c339SAmerigo Wang *neg = true; 172900b7c339SAmerigo Wang p++; 173000b7c339SAmerigo Wang } else 173100b7c339SAmerigo Wang *neg = false; 173200b7c339SAmerigo Wang if (!isdigit(*p)) 173300b7c339SAmerigo Wang return -EINVAL; 173400b7c339SAmerigo Wang 173500b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 173600b7c339SAmerigo Wang 173700b7c339SAmerigo Wang len = p - tmp; 173800b7c339SAmerigo Wang 173900b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 174000b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 174100b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 174200b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 174300b7c339SAmerigo Wang return -EINVAL; 174400b7c339SAmerigo Wang 174500b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 174600b7c339SAmerigo Wang return -EINVAL; 174700b7c339SAmerigo Wang 174800b7c339SAmerigo Wang if (tr && (len < *size)) 174900b7c339SAmerigo Wang *tr = *p; 175000b7c339SAmerigo Wang 175100b7c339SAmerigo Wang *buf += len; 175200b7c339SAmerigo Wang *size -= len; 175300b7c339SAmerigo Wang 175400b7c339SAmerigo Wang return 0; 175500b7c339SAmerigo Wang } 175600b7c339SAmerigo Wang 175700b7c339SAmerigo Wang /** 17580fc377bdSRandy Dunlap * proc_put_long - converts an integer to a decimal ASCII formatted string 175900b7c339SAmerigo Wang * 17600fc377bdSRandy Dunlap * @buf: the user buffer 17610fc377bdSRandy Dunlap * @size: the size of the user buffer 17620fc377bdSRandy Dunlap * @val: the integer to be converted 17630fc377bdSRandy Dunlap * @neg: sign of the number, %TRUE for negative 176400b7c339SAmerigo Wang * 17650fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 17660fc377bdSRandy Dunlap * the amount of bytes written. 176700b7c339SAmerigo Wang */ 176800b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 176900b7c339SAmerigo Wang bool neg) 177000b7c339SAmerigo Wang { 177100b7c339SAmerigo Wang int len; 177200b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 177300b7c339SAmerigo Wang 177400b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 177500b7c339SAmerigo Wang len = strlen(tmp); 177600b7c339SAmerigo Wang if (len > *size) 177700b7c339SAmerigo Wang len = *size; 177800b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 177900b7c339SAmerigo Wang return -EFAULT; 178000b7c339SAmerigo Wang *size -= len; 178100b7c339SAmerigo Wang *buf += len; 178200b7c339SAmerigo Wang return 0; 178300b7c339SAmerigo Wang } 178400b7c339SAmerigo Wang #undef TMPBUFLEN 178500b7c339SAmerigo Wang 178600b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 178700b7c339SAmerigo Wang { 178800b7c339SAmerigo Wang if (*size) { 178900b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 179000b7c339SAmerigo Wang if (put_user(c, *buffer)) 179100b7c339SAmerigo Wang return -EFAULT; 179200b7c339SAmerigo Wang (*size)--, (*buffer)++; 179300b7c339SAmerigo Wang *buf = *buffer; 179400b7c339SAmerigo Wang } 179500b7c339SAmerigo Wang return 0; 179600b7c339SAmerigo Wang } 179700b7c339SAmerigo Wang 179800b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 17991da177e4SLinus Torvalds int *valp, 18001da177e4SLinus Torvalds int write, void *data) 18011da177e4SLinus Torvalds { 18021da177e4SLinus Torvalds if (write) { 18031da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 18041da177e4SLinus Torvalds } else { 18051da177e4SLinus Torvalds int val = *valp; 18061da177e4SLinus Torvalds if (val < 0) { 180700b7c339SAmerigo Wang *negp = true; 18081da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 18091da177e4SLinus Torvalds } else { 181000b7c339SAmerigo Wang *negp = false; 18111da177e4SLinus Torvalds *lvalp = (unsigned long)val; 18121da177e4SLinus Torvalds } 18131da177e4SLinus Torvalds } 18141da177e4SLinus Torvalds return 0; 18151da177e4SLinus Torvalds } 18161da177e4SLinus Torvalds 181700b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 181800b7c339SAmerigo Wang 1819d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 18208d65af78SAlexey Dobriyan int write, void __user *buffer, 1821fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 182200b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 18231da177e4SLinus Torvalds int write, void *data), 18241da177e4SLinus Torvalds void *data) 18251da177e4SLinus Torvalds { 182600b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 182700b7c339SAmerigo Wang unsigned long page = 0; 182800b7c339SAmerigo Wang size_t left; 182900b7c339SAmerigo Wang char *kbuf; 18301da177e4SLinus Torvalds 183100b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 18321da177e4SLinus Torvalds *lenp = 0; 18331da177e4SLinus Torvalds return 0; 18341da177e4SLinus Torvalds } 18351da177e4SLinus Torvalds 1836fcfbd547SKirill Korotaev i = (int *) tbl_data; 18371da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 18381da177e4SLinus Torvalds left = *lenp; 18391da177e4SLinus Torvalds 18401da177e4SLinus Torvalds if (!conv) 18411da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 18421da177e4SLinus Torvalds 184300b7c339SAmerigo Wang if (write) { 184400b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 184500b7c339SAmerigo Wang left = PAGE_SIZE - 1; 184600b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 184700b7c339SAmerigo Wang kbuf = (char *) page; 184800b7c339SAmerigo Wang if (!kbuf) 184900b7c339SAmerigo Wang return -ENOMEM; 185000b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 185100b7c339SAmerigo Wang err = -EFAULT; 185200b7c339SAmerigo Wang goto free; 185300b7c339SAmerigo Wang } 185400b7c339SAmerigo Wang kbuf[left] = 0; 185500b7c339SAmerigo Wang } 185600b7c339SAmerigo Wang 18571da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 185800b7c339SAmerigo Wang unsigned long lval; 185900b7c339SAmerigo Wang bool neg; 186000b7c339SAmerigo Wang 18611da177e4SLinus Torvalds if (write) { 186200b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 186300b7c339SAmerigo Wang 1864563b0467SJ. R. Okajima if (!left) 1865563b0467SJ. R. Okajima break; 186600b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 186700b7c339SAmerigo Wang proc_wspace_sep, 186800b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 186900b7c339SAmerigo Wang if (err) 18701da177e4SLinus Torvalds break; 187100b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 187200b7c339SAmerigo Wang err = -EINVAL; 187300b7c339SAmerigo Wang break; 18741da177e4SLinus Torvalds } 18751da177e4SLinus Torvalds } else { 187600b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 187700b7c339SAmerigo Wang err = -EINVAL; 187800b7c339SAmerigo Wang break; 187900b7c339SAmerigo Wang } 18801da177e4SLinus Torvalds if (!first) 188100b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 188200b7c339SAmerigo Wang if (err) 18831da177e4SLinus Torvalds break; 188400b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 188500b7c339SAmerigo Wang if (err) 188600b7c339SAmerigo Wang break; 18871da177e4SLinus Torvalds } 18881da177e4SLinus Torvalds } 18891da177e4SLinus Torvalds 189000b7c339SAmerigo Wang if (!write && !first && left && !err) 189100b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 1892563b0467SJ. R. Okajima if (write && !err && left) 189300b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 189400b7c339SAmerigo Wang free: 18951da177e4SLinus Torvalds if (write) { 189600b7c339SAmerigo Wang free_page(page); 189700b7c339SAmerigo Wang if (first) 189800b7c339SAmerigo Wang return err ? : -EINVAL; 18991da177e4SLinus Torvalds } 19001da177e4SLinus Torvalds *lenp -= left; 19011da177e4SLinus Torvalds *ppos += *lenp; 190200b7c339SAmerigo Wang return err; 19031da177e4SLinus Torvalds } 19041da177e4SLinus Torvalds 19058d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 1906fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 190700b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 1908fcfbd547SKirill Korotaev int write, void *data), 1909fcfbd547SKirill Korotaev void *data) 1910fcfbd547SKirill Korotaev { 19118d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 1912fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 1913fcfbd547SKirill Korotaev } 1914fcfbd547SKirill Korotaev 19151da177e4SLinus Torvalds /** 19161da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 19171da177e4SLinus Torvalds * @table: the sysctl table 19181da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 19191da177e4SLinus Torvalds * @buffer: the user buffer 19201da177e4SLinus Torvalds * @lenp: the size of the user buffer 19211da177e4SLinus Torvalds * @ppos: file position 19221da177e4SLinus Torvalds * 19231da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 19241da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 19251da177e4SLinus Torvalds * 19261da177e4SLinus Torvalds * Returns 0 on success. 19271da177e4SLinus Torvalds */ 19288d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 19291da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 19301da177e4SLinus Torvalds { 19318d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 19321da177e4SLinus Torvalds NULL,NULL); 19331da177e4SLinus Torvalds } 19341da177e4SLinus Torvalds 193534f5a398STheodore Ts'o /* 193634f5a398STheodore Ts'o * Taint values can only be increased 193725ddbb18SAndi Kleen * This means we can safely use a temporary. 193834f5a398STheodore Ts'o */ 19398d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 194034f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 194134f5a398STheodore Ts'o { 194225ddbb18SAndi Kleen struct ctl_table t; 194325ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 194425ddbb18SAndi Kleen int err; 194534f5a398STheodore Ts'o 194691fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 194734f5a398STheodore Ts'o return -EPERM; 194834f5a398STheodore Ts'o 194925ddbb18SAndi Kleen t = *table; 195025ddbb18SAndi Kleen t.data = &tmptaint; 19518d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 195225ddbb18SAndi Kleen if (err < 0) 195325ddbb18SAndi Kleen return err; 195425ddbb18SAndi Kleen 195525ddbb18SAndi Kleen if (write) { 195625ddbb18SAndi Kleen /* 195725ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 195825ddbb18SAndi Kleen * to everyone's atomic.h for this 195925ddbb18SAndi Kleen */ 196025ddbb18SAndi Kleen int i; 196125ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 196225ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 196325ddbb18SAndi Kleen add_taint(i); 196425ddbb18SAndi Kleen } 196525ddbb18SAndi Kleen } 196625ddbb18SAndi Kleen 196725ddbb18SAndi Kleen return err; 196834f5a398STheodore Ts'o } 196934f5a398STheodore Ts'o 1970bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 1971620f6e8eSKees Cook static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 1972bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos) 1973bfdc0b49SRichard Weinberger { 1974bfdc0b49SRichard Weinberger if (write && !capable(CAP_SYS_ADMIN)) 1975bfdc0b49SRichard Weinberger return -EPERM; 1976bfdc0b49SRichard Weinberger 1977bfdc0b49SRichard Weinberger return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1978bfdc0b49SRichard Weinberger } 1979bfdc0b49SRichard Weinberger #endif 1980bfdc0b49SRichard Weinberger 19811da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 19821da177e4SLinus Torvalds int *min; 19831da177e4SLinus Torvalds int *max; 19841da177e4SLinus Torvalds }; 19851da177e4SLinus Torvalds 198600b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 19871da177e4SLinus Torvalds int *valp, 19881da177e4SLinus Torvalds int write, void *data) 19891da177e4SLinus Torvalds { 19901da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 19911da177e4SLinus Torvalds if (write) { 19921da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 19931da177e4SLinus Torvalds if ((param->min && *param->min > val) || 19941da177e4SLinus Torvalds (param->max && *param->max < val)) 19951da177e4SLinus Torvalds return -EINVAL; 19961da177e4SLinus Torvalds *valp = val; 19971da177e4SLinus Torvalds } else { 19981da177e4SLinus Torvalds int val = *valp; 19991da177e4SLinus Torvalds if (val < 0) { 200000b7c339SAmerigo Wang *negp = true; 20011da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 20021da177e4SLinus Torvalds } else { 200300b7c339SAmerigo Wang *negp = false; 20041da177e4SLinus Torvalds *lvalp = (unsigned long)val; 20051da177e4SLinus Torvalds } 20061da177e4SLinus Torvalds } 20071da177e4SLinus Torvalds return 0; 20081da177e4SLinus Torvalds } 20091da177e4SLinus Torvalds 20101da177e4SLinus Torvalds /** 20111da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 20121da177e4SLinus Torvalds * @table: the sysctl table 20131da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20141da177e4SLinus Torvalds * @buffer: the user buffer 20151da177e4SLinus Torvalds * @lenp: the size of the user buffer 20161da177e4SLinus Torvalds * @ppos: file position 20171da177e4SLinus Torvalds * 20181da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 20191da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 20201da177e4SLinus Torvalds * 20211da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 20221da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 20231da177e4SLinus Torvalds * 20241da177e4SLinus Torvalds * Returns 0 on success. 20251da177e4SLinus Torvalds */ 20268d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 20271da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20281da177e4SLinus Torvalds { 20291da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 20301da177e4SLinus Torvalds .min = (int *) table->extra1, 20311da177e4SLinus Torvalds .max = (int *) table->extra2, 20321da177e4SLinus Torvalds }; 20338d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 20341da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 20351da177e4SLinus Torvalds } 20361da177e4SLinus Torvalds 203754b50199SKees Cook static void validate_coredump_safety(void) 203854b50199SKees Cook { 203954b50199SKees Cook if (suid_dumpable == SUID_DUMPABLE_SAFE && 204054b50199SKees Cook core_pattern[0] != '/' && core_pattern[0] != '|') { 204154b50199SKees Cook printk(KERN_WARNING "Unsafe core_pattern used with "\ 204254b50199SKees Cook "suid_dumpable=2. Pipe handler or fully qualified "\ 204354b50199SKees Cook "core dump path required.\n"); 204454b50199SKees Cook } 204554b50199SKees Cook } 204654b50199SKees Cook 204754b50199SKees Cook static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 204854b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos) 204954b50199SKees Cook { 205054b50199SKees Cook int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 205154b50199SKees Cook if (!error) 205254b50199SKees Cook validate_coredump_safety(); 205354b50199SKees Cook return error; 205454b50199SKees Cook } 205554b50199SKees Cook 205654b50199SKees Cook static int proc_dostring_coredump(struct ctl_table *table, int write, 205754b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos) 205854b50199SKees Cook { 205954b50199SKees Cook int error = proc_dostring(table, write, buffer, lenp, ppos); 206054b50199SKees Cook if (!error) 206154b50199SKees Cook validate_coredump_safety(); 206254b50199SKees Cook return error; 206354b50199SKees Cook } 206454b50199SKees Cook 2065d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 20661da177e4SLinus Torvalds void __user *buffer, 20671da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 20681da177e4SLinus Torvalds unsigned long convmul, 20691da177e4SLinus Torvalds unsigned long convdiv) 20701da177e4SLinus Torvalds { 207100b7c339SAmerigo Wang unsigned long *i, *min, *max; 207200b7c339SAmerigo Wang int vleft, first = 1, err = 0; 207300b7c339SAmerigo Wang unsigned long page = 0; 207400b7c339SAmerigo Wang size_t left; 207500b7c339SAmerigo Wang char *kbuf; 20761da177e4SLinus Torvalds 207700b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 20781da177e4SLinus Torvalds *lenp = 0; 20791da177e4SLinus Torvalds return 0; 20801da177e4SLinus Torvalds } 20811da177e4SLinus Torvalds 2082fcfbd547SKirill Korotaev i = (unsigned long *) data; 20831da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 20841da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 20851da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 20861da177e4SLinus Torvalds left = *lenp; 20871da177e4SLinus Torvalds 20881da177e4SLinus Torvalds if (write) { 208900b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 209000b7c339SAmerigo Wang left = PAGE_SIZE - 1; 209100b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 209200b7c339SAmerigo Wang kbuf = (char *) page; 209300b7c339SAmerigo Wang if (!kbuf) 209400b7c339SAmerigo Wang return -ENOMEM; 209500b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 209600b7c339SAmerigo Wang err = -EFAULT; 209700b7c339SAmerigo Wang goto free; 20981da177e4SLinus Torvalds } 209900b7c339SAmerigo Wang kbuf[left] = 0; 21001da177e4SLinus Torvalds } 21011da177e4SLinus Torvalds 210227b3d80aSEric Dumazet for (; left && vleft--; i++, first = 0) { 210300b7c339SAmerigo Wang unsigned long val; 210400b7c339SAmerigo Wang 210500b7c339SAmerigo Wang if (write) { 210600b7c339SAmerigo Wang bool neg; 210700b7c339SAmerigo Wang 210800b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 210900b7c339SAmerigo Wang 211000b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 211100b7c339SAmerigo Wang proc_wspace_sep, 211200b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 211300b7c339SAmerigo Wang if (err) 211400b7c339SAmerigo Wang break; 21151da177e4SLinus Torvalds if (neg) 21161da177e4SLinus Torvalds continue; 21171da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 21181da177e4SLinus Torvalds continue; 21191da177e4SLinus Torvalds *i = val; 21201da177e4SLinus Torvalds } else { 212100b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 21221da177e4SLinus Torvalds if (!first) 212300b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 212400b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 212500b7c339SAmerigo Wang if (err) 212600b7c339SAmerigo Wang break; 21271da177e4SLinus Torvalds } 21281da177e4SLinus Torvalds } 21291da177e4SLinus Torvalds 213000b7c339SAmerigo Wang if (!write && !first && left && !err) 213100b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 213200b7c339SAmerigo Wang if (write && !err) 213300b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 213400b7c339SAmerigo Wang free: 21351da177e4SLinus Torvalds if (write) { 213600b7c339SAmerigo Wang free_page(page); 213700b7c339SAmerigo Wang if (first) 213800b7c339SAmerigo Wang return err ? : -EINVAL; 21391da177e4SLinus Torvalds } 21401da177e4SLinus Torvalds *lenp -= left; 21411da177e4SLinus Torvalds *ppos += *lenp; 214200b7c339SAmerigo Wang return err; 21431da177e4SLinus Torvalds } 21441da177e4SLinus Torvalds 2145d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2146fcfbd547SKirill Korotaev void __user *buffer, 2147fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2148fcfbd547SKirill Korotaev unsigned long convmul, 2149fcfbd547SKirill Korotaev unsigned long convdiv) 2150fcfbd547SKirill Korotaev { 2151fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 21528d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2153fcfbd547SKirill Korotaev } 2154fcfbd547SKirill Korotaev 21551da177e4SLinus Torvalds /** 21561da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 21571da177e4SLinus Torvalds * @table: the sysctl table 21581da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21591da177e4SLinus Torvalds * @buffer: the user buffer 21601da177e4SLinus Torvalds * @lenp: the size of the user buffer 21611da177e4SLinus Torvalds * @ppos: file position 21621da177e4SLinus Torvalds * 21631da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 21641da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 21651da177e4SLinus Torvalds * 21661da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 21671da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 21681da177e4SLinus Torvalds * 21691da177e4SLinus Torvalds * Returns 0 on success. 21701da177e4SLinus Torvalds */ 21718d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 21721da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21731da177e4SLinus Torvalds { 21748d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 21751da177e4SLinus Torvalds } 21761da177e4SLinus Torvalds 21771da177e4SLinus Torvalds /** 21781da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 21791da177e4SLinus Torvalds * @table: the sysctl table 21801da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21811da177e4SLinus Torvalds * @buffer: the user buffer 21821da177e4SLinus Torvalds * @lenp: the size of the user buffer 21831da177e4SLinus Torvalds * @ppos: file position 21841da177e4SLinus Torvalds * 21851da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 21861da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 21871da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 21881da177e4SLinus Torvalds * 21891da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 21901da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 21911da177e4SLinus Torvalds * 21921da177e4SLinus Torvalds * Returns 0 on success. 21931da177e4SLinus Torvalds */ 2194d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 21951da177e4SLinus Torvalds void __user *buffer, 21961da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 21971da177e4SLinus Torvalds { 21988d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 21991da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 22001da177e4SLinus Torvalds } 22011da177e4SLinus Torvalds 22021da177e4SLinus Torvalds 220300b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 22041da177e4SLinus Torvalds int *valp, 22051da177e4SLinus Torvalds int write, void *data) 22061da177e4SLinus Torvalds { 22071da177e4SLinus Torvalds if (write) { 2208cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2209cba9f33dSBart Samwel return 1; 22101da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 22111da177e4SLinus Torvalds } else { 22121da177e4SLinus Torvalds int val = *valp; 22131da177e4SLinus Torvalds unsigned long lval; 22141da177e4SLinus Torvalds if (val < 0) { 221500b7c339SAmerigo Wang *negp = true; 22161da177e4SLinus Torvalds lval = (unsigned long)-val; 22171da177e4SLinus Torvalds } else { 221800b7c339SAmerigo Wang *negp = false; 22191da177e4SLinus Torvalds lval = (unsigned long)val; 22201da177e4SLinus Torvalds } 22211da177e4SLinus Torvalds *lvalp = lval / HZ; 22221da177e4SLinus Torvalds } 22231da177e4SLinus Torvalds return 0; 22241da177e4SLinus Torvalds } 22251da177e4SLinus Torvalds 222600b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 22271da177e4SLinus Torvalds int *valp, 22281da177e4SLinus Torvalds int write, void *data) 22291da177e4SLinus Torvalds { 22301da177e4SLinus Torvalds if (write) { 2231cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2232cba9f33dSBart Samwel return 1; 22331da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 22341da177e4SLinus Torvalds } else { 22351da177e4SLinus Torvalds int val = *valp; 22361da177e4SLinus Torvalds unsigned long lval; 22371da177e4SLinus Torvalds if (val < 0) { 223800b7c339SAmerigo Wang *negp = true; 22391da177e4SLinus Torvalds lval = (unsigned long)-val; 22401da177e4SLinus Torvalds } else { 224100b7c339SAmerigo Wang *negp = false; 22421da177e4SLinus Torvalds lval = (unsigned long)val; 22431da177e4SLinus Torvalds } 22441da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 22451da177e4SLinus Torvalds } 22461da177e4SLinus Torvalds return 0; 22471da177e4SLinus Torvalds } 22481da177e4SLinus Torvalds 224900b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 22501da177e4SLinus Torvalds int *valp, 22511da177e4SLinus Torvalds int write, void *data) 22521da177e4SLinus Torvalds { 22531da177e4SLinus Torvalds if (write) { 22541da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 22551da177e4SLinus Torvalds } else { 22561da177e4SLinus Torvalds int val = *valp; 22571da177e4SLinus Torvalds unsigned long lval; 22581da177e4SLinus Torvalds if (val < 0) { 225900b7c339SAmerigo Wang *negp = true; 22601da177e4SLinus Torvalds lval = (unsigned long)-val; 22611da177e4SLinus Torvalds } else { 226200b7c339SAmerigo Wang *negp = false; 22631da177e4SLinus Torvalds lval = (unsigned long)val; 22641da177e4SLinus Torvalds } 22651da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 22661da177e4SLinus Torvalds } 22671da177e4SLinus Torvalds return 0; 22681da177e4SLinus Torvalds } 22691da177e4SLinus Torvalds 22701da177e4SLinus Torvalds /** 22711da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 22721da177e4SLinus Torvalds * @table: the sysctl table 22731da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22741da177e4SLinus Torvalds * @buffer: the user buffer 22751da177e4SLinus Torvalds * @lenp: the size of the user buffer 22761da177e4SLinus Torvalds * @ppos: file position 22771da177e4SLinus Torvalds * 22781da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22791da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22801da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 22811da177e4SLinus Torvalds * jiffies. 22821da177e4SLinus Torvalds * 22831da177e4SLinus Torvalds * Returns 0 on success. 22841da177e4SLinus Torvalds */ 22858d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 22861da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22871da177e4SLinus Torvalds { 22888d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 22891da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 22901da177e4SLinus Torvalds } 22911da177e4SLinus Torvalds 22921da177e4SLinus Torvalds /** 22931da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 22941da177e4SLinus Torvalds * @table: the sysctl table 22951da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22961da177e4SLinus Torvalds * @buffer: the user buffer 22971da177e4SLinus Torvalds * @lenp: the size of the user buffer 22981e5d5331SRandy Dunlap * @ppos: pointer to the file position 22991da177e4SLinus Torvalds * 23001da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23011da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23021da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 23031da177e4SLinus Torvalds * are converted into jiffies. 23041da177e4SLinus Torvalds * 23051da177e4SLinus Torvalds * Returns 0 on success. 23061da177e4SLinus Torvalds */ 23078d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 23081da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23091da177e4SLinus Torvalds { 23108d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 23111da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 23121da177e4SLinus Torvalds } 23131da177e4SLinus Torvalds 23141da177e4SLinus Torvalds /** 23151da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 23161da177e4SLinus Torvalds * @table: the sysctl table 23171da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23181da177e4SLinus Torvalds * @buffer: the user buffer 23191da177e4SLinus Torvalds * @lenp: the size of the user buffer 232067be2dd1SMartin Waitz * @ppos: file position 232167be2dd1SMartin Waitz * @ppos: the current position in the file 23221da177e4SLinus Torvalds * 23231da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23241da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23251da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 23261da177e4SLinus Torvalds * are converted into jiffies. 23271da177e4SLinus Torvalds * 23281da177e4SLinus Torvalds * Returns 0 on success. 23291da177e4SLinus Torvalds */ 23308d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 23311da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23321da177e4SLinus Torvalds { 23338d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 23341da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 23351da177e4SLinus Torvalds } 23361da177e4SLinus Torvalds 23378d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 23389ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 23399ec52099SCedric Le Goater { 23409ec52099SCedric Le Goater struct pid *new_pid; 23419ec52099SCedric Le Goater pid_t tmp; 23429ec52099SCedric Le Goater int r; 23439ec52099SCedric Le Goater 23446c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 23459ec52099SCedric Le Goater 23468d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 23479ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 23489ec52099SCedric Le Goater if (r || !write) 23499ec52099SCedric Le Goater return r; 23509ec52099SCedric Le Goater 23519ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 23529ec52099SCedric Le Goater if (!new_pid) 23539ec52099SCedric Le Goater return -ESRCH; 23549ec52099SCedric Le Goater 23559ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 23569ec52099SCedric Le Goater return 0; 23579ec52099SCedric Le Goater } 23589ec52099SCedric Le Goater 23599f977fb7SOctavian Purdila /** 23609f977fb7SOctavian Purdila * proc_do_large_bitmap - read/write from/to a large bitmap 23619f977fb7SOctavian Purdila * @table: the sysctl table 23629f977fb7SOctavian Purdila * @write: %TRUE if this is a write to the sysctl file 23639f977fb7SOctavian Purdila * @buffer: the user buffer 23649f977fb7SOctavian Purdila * @lenp: the size of the user buffer 23659f977fb7SOctavian Purdila * @ppos: file position 23669f977fb7SOctavian Purdila * 23679f977fb7SOctavian Purdila * The bitmap is stored at table->data and the bitmap length (in bits) 23689f977fb7SOctavian Purdila * in table->maxlen. 23699f977fb7SOctavian Purdila * 23709f977fb7SOctavian Purdila * We use a range comma separated format (e.g. 1,3-4,10-10) so that 23719f977fb7SOctavian Purdila * large bitmaps may be represented in a compact manner. Writing into 23729f977fb7SOctavian Purdila * the file will clear the bitmap then update it with the given input. 23739f977fb7SOctavian Purdila * 23749f977fb7SOctavian Purdila * Returns 0 on success. 23759f977fb7SOctavian Purdila */ 23769f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write, 23779f977fb7SOctavian Purdila void __user *buffer, size_t *lenp, loff_t *ppos) 23789f977fb7SOctavian Purdila { 23799f977fb7SOctavian Purdila int err = 0; 23809f977fb7SOctavian Purdila bool first = 1; 23819f977fb7SOctavian Purdila size_t left = *lenp; 23829f977fb7SOctavian Purdila unsigned long bitmap_len = table->maxlen; 23839f977fb7SOctavian Purdila unsigned long *bitmap = (unsigned long *) table->data; 23849f977fb7SOctavian Purdila unsigned long *tmp_bitmap = NULL; 23859f977fb7SOctavian Purdila char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 23869f977fb7SOctavian Purdila 23879f977fb7SOctavian Purdila if (!bitmap_len || !left || (*ppos && !write)) { 23889f977fb7SOctavian Purdila *lenp = 0; 23899f977fb7SOctavian Purdila return 0; 23909f977fb7SOctavian Purdila } 23919f977fb7SOctavian Purdila 23929f977fb7SOctavian Purdila if (write) { 23939f977fb7SOctavian Purdila unsigned long page = 0; 23949f977fb7SOctavian Purdila char *kbuf; 23959f977fb7SOctavian Purdila 23969f977fb7SOctavian Purdila if (left > PAGE_SIZE - 1) 23979f977fb7SOctavian Purdila left = PAGE_SIZE - 1; 23989f977fb7SOctavian Purdila 23999f977fb7SOctavian Purdila page = __get_free_page(GFP_TEMPORARY); 24009f977fb7SOctavian Purdila kbuf = (char *) page; 24019f977fb7SOctavian Purdila if (!kbuf) 24029f977fb7SOctavian Purdila return -ENOMEM; 24039f977fb7SOctavian Purdila if (copy_from_user(kbuf, buffer, left)) { 24049f977fb7SOctavian Purdila free_page(page); 24059f977fb7SOctavian Purdila return -EFAULT; 24069f977fb7SOctavian Purdila } 24079f977fb7SOctavian Purdila kbuf[left] = 0; 24089f977fb7SOctavian Purdila 24099f977fb7SOctavian Purdila tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), 24109f977fb7SOctavian Purdila GFP_KERNEL); 24119f977fb7SOctavian Purdila if (!tmp_bitmap) { 24129f977fb7SOctavian Purdila free_page(page); 24139f977fb7SOctavian Purdila return -ENOMEM; 24149f977fb7SOctavian Purdila } 24159f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 24169f977fb7SOctavian Purdila while (!err && left) { 24179f977fb7SOctavian Purdila unsigned long val_a, val_b; 24189f977fb7SOctavian Purdila bool neg; 24199f977fb7SOctavian Purdila 24209f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, 24219f977fb7SOctavian Purdila sizeof(tr_a), &c); 24229f977fb7SOctavian Purdila if (err) 24239f977fb7SOctavian Purdila break; 24249f977fb7SOctavian Purdila if (val_a >= bitmap_len || neg) { 24259f977fb7SOctavian Purdila err = -EINVAL; 24269f977fb7SOctavian Purdila break; 24279f977fb7SOctavian Purdila } 24289f977fb7SOctavian Purdila 24299f977fb7SOctavian Purdila val_b = val_a; 24309f977fb7SOctavian Purdila if (left) { 24319f977fb7SOctavian Purdila kbuf++; 24329f977fb7SOctavian Purdila left--; 24339f977fb7SOctavian Purdila } 24349f977fb7SOctavian Purdila 24359f977fb7SOctavian Purdila if (c == '-') { 24369f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_b, 24379f977fb7SOctavian Purdila &neg, tr_b, sizeof(tr_b), 24389f977fb7SOctavian Purdila &c); 24399f977fb7SOctavian Purdila if (err) 24409f977fb7SOctavian Purdila break; 24419f977fb7SOctavian Purdila if (val_b >= bitmap_len || neg || 24429f977fb7SOctavian Purdila val_a > val_b) { 24439f977fb7SOctavian Purdila err = -EINVAL; 24449f977fb7SOctavian Purdila break; 24459f977fb7SOctavian Purdila } 24469f977fb7SOctavian Purdila if (left) { 24479f977fb7SOctavian Purdila kbuf++; 24489f977fb7SOctavian Purdila left--; 24499f977fb7SOctavian Purdila } 24509f977fb7SOctavian Purdila } 24519f977fb7SOctavian Purdila 24525a04cca6SAkinobu Mita bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 24539f977fb7SOctavian Purdila first = 0; 24549f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 24559f977fb7SOctavian Purdila } 24569f977fb7SOctavian Purdila free_page(page); 24579f977fb7SOctavian Purdila } else { 24589f977fb7SOctavian Purdila unsigned long bit_a, bit_b = 0; 24599f977fb7SOctavian Purdila 24609f977fb7SOctavian Purdila while (left) { 24619f977fb7SOctavian Purdila bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 24629f977fb7SOctavian Purdila if (bit_a >= bitmap_len) 24639f977fb7SOctavian Purdila break; 24649f977fb7SOctavian Purdila bit_b = find_next_zero_bit(bitmap, bitmap_len, 24659f977fb7SOctavian Purdila bit_a + 1) - 1; 24669f977fb7SOctavian Purdila 24679f977fb7SOctavian Purdila if (!first) { 24689f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, ','); 24699f977fb7SOctavian Purdila if (err) 24709f977fb7SOctavian Purdila break; 24719f977fb7SOctavian Purdila } 24729f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_a, false); 24739f977fb7SOctavian Purdila if (err) 24749f977fb7SOctavian Purdila break; 24759f977fb7SOctavian Purdila if (bit_a != bit_b) { 24769f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '-'); 24779f977fb7SOctavian Purdila if (err) 24789f977fb7SOctavian Purdila break; 24799f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_b, false); 24809f977fb7SOctavian Purdila if (err) 24819f977fb7SOctavian Purdila break; 24829f977fb7SOctavian Purdila } 24839f977fb7SOctavian Purdila 24849f977fb7SOctavian Purdila first = 0; bit_b++; 24859f977fb7SOctavian Purdila } 24869f977fb7SOctavian Purdila if (!err) 24879f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '\n'); 24889f977fb7SOctavian Purdila } 24899f977fb7SOctavian Purdila 24909f977fb7SOctavian Purdila if (!err) { 24919f977fb7SOctavian Purdila if (write) { 24929f977fb7SOctavian Purdila if (*ppos) 24939f977fb7SOctavian Purdila bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 24949f977fb7SOctavian Purdila else 24955a04cca6SAkinobu Mita bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 24969f977fb7SOctavian Purdila } 24979f977fb7SOctavian Purdila kfree(tmp_bitmap); 24989f977fb7SOctavian Purdila *lenp -= left; 24999f977fb7SOctavian Purdila *ppos += *lenp; 25009f977fb7SOctavian Purdila return 0; 25019f977fb7SOctavian Purdila } else { 25029f977fb7SOctavian Purdila kfree(tmp_bitmap); 25039f977fb7SOctavian Purdila return err; 25049f977fb7SOctavian Purdila } 25059f977fb7SOctavian Purdila } 25069f977fb7SOctavian Purdila 250755610500SJovi Zhang #else /* CONFIG_PROC_SYSCTL */ 25081da177e4SLinus Torvalds 25098d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 25101da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25111da177e4SLinus Torvalds { 25121da177e4SLinus Torvalds return -ENOSYS; 25131da177e4SLinus Torvalds } 25141da177e4SLinus Torvalds 25158d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 25161da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25171da177e4SLinus Torvalds { 25181da177e4SLinus Torvalds return -ENOSYS; 25191da177e4SLinus Torvalds } 25201da177e4SLinus Torvalds 25218d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 25221da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25231da177e4SLinus Torvalds { 25241da177e4SLinus Torvalds return -ENOSYS; 25251da177e4SLinus Torvalds } 25261da177e4SLinus Torvalds 25278d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 25281da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25291da177e4SLinus Torvalds { 25301da177e4SLinus Torvalds return -ENOSYS; 25311da177e4SLinus Torvalds } 25321da177e4SLinus Torvalds 25338d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 25341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25351da177e4SLinus Torvalds { 25361da177e4SLinus Torvalds return -ENOSYS; 25371da177e4SLinus Torvalds } 25381da177e4SLinus Torvalds 25398d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 25401da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25411da177e4SLinus Torvalds { 25421da177e4SLinus Torvalds return -ENOSYS; 25431da177e4SLinus Torvalds } 25441da177e4SLinus Torvalds 25458d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 25461da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25471da177e4SLinus Torvalds { 25481da177e4SLinus Torvalds return -ENOSYS; 25491da177e4SLinus Torvalds } 25501da177e4SLinus Torvalds 2551d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 25521da177e4SLinus Torvalds void __user *buffer, 25531da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 25541da177e4SLinus Torvalds { 25551da177e4SLinus Torvalds return -ENOSYS; 25561da177e4SLinus Torvalds } 25571da177e4SLinus Torvalds 25581da177e4SLinus Torvalds 255955610500SJovi Zhang #endif /* CONFIG_PROC_SYSCTL */ 25601da177e4SLinus Torvalds 25611da177e4SLinus Torvalds /* 25621da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 25631da177e4SLinus Torvalds * exception granted :-) 25641da177e4SLinus Torvalds */ 25651da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 25661da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 25671da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 25681da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 25691da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 25701da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 25711da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 25721da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 2573