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; 100d6e71144SAlan Cox extern int suid_dumpable; 101046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 102046d662fSAlex Kelly extern int core_uses_pid; 1031da177e4SLinus Torvalds extern char core_pattern[]; 104a293980cSNeil Horman extern unsigned int core_pipe_limit; 105046d662fSAlex Kelly #endif 1061da177e4SLinus Torvalds extern int pid_max; 1071da177e4SLinus Torvalds extern int min_free_kbytes; 1081da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 1099d0243bcSAndrew Morton extern int sysctl_drop_caches; 1108ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 111bebfa101SAndi Kleen extern int compat_log; 1129745512cSArjan van de Ven extern int latencytop_enabled; 113eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 114dd8632a1SPaul Mundt #ifndef CONFIG_MMU 115dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 116dd8632a1SPaul Mundt #endif 117cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 1185e605b64SJens Axboe extern int blk_iopoll_enabled; 119cb684b5bSJens Axboe #endif 1201da177e4SLinus Torvalds 121c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 1222508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR 123c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1249383d967SDimitri Sivanich static int neg_one = -1; 125c4f3b63fSRavikiran G Thirumalai #endif 126c4f3b63fSRavikiran G Thirumalai 127c4f3b63fSRavikiran G Thirumalai static int zero; 128cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 129cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 130cb16e95fSPetr Holasek static int __maybe_unused three = 3; 131fc3501d4SSven Wegener static unsigned long one_ul = 1; 132c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 133af91322eSDave Young #ifdef CONFIG_PRINTK 134af91322eSDave Young static int ten_thousand = 10000; 135af91322eSDave Young #endif 136c4f3b63fSRavikiran G Thirumalai 1379e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1389e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1399e4a5bdaSAndrea Righi 1401da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1411da177e4SLinus Torvalds static int maxolduid = 65535; 1421da177e4SLinus Torvalds static int minolduid; 1438ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 14673efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP; 1471da177e4SLinus Torvalds 148d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER 149d14f1729SDave Young #include <linux/inotify.h> 150d14f1729SDave Young #endif 15172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 1521da177e4SLinus Torvalds #endif 1531da177e4SLinus Torvalds 1540871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1550871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1560871420fSDavid S. Miller #endif 1570871420fSDavid S. Miller 1581da177e4SLinus Torvalds #ifdef __hppa__ 1591da177e4SLinus Torvalds extern int pwrsw_enabled; 1601da177e4SLinus Torvalds extern int unaligned_enabled; 1611da177e4SLinus Torvalds #endif 1621da177e4SLinus Torvalds 163d2b176edSJes Sorensen #ifdef CONFIG_IA64 164d2b176edSJes Sorensen extern int no_unaligned_warning; 16588fc241fSDoug Chapman extern int unaligned_dump_stack; 166d2b176edSJes Sorensen #endif 167d2b176edSJes Sorensen 168d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1698d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1709ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1718d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 17234f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 173d6f8ff73SRandy Dunlap #endif 1749ec52099SCedric Le Goater 175bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 176620f6e8eSKees Cook static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 177bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos); 178bfdc0b49SRichard Weinberger #endif 179bfdc0b49SRichard Weinberger 18054b50199SKees Cook static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 18154b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos); 182046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 18354b50199SKees Cook static int proc_dostring_coredump(struct ctl_table *table, int write, 18454b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos); 185046d662fSAlex Kelly #endif 18654b50199SKees Cook 18797f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ 1888c6a98b2SAndy Whitcroft /* Note: sysrq code uses it's own private copy */ 1898c6a98b2SAndy Whitcroft static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; 19097f5f0cdSDmitry Torokhov 19197f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write, 19297f5f0cdSDmitry Torokhov void __user *buffer, size_t *lenp, 19397f5f0cdSDmitry Torokhov loff_t *ppos) 19497f5f0cdSDmitry Torokhov { 19597f5f0cdSDmitry Torokhov int error; 19697f5f0cdSDmitry Torokhov 19797f5f0cdSDmitry Torokhov error = proc_dointvec(table, write, buffer, lenp, ppos); 19897f5f0cdSDmitry Torokhov if (error) 19997f5f0cdSDmitry Torokhov return error; 20097f5f0cdSDmitry Torokhov 20197f5f0cdSDmitry Torokhov if (write) 20297f5f0cdSDmitry Torokhov sysrq_toggle_support(__sysrq_enabled); 20397f5f0cdSDmitry Torokhov 20497f5f0cdSDmitry Torokhov return 0; 20597f5f0cdSDmitry Torokhov } 20697f5f0cdSDmitry Torokhov 20797f5f0cdSDmitry Torokhov #endif 20897f5f0cdSDmitry Torokhov 209d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 210d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 211d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 212d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 213d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 214d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 2157ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 2167ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 2177ef9964eSDavide Libenzi #endif 2181da177e4SLinus Torvalds 2191da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 2201da177e4SLinus Torvalds int sysctl_legacy_va_layout; 2211da177e4SLinus Torvalds #endif 2221da177e4SLinus Torvalds 2231da177e4SLinus Torvalds /* The default sysctl tables: */ 2241da177e4SLinus Torvalds 225de4e83bdSEric W. Biederman static struct ctl_table sysctl_base_table[] = { 2261da177e4SLinus Torvalds { 2271da177e4SLinus Torvalds .procname = "kernel", 2281da177e4SLinus Torvalds .mode = 0555, 2291da177e4SLinus Torvalds .child = kern_table, 2301da177e4SLinus Torvalds }, 2311da177e4SLinus Torvalds { 2321da177e4SLinus Torvalds .procname = "vm", 2331da177e4SLinus Torvalds .mode = 0555, 2341da177e4SLinus Torvalds .child = vm_table, 2351da177e4SLinus Torvalds }, 2361da177e4SLinus Torvalds { 2371da177e4SLinus Torvalds .procname = "fs", 2381da177e4SLinus Torvalds .mode = 0555, 2391da177e4SLinus Torvalds .child = fs_table, 2401da177e4SLinus Torvalds }, 2411da177e4SLinus Torvalds { 2421da177e4SLinus Torvalds .procname = "debug", 2431da177e4SLinus Torvalds .mode = 0555, 2441da177e4SLinus Torvalds .child = debug_table, 2451da177e4SLinus Torvalds }, 2461da177e4SLinus Torvalds { 2471da177e4SLinus Torvalds .procname = "dev", 2481da177e4SLinus Torvalds .mode = 0555, 2491da177e4SLinus Torvalds .child = dev_table, 2501da177e4SLinus Torvalds }, 2516fce56ecSEric W. Biederman { } 2521da177e4SLinus Torvalds }; 2531da177e4SLinus Torvalds 25477e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 25573c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 25673c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 25773c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 25873c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2591983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2601983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 26177e54a1fSIngo Molnar #endif 26277e54a1fSIngo Molnar 2635e771905SMel Gorman #ifdef CONFIG_COMPACTION 2645e771905SMel Gorman static int min_extfrag_threshold; 2655e771905SMel Gorman static int max_extfrag_threshold = 1000; 2665e771905SMel Gorman #endif 2675e771905SMel Gorman 268d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2692bba22c5SMike Galbraith { 2702bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2712bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2722bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2732bba22c5SMike Galbraith .mode = 0644, 2746d456111SEric W. Biederman .proc_handler = proc_dointvec, 2752bba22c5SMike Galbraith }, 27677e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 27777e54a1fSIngo Molnar { 278b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 279b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 28077e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 28177e54a1fSIngo Molnar .mode = 0644, 282702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 283b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 284b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 28577e54a1fSIngo Molnar }, 28677e54a1fSIngo Molnar { 28721805085SPeter Zijlstra .procname = "sched_latency_ns", 28821805085SPeter Zijlstra .data = &sysctl_sched_latency, 28921805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 29021805085SPeter Zijlstra .mode = 0644, 291702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 29221805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 29321805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 29421805085SPeter Zijlstra }, 29521805085SPeter Zijlstra { 29677e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 29777e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 29877e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 29977e54a1fSIngo Molnar .mode = 0644, 300702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 30177e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 30277e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 30377e54a1fSIngo Molnar }, 30477e54a1fSIngo Molnar { 3051983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 3061983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 3071983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 3081983a922SChristian Ehrhardt .mode = 0644, 309702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 3101983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 3111983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 3122398f2c6SPeter Zijlstra }, 3132398f2c6SPeter Zijlstra { 314d00535dbSNamhyung Kim .procname = "sched_migration_cost_ns", 315da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 316da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 317da84d961SIngo Molnar .mode = 0644, 3186d456111SEric W. Biederman .proc_handler = proc_dointvec, 319da84d961SIngo Molnar }, 320b82d9fddSPeter Zijlstra { 321b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 322b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 323b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 324fa85ae24SPeter Zijlstra .mode = 0644, 3256d456111SEric W. Biederman .proc_handler = proc_dointvec, 326fa85ae24SPeter Zijlstra }, 327cd1bb94bSArun R Bharadwaj { 328d00535dbSNamhyung Kim .procname = "sched_time_avg_ms", 329e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 330e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 331e9e9250bSPeter Zijlstra .mode = 0644, 3326d456111SEric W. Biederman .proc_handler = proc_dointvec, 333e9e9250bSPeter Zijlstra }, 334e9e9250bSPeter Zijlstra { 335d00535dbSNamhyung Kim .procname = "sched_shares_window_ns", 336a7a4f8a7SPaul Turner .data = &sysctl_sched_shares_window, 337a7a4f8a7SPaul Turner .maxlen = sizeof(unsigned int), 338a7a4f8a7SPaul Turner .mode = 0644, 339a7a4f8a7SPaul Turner .proc_handler = proc_dointvec, 340a7a4f8a7SPaul Turner }, 341a7a4f8a7SPaul Turner { 342cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 343cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 344cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 345cd1bb94bSArun R Bharadwaj .mode = 0644, 3466d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 347bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 348bfdb4d9fSArun R Bharadwaj .extra2 = &one, 349cd1bb94bSArun R Bharadwaj }, 3501fc84aaaSPeter Zijlstra #endif 3511799e35dSIngo Molnar { 3529f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3539f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3549f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3559f0c1e56SPeter Zijlstra .mode = 0644, 3566d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3579f0c1e56SPeter Zijlstra }, 3589f0c1e56SPeter Zijlstra { 3599f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3609f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3619f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3629f0c1e56SPeter Zijlstra .mode = 0644, 3636d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3649f0c1e56SPeter Zijlstra }, 3655091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP 3665091faa4SMike Galbraith { 3675091faa4SMike Galbraith .procname = "sched_autogroup_enabled", 3685091faa4SMike Galbraith .data = &sysctl_sched_autogroup_enabled, 3695091faa4SMike Galbraith .maxlen = sizeof(unsigned int), 3705091faa4SMike Galbraith .mode = 0644, 3711747b21fSYong Zhang .proc_handler = proc_dointvec_minmax, 3725091faa4SMike Galbraith .extra1 = &zero, 3735091faa4SMike Galbraith .extra2 = &one, 3745091faa4SMike Galbraith }, 3755091faa4SMike Galbraith #endif 376ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH 377ec12cb7fSPaul Turner { 378ec12cb7fSPaul Turner .procname = "sched_cfs_bandwidth_slice_us", 379ec12cb7fSPaul Turner .data = &sysctl_sched_cfs_bandwidth_slice, 380ec12cb7fSPaul Turner .maxlen = sizeof(unsigned int), 381ec12cb7fSPaul Turner .mode = 0644, 382ec12cb7fSPaul Turner .proc_handler = proc_dointvec_minmax, 383ec12cb7fSPaul Turner .extra1 = &one, 384ec12cb7fSPaul Turner }, 385ec12cb7fSPaul Turner #endif 386f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 387f20786ffSPeter Zijlstra { 388f20786ffSPeter Zijlstra .procname = "prove_locking", 389f20786ffSPeter Zijlstra .data = &prove_locking, 390f20786ffSPeter Zijlstra .maxlen = sizeof(int), 391f20786ffSPeter Zijlstra .mode = 0644, 3926d456111SEric W. Biederman .proc_handler = proc_dointvec, 393f20786ffSPeter Zijlstra }, 394f20786ffSPeter Zijlstra #endif 395f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 396f20786ffSPeter Zijlstra { 397f20786ffSPeter Zijlstra .procname = "lock_stat", 398f20786ffSPeter Zijlstra .data = &lock_stat, 399f20786ffSPeter Zijlstra .maxlen = sizeof(int), 400f20786ffSPeter Zijlstra .mode = 0644, 4016d456111SEric W. Biederman .proc_handler = proc_dointvec, 402f20786ffSPeter Zijlstra }, 403f20786ffSPeter Zijlstra #endif 40477e54a1fSIngo Molnar { 4051da177e4SLinus Torvalds .procname = "panic", 4061da177e4SLinus Torvalds .data = &panic_timeout, 4071da177e4SLinus Torvalds .maxlen = sizeof(int), 4081da177e4SLinus Torvalds .mode = 0644, 4096d456111SEric W. Biederman .proc_handler = proc_dointvec, 4101da177e4SLinus Torvalds }, 411046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 4121da177e4SLinus Torvalds { 4131da177e4SLinus Torvalds .procname = "core_uses_pid", 4141da177e4SLinus Torvalds .data = &core_uses_pid, 4151da177e4SLinus Torvalds .maxlen = sizeof(int), 4161da177e4SLinus Torvalds .mode = 0644, 4176d456111SEric W. Biederman .proc_handler = proc_dointvec, 4181da177e4SLinus Torvalds }, 4191da177e4SLinus Torvalds { 4201da177e4SLinus Torvalds .procname = "core_pattern", 4211da177e4SLinus Torvalds .data = core_pattern, 42271ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 4231da177e4SLinus Torvalds .mode = 0644, 42454b50199SKees Cook .proc_handler = proc_dostring_coredump, 4251da177e4SLinus Torvalds }, 426a293980cSNeil Horman { 427a293980cSNeil Horman .procname = "core_pipe_limit", 428a293980cSNeil Horman .data = &core_pipe_limit, 429a293980cSNeil Horman .maxlen = sizeof(unsigned int), 430a293980cSNeil Horman .mode = 0644, 4316d456111SEric W. Biederman .proc_handler = proc_dointvec, 432a293980cSNeil Horman }, 433046d662fSAlex Kelly #endif 43434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4351da177e4SLinus Torvalds { 4361da177e4SLinus Torvalds .procname = "tainted", 43725ddbb18SAndi Kleen .maxlen = sizeof(long), 43834f5a398STheodore Ts'o .mode = 0644, 4396d456111SEric W. Biederman .proc_handler = proc_taint, 4401da177e4SLinus Torvalds }, 44134f5a398STheodore Ts'o #endif 4429745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4439745512cSArjan van de Ven { 4449745512cSArjan van de Ven .procname = "latencytop", 4459745512cSArjan van de Ven .data = &latencytop_enabled, 4469745512cSArjan van de Ven .maxlen = sizeof(int), 4479745512cSArjan van de Ven .mode = 0644, 4486d456111SEric W. Biederman .proc_handler = proc_dointvec, 4499745512cSArjan van de Ven }, 4509745512cSArjan van de Ven #endif 4511da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4521da177e4SLinus Torvalds { 4531da177e4SLinus Torvalds .procname = "real-root-dev", 4541da177e4SLinus Torvalds .data = &real_root_dev, 4551da177e4SLinus Torvalds .maxlen = sizeof(int), 4561da177e4SLinus Torvalds .mode = 0644, 4576d456111SEric W. Biederman .proc_handler = proc_dointvec, 4581da177e4SLinus Torvalds }, 4591da177e4SLinus Torvalds #endif 46045807a1dSIngo Molnar { 46145807a1dSIngo Molnar .procname = "print-fatal-signals", 46245807a1dSIngo Molnar .data = &print_fatal_signals, 46345807a1dSIngo Molnar .maxlen = sizeof(int), 46445807a1dSIngo Molnar .mode = 0644, 4656d456111SEric W. Biederman .proc_handler = proc_dointvec, 46645807a1dSIngo Molnar }, 46772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4681da177e4SLinus Torvalds { 4691da177e4SLinus Torvalds .procname = "reboot-cmd", 4701da177e4SLinus Torvalds .data = reboot_command, 4711da177e4SLinus Torvalds .maxlen = 256, 4721da177e4SLinus Torvalds .mode = 0644, 4736d456111SEric W. Biederman .proc_handler = proc_dostring, 4741da177e4SLinus Torvalds }, 4751da177e4SLinus Torvalds { 4761da177e4SLinus Torvalds .procname = "stop-a", 4771da177e4SLinus Torvalds .data = &stop_a_enabled, 4781da177e4SLinus Torvalds .maxlen = sizeof (int), 4791da177e4SLinus Torvalds .mode = 0644, 4806d456111SEric W. Biederman .proc_handler = proc_dointvec, 4811da177e4SLinus Torvalds }, 4821da177e4SLinus Torvalds { 4831da177e4SLinus Torvalds .procname = "scons-poweroff", 4841da177e4SLinus Torvalds .data = &scons_pwroff, 4851da177e4SLinus Torvalds .maxlen = sizeof (int), 4861da177e4SLinus Torvalds .mode = 0644, 4876d456111SEric W. Biederman .proc_handler = proc_dointvec, 4881da177e4SLinus Torvalds }, 4891da177e4SLinus Torvalds #endif 4900871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4910871420fSDavid S. Miller { 4920871420fSDavid S. Miller .procname = "tsb-ratio", 4930871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4940871420fSDavid S. Miller .maxlen = sizeof (int), 4950871420fSDavid S. Miller .mode = 0644, 4966d456111SEric W. Biederman .proc_handler = proc_dointvec, 4970871420fSDavid S. Miller }, 4980871420fSDavid S. Miller #endif 4991da177e4SLinus Torvalds #ifdef __hppa__ 5001da177e4SLinus Torvalds { 5011da177e4SLinus Torvalds .procname = "soft-power", 5021da177e4SLinus Torvalds .data = &pwrsw_enabled, 5031da177e4SLinus Torvalds .maxlen = sizeof (int), 5041da177e4SLinus Torvalds .mode = 0644, 5056d456111SEric W. Biederman .proc_handler = proc_dointvec, 5061da177e4SLinus Torvalds }, 5071da177e4SLinus Torvalds { 5081da177e4SLinus Torvalds .procname = "unaligned-trap", 5091da177e4SLinus Torvalds .data = &unaligned_enabled, 5101da177e4SLinus Torvalds .maxlen = sizeof (int), 5111da177e4SLinus Torvalds .mode = 0644, 5126d456111SEric W. Biederman .proc_handler = proc_dointvec, 5131da177e4SLinus Torvalds }, 5141da177e4SLinus Torvalds #endif 5151da177e4SLinus Torvalds { 5161da177e4SLinus Torvalds .procname = "ctrl-alt-del", 5171da177e4SLinus Torvalds .data = &C_A_D, 5181da177e4SLinus Torvalds .maxlen = sizeof(int), 5191da177e4SLinus Torvalds .mode = 0644, 5206d456111SEric W. Biederman .proc_handler = proc_dointvec, 5211da177e4SLinus Torvalds }, 522606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 523b0fc494fSSteven Rostedt { 524b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 525b0fc494fSSteven Rostedt .data = &ftrace_enabled, 526b0fc494fSSteven Rostedt .maxlen = sizeof(int), 527b0fc494fSSteven Rostedt .mode = 0644, 5286d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 529b0fc494fSSteven Rostedt }, 530b0fc494fSSteven Rostedt #endif 531f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 532f38f1d2aSSteven Rostedt { 533f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 534f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 535f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 536f38f1d2aSSteven Rostedt .mode = 0644, 5376d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 538f38f1d2aSSteven Rostedt }, 539f38f1d2aSSteven Rostedt #endif 540944ac425SSteven Rostedt #ifdef CONFIG_TRACING 541944ac425SSteven Rostedt { 5423299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 543944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 544944ac425SSteven Rostedt .maxlen = sizeof(int), 545944ac425SSteven Rostedt .mode = 0644, 5466d456111SEric W. Biederman .proc_handler = proc_dointvec, 547944ac425SSteven Rostedt }, 548944ac425SSteven Rostedt #endif 549a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5501da177e4SLinus Torvalds { 5511da177e4SLinus Torvalds .procname = "modprobe", 5521da177e4SLinus Torvalds .data = &modprobe_path, 5531da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5541da177e4SLinus Torvalds .mode = 0644, 5556d456111SEric W. Biederman .proc_handler = proc_dostring, 5561da177e4SLinus Torvalds }, 5573d43321bSKees Cook { 5583d43321bSKees Cook .procname = "modules_disabled", 5593d43321bSKees Cook .data = &modules_disabled, 5603d43321bSKees Cook .maxlen = sizeof(int), 5613d43321bSKees Cook .mode = 0644, 5623d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5636d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5643d43321bSKees Cook .extra1 = &one, 5653d43321bSKees Cook .extra2 = &one, 5663d43321bSKees Cook }, 5671da177e4SLinus Torvalds #endif 568*3b572b50SBill Pemberton 5691da177e4SLinus Torvalds { 5701da177e4SLinus Torvalds .procname = "hotplug", 571312c004dSKay Sievers .data = &uevent_helper, 572312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5731da177e4SLinus Torvalds .mode = 0644, 5746d456111SEric W. Biederman .proc_handler = proc_dostring, 5751da177e4SLinus Torvalds }, 576*3b572b50SBill Pemberton 5771da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5781da177e4SLinus Torvalds { 5791da177e4SLinus Torvalds .procname = "sg-big-buff", 5801da177e4SLinus Torvalds .data = &sg_big_buff, 5811da177e4SLinus Torvalds .maxlen = sizeof (int), 5821da177e4SLinus Torvalds .mode = 0444, 5836d456111SEric W. Biederman .proc_handler = proc_dointvec, 5841da177e4SLinus Torvalds }, 5851da177e4SLinus Torvalds #endif 5861da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5871da177e4SLinus Torvalds { 5881da177e4SLinus Torvalds .procname = "acct", 5891da177e4SLinus Torvalds .data = &acct_parm, 5901da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5911da177e4SLinus Torvalds .mode = 0644, 5926d456111SEric W. Biederman .proc_handler = proc_dointvec, 5931da177e4SLinus Torvalds }, 5941da177e4SLinus Torvalds #endif 5951da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5961da177e4SLinus Torvalds { 5971da177e4SLinus Torvalds .procname = "sysrq", 5985d6f647fSIngo Molnar .data = &__sysrq_enabled, 5991da177e4SLinus Torvalds .maxlen = sizeof (int), 6001da177e4SLinus Torvalds .mode = 0644, 60197f5f0cdSDmitry Torokhov .proc_handler = sysrq_sysctl_handler, 6021da177e4SLinus Torvalds }, 6031da177e4SLinus Torvalds #endif 604d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 6051da177e4SLinus Torvalds { 6061da177e4SLinus Torvalds .procname = "cad_pid", 6079ec52099SCedric Le Goater .data = NULL, 6081da177e4SLinus Torvalds .maxlen = sizeof (int), 6091da177e4SLinus Torvalds .mode = 0600, 6106d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 6111da177e4SLinus Torvalds }, 612d6f8ff73SRandy Dunlap #endif 6131da177e4SLinus Torvalds { 6141da177e4SLinus Torvalds .procname = "threads-max", 6151da177e4SLinus Torvalds .data = &max_threads, 6161da177e4SLinus Torvalds .maxlen = sizeof(int), 6171da177e4SLinus Torvalds .mode = 0644, 6186d456111SEric W. Biederman .proc_handler = proc_dointvec, 6191da177e4SLinus Torvalds }, 6201da177e4SLinus Torvalds { 6211da177e4SLinus Torvalds .procname = "random", 6221da177e4SLinus Torvalds .mode = 0555, 6231da177e4SLinus Torvalds .child = random_table, 6241da177e4SLinus Torvalds }, 6251da177e4SLinus Torvalds { 62617f60a7dSEric Paris .procname = "usermodehelper", 62717f60a7dSEric Paris .mode = 0555, 62817f60a7dSEric Paris .child = usermodehelper_table, 62917f60a7dSEric Paris }, 63017f60a7dSEric Paris { 6311da177e4SLinus Torvalds .procname = "overflowuid", 6321da177e4SLinus Torvalds .data = &overflowuid, 6331da177e4SLinus Torvalds .maxlen = sizeof(int), 6341da177e4SLinus Torvalds .mode = 0644, 6356d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6361da177e4SLinus Torvalds .extra1 = &minolduid, 6371da177e4SLinus Torvalds .extra2 = &maxolduid, 6381da177e4SLinus Torvalds }, 6391da177e4SLinus Torvalds { 6401da177e4SLinus Torvalds .procname = "overflowgid", 6411da177e4SLinus Torvalds .data = &overflowgid, 6421da177e4SLinus Torvalds .maxlen = sizeof(int), 6431da177e4SLinus Torvalds .mode = 0644, 6446d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6451da177e4SLinus Torvalds .extra1 = &minolduid, 6461da177e4SLinus Torvalds .extra2 = &maxolduid, 6471da177e4SLinus Torvalds }, 648347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6491da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6501da177e4SLinus Torvalds { 6511da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6521da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6531da177e4SLinus Torvalds .maxlen = sizeof(int), 6541da177e4SLinus Torvalds .mode = 0644, 6556d456111SEric W. Biederman .proc_handler = proc_dointvec, 6561da177e4SLinus Torvalds }, 6571da177e4SLinus Torvalds #endif 6581da177e4SLinus Torvalds { 6591da177e4SLinus Torvalds .procname = "userprocess_debug", 660ab3c68eeSHeiko Carstens .data = &show_unhandled_signals, 6611da177e4SLinus Torvalds .maxlen = sizeof(int), 6621da177e4SLinus Torvalds .mode = 0644, 6636d456111SEric W. Biederman .proc_handler = proc_dointvec, 6641da177e4SLinus Torvalds }, 6651da177e4SLinus Torvalds #endif 6661da177e4SLinus Torvalds { 6671da177e4SLinus Torvalds .procname = "pid_max", 6681da177e4SLinus Torvalds .data = &pid_max, 6691da177e4SLinus Torvalds .maxlen = sizeof (int), 6701da177e4SLinus Torvalds .mode = 0644, 6716d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6721da177e4SLinus Torvalds .extra1 = &pid_max_min, 6731da177e4SLinus Torvalds .extra2 = &pid_max_max, 6741da177e4SLinus Torvalds }, 6751da177e4SLinus Torvalds { 6761da177e4SLinus Torvalds .procname = "panic_on_oops", 6771da177e4SLinus Torvalds .data = &panic_on_oops, 6781da177e4SLinus Torvalds .maxlen = sizeof(int), 6791da177e4SLinus Torvalds .mode = 0644, 6806d456111SEric W. Biederman .proc_handler = proc_dointvec, 6811da177e4SLinus Torvalds }, 6827ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6837ef3d2fdSJoe Perches { 6847ef3d2fdSJoe Perches .procname = "printk", 6857ef3d2fdSJoe Perches .data = &console_loglevel, 6867ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6877ef3d2fdSJoe Perches .mode = 0644, 6886d456111SEric W. Biederman .proc_handler = proc_dointvec, 6897ef3d2fdSJoe Perches }, 6901da177e4SLinus Torvalds { 6911da177e4SLinus Torvalds .procname = "printk_ratelimit", 692717115e1SDave Young .data = &printk_ratelimit_state.interval, 6931da177e4SLinus Torvalds .maxlen = sizeof(int), 6941da177e4SLinus Torvalds .mode = 0644, 6956d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6961da177e4SLinus Torvalds }, 6971da177e4SLinus Torvalds { 6981da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 699717115e1SDave Young .data = &printk_ratelimit_state.burst, 7001da177e4SLinus Torvalds .maxlen = sizeof(int), 7011da177e4SLinus Torvalds .mode = 0644, 7026d456111SEric W. Biederman .proc_handler = proc_dointvec, 7031da177e4SLinus Torvalds }, 704af91322eSDave Young { 705af91322eSDave Young .procname = "printk_delay", 706af91322eSDave Young .data = &printk_delay_msec, 707af91322eSDave Young .maxlen = sizeof(int), 708af91322eSDave Young .mode = 0644, 7096d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 710af91322eSDave Young .extra1 = &zero, 711af91322eSDave Young .extra2 = &ten_thousand, 712af91322eSDave Young }, 7131da177e4SLinus Torvalds { 714eaf06b24SDan Rosenberg .procname = "dmesg_restrict", 715eaf06b24SDan Rosenberg .data = &dmesg_restrict, 716eaf06b24SDan Rosenberg .maxlen = sizeof(int), 717eaf06b24SDan Rosenberg .mode = 0644, 718620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 719eaf06b24SDan Rosenberg .extra1 = &zero, 720eaf06b24SDan Rosenberg .extra2 = &one, 721eaf06b24SDan Rosenberg }, 722455cd5abSDan Rosenberg { 723455cd5abSDan Rosenberg .procname = "kptr_restrict", 724455cd5abSDan Rosenberg .data = &kptr_restrict, 725455cd5abSDan Rosenberg .maxlen = sizeof(int), 726455cd5abSDan Rosenberg .mode = 0644, 727620f6e8eSKees Cook .proc_handler = proc_dointvec_minmax_sysadmin, 728455cd5abSDan Rosenberg .extra1 = &zero, 729455cd5abSDan Rosenberg .extra2 = &two, 730455cd5abSDan Rosenberg }, 731df6e61d4SJoe Perches #endif 732eaf06b24SDan Rosenberg { 7331da177e4SLinus Torvalds .procname = "ngroups_max", 7341da177e4SLinus Torvalds .data = &ngroups_max, 7351da177e4SLinus Torvalds .maxlen = sizeof (int), 7361da177e4SLinus Torvalds .mode = 0444, 7376d456111SEric W. Biederman .proc_handler = proc_dointvec, 7381da177e4SLinus Torvalds }, 73973efc039SDan Ballard { 74073efc039SDan Ballard .procname = "cap_last_cap", 74173efc039SDan Ballard .data = (void *)&cap_last_cap, 74273efc039SDan Ballard .maxlen = sizeof(int), 74373efc039SDan Ballard .mode = 0444, 74473efc039SDan Ballard .proc_handler = proc_dointvec, 74573efc039SDan Ballard }, 74658687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR) 747504d7cf1SDon Zickus { 74858687acbSDon Zickus .procname = "watchdog", 74958687acbSDon Zickus .data = &watchdog_enabled, 750504d7cf1SDon Zickus .maxlen = sizeof (int), 751504d7cf1SDon Zickus .mode = 0644, 752586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 753586692a5SMandeep Singh Baines .extra1 = &zero, 754586692a5SMandeep Singh Baines .extra2 = &one, 75558687acbSDon Zickus }, 75658687acbSDon Zickus { 75758687acbSDon Zickus .procname = "watchdog_thresh", 758586692a5SMandeep Singh Baines .data = &watchdog_thresh, 75958687acbSDon Zickus .maxlen = sizeof(int), 76058687acbSDon Zickus .mode = 0644, 761586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 76258687acbSDon Zickus .extra1 = &neg_one, 76358687acbSDon Zickus .extra2 = &sixty, 764504d7cf1SDon Zickus }, 7652508ce18SDon Zickus { 7662508ce18SDon Zickus .procname = "softlockup_panic", 7672508ce18SDon Zickus .data = &softlockup_panic, 7682508ce18SDon Zickus .maxlen = sizeof(int), 7692508ce18SDon Zickus .mode = 0644, 7702508ce18SDon Zickus .proc_handler = proc_dointvec_minmax, 7712508ce18SDon Zickus .extra1 = &zero, 7722508ce18SDon Zickus .extra2 = &one, 7732508ce18SDon Zickus }, 7745dc30558SDon Zickus { 7755dc30558SDon Zickus .procname = "nmi_watchdog", 7765dc30558SDon Zickus .data = &watchdog_enabled, 7775dc30558SDon Zickus .maxlen = sizeof (int), 7785dc30558SDon Zickus .mode = 0644, 779586692a5SMandeep Singh Baines .proc_handler = proc_dowatchdog, 780586692a5SMandeep Singh Baines .extra1 = &zero, 781586692a5SMandeep Singh Baines .extra2 = &one, 7825dc30558SDon Zickus }, 7835dc30558SDon Zickus #endif 7845dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 7855dc30558SDon Zickus { 7865dc30558SDon Zickus .procname = "unknown_nmi_panic", 7875dc30558SDon Zickus .data = &unknown_nmi_panic, 7885dc30558SDon Zickus .maxlen = sizeof (int), 7895dc30558SDon Zickus .mode = 0644, 7905dc30558SDon Zickus .proc_handler = proc_dointvec, 7915dc30558SDon Zickus }, 792504d7cf1SDon Zickus #endif 7931da177e4SLinus Torvalds #if defined(CONFIG_X86) 7941da177e4SLinus Torvalds { 7958da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7968da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7978da5addaSDon Zickus .maxlen = sizeof(int), 7988da5addaSDon Zickus .mode = 0644, 7996d456111SEric W. Biederman .proc_handler = proc_dointvec, 8008da5addaSDon Zickus }, 8018da5addaSDon Zickus { 8025211a242SKurt Garloff .procname = "panic_on_io_nmi", 8035211a242SKurt Garloff .data = &panic_on_io_nmi, 8045211a242SKurt Garloff .maxlen = sizeof(int), 8055211a242SKurt Garloff .mode = 0644, 8066d456111SEric W. Biederman .proc_handler = proc_dointvec, 8075211a242SKurt Garloff }, 80855af7796SMitsuo Hayasaka #ifdef CONFIG_DEBUG_STACKOVERFLOW 80955af7796SMitsuo Hayasaka { 81055af7796SMitsuo Hayasaka .procname = "panic_on_stackoverflow", 81155af7796SMitsuo Hayasaka .data = &sysctl_panic_on_stackoverflow, 81255af7796SMitsuo Hayasaka .maxlen = sizeof(int), 81355af7796SMitsuo Hayasaka .mode = 0644, 81455af7796SMitsuo Hayasaka .proc_handler = proc_dointvec, 81555af7796SMitsuo Hayasaka }, 81655af7796SMitsuo Hayasaka #endif 8175211a242SKurt Garloff { 8181da177e4SLinus Torvalds .procname = "bootloader_type", 8191da177e4SLinus Torvalds .data = &bootloader_type, 8201da177e4SLinus Torvalds .maxlen = sizeof (int), 8211da177e4SLinus Torvalds .mode = 0444, 8226d456111SEric W. Biederman .proc_handler = proc_dointvec, 8231da177e4SLinus Torvalds }, 8240741f4d2SChuck Ebbert { 8255031296cSH. Peter Anvin .procname = "bootloader_version", 8265031296cSH. Peter Anvin .data = &bootloader_version, 8275031296cSH. Peter Anvin .maxlen = sizeof (int), 8285031296cSH. Peter Anvin .mode = 0444, 8296d456111SEric W. Biederman .proc_handler = proc_dointvec, 8305031296cSH. Peter Anvin }, 8315031296cSH. Peter Anvin { 8320741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 8330741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 8340741f4d2SChuck Ebbert .maxlen = sizeof(int), 8350741f4d2SChuck Ebbert .mode = 0644, 8366d456111SEric W. Biederman .proc_handler = proc_dointvec, 8370741f4d2SChuck Ebbert }, 8386e7c4025SIngo Molnar { 8396e7c4025SIngo Molnar .procname = "io_delay_type", 8406e7c4025SIngo Molnar .data = &io_delay_type, 8416e7c4025SIngo Molnar .maxlen = sizeof(int), 8426e7c4025SIngo Molnar .mode = 0644, 8436d456111SEric W. Biederman .proc_handler = proc_dointvec, 8446e7c4025SIngo Molnar }, 8451da177e4SLinus Torvalds #endif 8467a9166e3SLuke Yang #if defined(CONFIG_MMU) 8471da177e4SLinus Torvalds { 8481da177e4SLinus Torvalds .procname = "randomize_va_space", 8491da177e4SLinus Torvalds .data = &randomize_va_space, 8501da177e4SLinus Torvalds .maxlen = sizeof(int), 8511da177e4SLinus Torvalds .mode = 0644, 8526d456111SEric W. Biederman .proc_handler = proc_dointvec, 8531da177e4SLinus Torvalds }, 8547a9166e3SLuke Yang #endif 8550152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 856951f22d5SMartin Schwidefsky { 857951f22d5SMartin Schwidefsky .procname = "spin_retry", 858951f22d5SMartin Schwidefsky .data = &spin_retry, 859951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 860951f22d5SMartin Schwidefsky .mode = 0644, 8616d456111SEric W. Biederman .proc_handler = proc_dointvec, 862951f22d5SMartin Schwidefsky }, 863951f22d5SMartin Schwidefsky #endif 864673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 865c255d844SPavel Machek { 866c255d844SPavel Machek .procname = "acpi_video_flags", 86777afcf78SPavel Machek .data = &acpi_realmode_flags, 868c255d844SPavel Machek .maxlen = sizeof (unsigned long), 869c255d844SPavel Machek .mode = 0644, 8706d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 871c255d844SPavel Machek }, 872c255d844SPavel Machek #endif 873d2b176edSJes Sorensen #ifdef CONFIG_IA64 874d2b176edSJes Sorensen { 875d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 876d2b176edSJes Sorensen .data = &no_unaligned_warning, 877d2b176edSJes Sorensen .maxlen = sizeof (int), 878d2b176edSJes Sorensen .mode = 0644, 8796d456111SEric W. Biederman .proc_handler = proc_dointvec, 880d2b176edSJes Sorensen }, 88188fc241fSDoug Chapman { 88288fc241fSDoug Chapman .procname = "unaligned-dump-stack", 88388fc241fSDoug Chapman .data = &unaligned_dump_stack, 88488fc241fSDoug Chapman .maxlen = sizeof (int), 88588fc241fSDoug Chapman .mode = 0644, 8866d456111SEric W. Biederman .proc_handler = proc_dointvec, 88788fc241fSDoug Chapman }, 888d2b176edSJes Sorensen #endif 889e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 890e162b39aSMandeep Singh Baines { 891e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 892e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 893e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 894e162b39aSMandeep Singh Baines .mode = 0644, 8956d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 896e162b39aSMandeep Singh Baines .extra1 = &zero, 897e162b39aSMandeep Singh Baines .extra2 = &one, 898e162b39aSMandeep Singh Baines }, 89982a1fcb9SIngo Molnar { 90082a1fcb9SIngo Molnar .procname = "hung_task_check_count", 90182a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 90290739081SIngo Molnar .maxlen = sizeof(unsigned long), 90382a1fcb9SIngo Molnar .mode = 0644, 9046d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 90582a1fcb9SIngo Molnar }, 90682a1fcb9SIngo Molnar { 90782a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 90882a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 90990739081SIngo Molnar .maxlen = sizeof(unsigned long), 91082a1fcb9SIngo Molnar .mode = 0644, 9116d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 91282a1fcb9SIngo Molnar }, 91382a1fcb9SIngo Molnar { 91482a1fcb9SIngo Molnar .procname = "hung_task_warnings", 91582a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 91690739081SIngo Molnar .maxlen = sizeof(unsigned long), 91782a1fcb9SIngo Molnar .mode = 0644, 9186d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 91982a1fcb9SIngo Molnar }, 920c4f3b63fSRavikiran G Thirumalai #endif 921bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 922bebfa101SAndi Kleen { 923bebfa101SAndi Kleen .procname = "compat-log", 924bebfa101SAndi Kleen .data = &compat_log, 925bebfa101SAndi Kleen .maxlen = sizeof (int), 926bebfa101SAndi Kleen .mode = 0644, 9276d456111SEric W. Biederman .proc_handler = proc_dointvec, 928bebfa101SAndi Kleen }, 929bebfa101SAndi Kleen #endif 93023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 93123f78d4aSIngo Molnar { 93223f78d4aSIngo Molnar .procname = "max_lock_depth", 93323f78d4aSIngo Molnar .data = &max_lock_depth, 93423f78d4aSIngo Molnar .maxlen = sizeof(int), 93523f78d4aSIngo Molnar .mode = 0644, 9366d456111SEric W. Biederman .proc_handler = proc_dointvec, 93723f78d4aSIngo Molnar }, 93823f78d4aSIngo Molnar #endif 93910a0a8d4SJeremy Fitzhardinge { 94010a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 94110a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 94210a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 94310a0a8d4SJeremy Fitzhardinge .mode = 0644, 9446d456111SEric W. Biederman .proc_handler = proc_dostring, 94510a0a8d4SJeremy Fitzhardinge }, 9460b77f5bfSDavid Howells #ifdef CONFIG_KEYS 9470b77f5bfSDavid Howells { 9480b77f5bfSDavid Howells .procname = "keys", 9490b77f5bfSDavid Howells .mode = 0555, 9500b77f5bfSDavid Howells .child = key_sysctls, 9510b77f5bfSDavid Howells }, 9520b77f5bfSDavid Howells #endif 95331a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 95431a72bceSPaul E. McKenney { 95531a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 95631a72bceSPaul E. McKenney .data = &rcutorture_runnable, 95731a72bceSPaul E. McKenney .maxlen = sizeof(int), 95831a72bceSPaul E. McKenney .mode = 0644, 9596d456111SEric W. Biederman .proc_handler = proc_dointvec, 96031a72bceSPaul E. McKenney }, 96131a72bceSPaul E. McKenney #endif 962cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 963aa4a2218SVince Weaver /* 964aa4a2218SVince Weaver * User-space scripts rely on the existence of this file 965aa4a2218SVince Weaver * as a feature check for perf_events being enabled. 966aa4a2218SVince Weaver * 967aa4a2218SVince Weaver * So it's an ABI, do not remove! 968aa4a2218SVince Weaver */ 9691ccd1549SPeter Zijlstra { 970cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 971cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 972cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 9731ccd1549SPeter Zijlstra .mode = 0644, 9746d456111SEric W. Biederman .proc_handler = proc_dointvec, 9751ccd1549SPeter Zijlstra }, 976c5078f78SPeter Zijlstra { 977cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 978cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 979cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 980c5078f78SPeter Zijlstra .mode = 0644, 9816d456111SEric W. Biederman .proc_handler = proc_dointvec, 982c5078f78SPeter Zijlstra }, 983a78ac325SPeter Zijlstra { 984cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 985cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 986cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 987a78ac325SPeter Zijlstra .mode = 0644, 988163ec435SPeter Zijlstra .proc_handler = perf_proc_update_handler, 989a78ac325SPeter Zijlstra }, 9901ccd1549SPeter Zijlstra #endif 991dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 992dfec072eSVegard Nossum { 993dfec072eSVegard Nossum .procname = "kmemcheck", 994dfec072eSVegard Nossum .data = &kmemcheck_enabled, 995dfec072eSVegard Nossum .maxlen = sizeof(int), 996dfec072eSVegard Nossum .mode = 0644, 9976d456111SEric W. Biederman .proc_handler = proc_dointvec, 998dfec072eSVegard Nossum }, 999dfec072eSVegard Nossum #endif 1000cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 10015e605b64SJens Axboe { 10025e605b64SJens Axboe .procname = "blk_iopoll", 10035e605b64SJens Axboe .data = &blk_iopoll_enabled, 10045e605b64SJens Axboe .maxlen = sizeof(int), 10055e605b64SJens Axboe .mode = 0644, 10066d456111SEric W. Biederman .proc_handler = proc_dointvec, 10075e605b64SJens Axboe }, 1008cb684b5bSJens Axboe #endif 10096fce56ecSEric W. Biederman { } 10101da177e4SLinus Torvalds }; 10111da177e4SLinus Torvalds 1012d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 10131da177e4SLinus Torvalds { 10141da177e4SLinus Torvalds .procname = "overcommit_memory", 10151da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 10161da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 10171da177e4SLinus Torvalds .mode = 0644, 1018cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1019cb16e95fSPetr Holasek .extra1 = &zero, 1020cb16e95fSPetr Holasek .extra2 = &two, 10211da177e4SLinus Torvalds }, 10221da177e4SLinus Torvalds { 1023fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 1024fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 1025fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 1026fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 1027cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1028cb16e95fSPetr Holasek .extra1 = &zero, 1029cb16e95fSPetr Holasek .extra2 = &two, 1030fadd8fbdSKAMEZAWA Hiroyuki }, 1031fadd8fbdSKAMEZAWA Hiroyuki { 1032fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 1033fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 1034fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 1035fe071d7eSDavid Rientjes .mode = 0644, 10366d456111SEric W. Biederman .proc_handler = proc_dointvec, 1037fe071d7eSDavid Rientjes }, 1038fe071d7eSDavid Rientjes { 1039fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 1040fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 1041fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 1042fef1bdd6SDavid Rientjes .mode = 0644, 10436d456111SEric W. Biederman .proc_handler = proc_dointvec, 1044fef1bdd6SDavid Rientjes }, 1045fef1bdd6SDavid Rientjes { 10461da177e4SLinus Torvalds .procname = "overcommit_ratio", 10471da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 10481da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 10491da177e4SLinus Torvalds .mode = 0644, 10506d456111SEric W. Biederman .proc_handler = proc_dointvec, 10511da177e4SLinus Torvalds }, 10521da177e4SLinus Torvalds { 10531da177e4SLinus Torvalds .procname = "page-cluster", 10541da177e4SLinus Torvalds .data = &page_cluster, 10551da177e4SLinus Torvalds .maxlen = sizeof(int), 10561da177e4SLinus Torvalds .mode = 0644, 1057cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1058cb16e95fSPetr Holasek .extra1 = &zero, 10591da177e4SLinus Torvalds }, 10601da177e4SLinus Torvalds { 10611da177e4SLinus Torvalds .procname = "dirty_background_ratio", 10621da177e4SLinus Torvalds .data = &dirty_background_ratio, 10631da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 10641da177e4SLinus Torvalds .mode = 0644, 10656d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 10661da177e4SLinus Torvalds .extra1 = &zero, 10671da177e4SLinus Torvalds .extra2 = &one_hundred, 10681da177e4SLinus Torvalds }, 10691da177e4SLinus Torvalds { 10702da02997SDavid Rientjes .procname = "dirty_background_bytes", 10712da02997SDavid Rientjes .data = &dirty_background_bytes, 10722da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 10732da02997SDavid Rientjes .mode = 0644, 10746d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 1075fc3501d4SSven Wegener .extra1 = &one_ul, 10762da02997SDavid Rientjes }, 10772da02997SDavid Rientjes { 10781da177e4SLinus Torvalds .procname = "dirty_ratio", 10791da177e4SLinus Torvalds .data = &vm_dirty_ratio, 10801da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10811da177e4SLinus Torvalds .mode = 0644, 10826d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10831da177e4SLinus Torvalds .extra1 = &zero, 10841da177e4SLinus Torvalds .extra2 = &one_hundred, 10851da177e4SLinus Torvalds }, 10861da177e4SLinus Torvalds { 10872da02997SDavid Rientjes .procname = "dirty_bytes", 10882da02997SDavid Rientjes .data = &vm_dirty_bytes, 10892da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10902da02997SDavid Rientjes .mode = 0644, 10916d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10929e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10932da02997SDavid Rientjes }, 10942da02997SDavid Rientjes { 10951da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1096f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1097f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10981da177e4SLinus Torvalds .mode = 0644, 10996d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 11001da177e4SLinus Torvalds }, 11011da177e4SLinus Torvalds { 11021da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1103f6ef9438SBart Samwel .data = &dirty_expire_interval, 1104f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 11051da177e4SLinus Torvalds .mode = 0644, 1106cb16e95fSPetr Holasek .proc_handler = proc_dointvec_minmax, 1107cb16e95fSPetr Holasek .extra1 = &zero, 11081da177e4SLinus Torvalds }, 11091da177e4SLinus Torvalds { 11101da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 11111da177e4SLinus Torvalds .mode = 0444 /* read-only */, 11123965c9aeSWanpeng Li .proc_handler = pdflush_proc_obsolete, 11131da177e4SLinus Torvalds }, 11141da177e4SLinus Torvalds { 11151da177e4SLinus Torvalds .procname = "swappiness", 11161da177e4SLinus Torvalds .data = &vm_swappiness, 11171da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 11181da177e4SLinus Torvalds .mode = 0644, 11196d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 11201da177e4SLinus Torvalds .extra1 = &zero, 11211da177e4SLinus Torvalds .extra2 = &one_hundred, 11221da177e4SLinus Torvalds }, 11231da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 11241da177e4SLinus Torvalds { 11251da177e4SLinus Torvalds .procname = "nr_hugepages", 1126e5ff2159SAndi Kleen .data = NULL, 11271da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 11281da177e4SLinus Torvalds .mode = 0644, 11296d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 11301da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 11311da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 11321da177e4SLinus Torvalds }, 113306808b08SLee Schermerhorn #ifdef CONFIG_NUMA 113406808b08SLee Schermerhorn { 113506808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 113606808b08SLee Schermerhorn .data = NULL, 113706808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 113806808b08SLee Schermerhorn .mode = 0644, 113906808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 114006808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 114106808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 114206808b08SLee Schermerhorn }, 114306808b08SLee Schermerhorn #endif 11441da177e4SLinus Torvalds { 11451da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 11461da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 11471da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 11481da177e4SLinus Torvalds .mode = 0644, 11496d456111SEric W. Biederman .proc_handler = proc_dointvec, 11501da177e4SLinus Torvalds }, 1151396faf03SMel Gorman { 1152396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1153396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1154396faf03SMel Gorman .maxlen = sizeof(int), 1155396faf03SMel Gorman .mode = 0644, 11566d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1157396faf03SMel Gorman }, 115854f9f80dSAdam Litke { 1159d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1160e5ff2159SAndi Kleen .data = NULL, 1161e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1162d1c3fb1fSNishanth Aravamudan .mode = 0644, 11636d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1164e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1165e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1166d1c3fb1fSNishanth Aravamudan }, 11671da177e4SLinus Torvalds #endif 11681da177e4SLinus Torvalds { 11691da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 11701da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 11711da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 11721da177e4SLinus Torvalds .mode = 0644, 11736d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 11741da177e4SLinus Torvalds }, 11751da177e4SLinus Torvalds { 11769d0243bcSAndrew Morton .procname = "drop_caches", 11779d0243bcSAndrew Morton .data = &sysctl_drop_caches, 11789d0243bcSAndrew Morton .maxlen = sizeof(int), 11799d0243bcSAndrew Morton .mode = 0644, 11809d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 1181cb16e95fSPetr Holasek .extra1 = &one, 1182cb16e95fSPetr Holasek .extra2 = &three, 11839d0243bcSAndrew Morton }, 118476ab0f53SMel Gorman #ifdef CONFIG_COMPACTION 118576ab0f53SMel Gorman { 118676ab0f53SMel Gorman .procname = "compact_memory", 118776ab0f53SMel Gorman .data = &sysctl_compact_memory, 118876ab0f53SMel Gorman .maxlen = sizeof(int), 118976ab0f53SMel Gorman .mode = 0200, 119076ab0f53SMel Gorman .proc_handler = sysctl_compaction_handler, 119176ab0f53SMel Gorman }, 11925e771905SMel Gorman { 11935e771905SMel Gorman .procname = "extfrag_threshold", 11945e771905SMel Gorman .data = &sysctl_extfrag_threshold, 11955e771905SMel Gorman .maxlen = sizeof(int), 11965e771905SMel Gorman .mode = 0644, 11975e771905SMel Gorman .proc_handler = sysctl_extfrag_handler, 11985e771905SMel Gorman .extra1 = &min_extfrag_threshold, 11995e771905SMel Gorman .extra2 = &max_extfrag_threshold, 12005e771905SMel Gorman }, 12015e771905SMel Gorman 120276ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */ 12039d0243bcSAndrew Morton { 12041da177e4SLinus Torvalds .procname = "min_free_kbytes", 12051da177e4SLinus Torvalds .data = &min_free_kbytes, 12061da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 12071da177e4SLinus Torvalds .mode = 0644, 12086d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 12091da177e4SLinus Torvalds .extra1 = &zero, 12101da177e4SLinus Torvalds }, 12118ad4b1fbSRohit Seth { 12128ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 12138ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 12148ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 12158ad4b1fbSRohit Seth .mode = 0644, 12166d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 12178ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 12188ad4b1fbSRohit Seth }, 12191da177e4SLinus Torvalds #ifdef CONFIG_MMU 12201da177e4SLinus Torvalds { 12211da177e4SLinus Torvalds .procname = "max_map_count", 12221da177e4SLinus Torvalds .data = &sysctl_max_map_count, 12231da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 12241da177e4SLinus Torvalds .mode = 0644, 12253e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 122670da2340SAmerigo Wang .extra1 = &zero, 12271da177e4SLinus Torvalds }, 1228dd8632a1SPaul Mundt #else 1229dd8632a1SPaul Mundt { 1230dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1231dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1232dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1233dd8632a1SPaul Mundt .mode = 0644, 12346d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1235dd8632a1SPaul Mundt .extra1 = &zero, 1236dd8632a1SPaul Mundt }, 12371da177e4SLinus Torvalds #endif 12381da177e4SLinus Torvalds { 12391da177e4SLinus Torvalds .procname = "laptop_mode", 12401da177e4SLinus Torvalds .data = &laptop_mode, 12411da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 12421da177e4SLinus Torvalds .mode = 0644, 12436d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 12441da177e4SLinus Torvalds }, 12451da177e4SLinus Torvalds { 12461da177e4SLinus Torvalds .procname = "block_dump", 12471da177e4SLinus Torvalds .data = &block_dump, 12481da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 12491da177e4SLinus Torvalds .mode = 0644, 12506d456111SEric W. Biederman .proc_handler = proc_dointvec, 12511da177e4SLinus Torvalds .extra1 = &zero, 12521da177e4SLinus Torvalds }, 12531da177e4SLinus Torvalds { 12541da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 12551da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 12561da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 12571da177e4SLinus Torvalds .mode = 0644, 12586d456111SEric W. Biederman .proc_handler = proc_dointvec, 12591da177e4SLinus Torvalds .extra1 = &zero, 12601da177e4SLinus Torvalds }, 12611da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 12621da177e4SLinus Torvalds { 12631da177e4SLinus Torvalds .procname = "legacy_va_layout", 12641da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 12651da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 12661da177e4SLinus Torvalds .mode = 0644, 12676d456111SEric W. Biederman .proc_handler = proc_dointvec, 12681da177e4SLinus Torvalds .extra1 = &zero, 12691da177e4SLinus Torvalds }, 12701da177e4SLinus Torvalds #endif 12711743660bSChristoph Lameter #ifdef CONFIG_NUMA 12721743660bSChristoph Lameter { 12731743660bSChristoph Lameter .procname = "zone_reclaim_mode", 12741743660bSChristoph Lameter .data = &zone_reclaim_mode, 12751743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 12761743660bSChristoph Lameter .mode = 0644, 12776d456111SEric W. Biederman .proc_handler = proc_dointvec, 1278c84db23cSChristoph Lameter .extra1 = &zero, 12791743660bSChristoph Lameter }, 12809614634fSChristoph Lameter { 12819614634fSChristoph Lameter .procname = "min_unmapped_ratio", 12829614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 12839614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 12849614634fSChristoph Lameter .mode = 0644, 12856d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 12869614634fSChristoph Lameter .extra1 = &zero, 12879614634fSChristoph Lameter .extra2 = &one_hundred, 12889614634fSChristoph Lameter }, 12890ff38490SChristoph Lameter { 12900ff38490SChristoph Lameter .procname = "min_slab_ratio", 12910ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 12920ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 12930ff38490SChristoph Lameter .mode = 0644, 12946d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 12950ff38490SChristoph Lameter .extra1 = &zero, 12960ff38490SChristoph Lameter .extra2 = &one_hundred, 12970ff38490SChristoph Lameter }, 12981743660bSChristoph Lameter #endif 129977461ab3SChristoph Lameter #ifdef CONFIG_SMP 130077461ab3SChristoph Lameter { 130177461ab3SChristoph Lameter .procname = "stat_interval", 130277461ab3SChristoph Lameter .data = &sysctl_stat_interval, 130377461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 130477461ab3SChristoph Lameter .mode = 0644, 13056d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 130677461ab3SChristoph Lameter }, 130777461ab3SChristoph Lameter #endif 13086e141546SDavid Howells #ifdef CONFIG_MMU 1309ed032189SEric Paris { 1310ed032189SEric Paris .procname = "mmap_min_addr", 1311788084abSEric Paris .data = &dac_mmap_min_addr, 1312ed032189SEric Paris .maxlen = sizeof(unsigned long), 1313ed032189SEric Paris .mode = 0644, 13146d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1315ed032189SEric Paris }, 13166e141546SDavid Howells #endif 1317f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1318f0c0b2b8SKAMEZAWA Hiroyuki { 1319f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1320f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1321f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1322f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 13236d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1324f0c0b2b8SKAMEZAWA Hiroyuki }, 1325f0c0b2b8SKAMEZAWA Hiroyuki #endif 13262b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 13275c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1328e6e5494cSIngo Molnar { 1329e6e5494cSIngo Molnar .procname = "vdso_enabled", 1330e6e5494cSIngo Molnar .data = &vdso_enabled, 1331e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1332e6e5494cSIngo Molnar .mode = 0644, 13336d456111SEric W. Biederman .proc_handler = proc_dointvec, 1334e6e5494cSIngo Molnar .extra1 = &zero, 1335e6e5494cSIngo Molnar }, 1336e6e5494cSIngo Molnar #endif 1337195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1338195cf453SBron Gondwana { 1339195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1340195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1341195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1342195cf453SBron Gondwana .mode = 0644, 13436d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1344195cf453SBron Gondwana .extra1 = &zero, 1345195cf453SBron Gondwana .extra2 = &one, 1346195cf453SBron Gondwana }, 1347195cf453SBron Gondwana #endif 13484be6f6bbSPeter Zijlstra { 13494be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 13504be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 13514be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 13524be6f6bbSPeter Zijlstra .mode = 0644, 13536d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 13544be6f6bbSPeter Zijlstra }, 13556a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 13566a46079cSAndi Kleen { 13576a46079cSAndi Kleen .procname = "memory_failure_early_kill", 13586a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 13596a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 13606a46079cSAndi Kleen .mode = 0644, 13616d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13626a46079cSAndi Kleen .extra1 = &zero, 13636a46079cSAndi Kleen .extra2 = &one, 13646a46079cSAndi Kleen }, 13656a46079cSAndi Kleen { 13666a46079cSAndi Kleen .procname = "memory_failure_recovery", 13676a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 13686a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 13696a46079cSAndi Kleen .mode = 0644, 13706d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13716a46079cSAndi Kleen .extra1 = &zero, 13726a46079cSAndi Kleen .extra2 = &one, 13736a46079cSAndi Kleen }, 13746a46079cSAndi Kleen #endif 13756fce56ecSEric W. Biederman { } 13761da177e4SLinus Torvalds }; 13771da177e4SLinus Torvalds 13782abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1379d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 13806fce56ecSEric W. Biederman { } 13812abc26fcSEric W. Biederman }; 13822abc26fcSEric W. Biederman #endif 13832abc26fcSEric W. Biederman 1384d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 13851da177e4SLinus Torvalds { 13861da177e4SLinus Torvalds .procname = "inode-nr", 13871da177e4SLinus Torvalds .data = &inodes_stat, 13881da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 13891da177e4SLinus Torvalds .mode = 0444, 1390cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13911da177e4SLinus Torvalds }, 13921da177e4SLinus Torvalds { 13931da177e4SLinus Torvalds .procname = "inode-state", 13941da177e4SLinus Torvalds .data = &inodes_stat, 13951da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13961da177e4SLinus Torvalds .mode = 0444, 1397cffbc8aaSDave Chinner .proc_handler = proc_nr_inodes, 13981da177e4SLinus Torvalds }, 13991da177e4SLinus Torvalds { 14001da177e4SLinus Torvalds .procname = "file-nr", 14011da177e4SLinus Torvalds .data = &files_stat, 1402518de9b3SEric Dumazet .maxlen = sizeof(files_stat), 14031da177e4SLinus Torvalds .mode = 0444, 14046d456111SEric W. Biederman .proc_handler = proc_nr_files, 14051da177e4SLinus Torvalds }, 14061da177e4SLinus Torvalds { 14071da177e4SLinus Torvalds .procname = "file-max", 14081da177e4SLinus Torvalds .data = &files_stat.max_files, 1409518de9b3SEric Dumazet .maxlen = sizeof(files_stat.max_files), 14101da177e4SLinus Torvalds .mode = 0644, 1411518de9b3SEric Dumazet .proc_handler = proc_doulongvec_minmax, 14121da177e4SLinus Torvalds }, 14131da177e4SLinus Torvalds { 14149cfe015aSEric Dumazet .procname = "nr_open", 14159cfe015aSEric Dumazet .data = &sysctl_nr_open, 14169cfe015aSEric Dumazet .maxlen = sizeof(int), 14179cfe015aSEric Dumazet .mode = 0644, 14186d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1419eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1420eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 14219cfe015aSEric Dumazet }, 14229cfe015aSEric Dumazet { 14231da177e4SLinus Torvalds .procname = "dentry-state", 14241da177e4SLinus Torvalds .data = &dentry_stat, 14251da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 14261da177e4SLinus Torvalds .mode = 0444, 1427312d3ca8SChristoph Hellwig .proc_handler = proc_nr_dentry, 14281da177e4SLinus Torvalds }, 14291da177e4SLinus Torvalds { 14301da177e4SLinus Torvalds .procname = "overflowuid", 14311da177e4SLinus Torvalds .data = &fs_overflowuid, 14321da177e4SLinus Torvalds .maxlen = sizeof(int), 14331da177e4SLinus Torvalds .mode = 0644, 14346d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14351da177e4SLinus Torvalds .extra1 = &minolduid, 14361da177e4SLinus Torvalds .extra2 = &maxolduid, 14371da177e4SLinus Torvalds }, 14381da177e4SLinus Torvalds { 14391da177e4SLinus Torvalds .procname = "overflowgid", 14401da177e4SLinus Torvalds .data = &fs_overflowgid, 14411da177e4SLinus Torvalds .maxlen = sizeof(int), 14421da177e4SLinus Torvalds .mode = 0644, 14436d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14441da177e4SLinus Torvalds .extra1 = &minolduid, 14451da177e4SLinus Torvalds .extra2 = &maxolduid, 14461da177e4SLinus Torvalds }, 1447bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14481da177e4SLinus Torvalds { 14491da177e4SLinus Torvalds .procname = "leases-enable", 14501da177e4SLinus Torvalds .data = &leases_enable, 14511da177e4SLinus Torvalds .maxlen = sizeof(int), 14521da177e4SLinus Torvalds .mode = 0644, 14536d456111SEric W. Biederman .proc_handler = proc_dointvec, 14541da177e4SLinus Torvalds }, 1455bfcd17a6SThomas Petazzoni #endif 14561da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 14571da177e4SLinus Torvalds { 14581da177e4SLinus Torvalds .procname = "dir-notify-enable", 14591da177e4SLinus Torvalds .data = &dir_notify_enable, 14601da177e4SLinus Torvalds .maxlen = sizeof(int), 14611da177e4SLinus Torvalds .mode = 0644, 14626d456111SEric W. Biederman .proc_handler = proc_dointvec, 14631da177e4SLinus Torvalds }, 14641da177e4SLinus Torvalds #endif 14651da177e4SLinus Torvalds #ifdef CONFIG_MMU 1466bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 14671da177e4SLinus Torvalds { 14681da177e4SLinus Torvalds .procname = "lease-break-time", 14691da177e4SLinus Torvalds .data = &lease_break_time, 14701da177e4SLinus Torvalds .maxlen = sizeof(int), 14711da177e4SLinus Torvalds .mode = 0644, 14726d456111SEric W. Biederman .proc_handler = proc_dointvec, 14731da177e4SLinus Torvalds }, 1474bfcd17a6SThomas Petazzoni #endif 1475ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 14761da177e4SLinus Torvalds { 14771da177e4SLinus Torvalds .procname = "aio-nr", 14781da177e4SLinus Torvalds .data = &aio_nr, 14791da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 14801da177e4SLinus Torvalds .mode = 0444, 14816d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14821da177e4SLinus Torvalds }, 14831da177e4SLinus Torvalds { 14841da177e4SLinus Torvalds .procname = "aio-max-nr", 14851da177e4SLinus Torvalds .data = &aio_max_nr, 14861da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 14871da177e4SLinus Torvalds .mode = 0644, 14886d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 14891da177e4SLinus Torvalds }, 1490ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 14912d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 14920399cb08SRobert Love { 14930399cb08SRobert Love .procname = "inotify", 14940399cb08SRobert Love .mode = 0555, 14950399cb08SRobert Love .child = inotify_table, 14960399cb08SRobert Love }, 14970399cb08SRobert Love #endif 14987ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14997ef9964eSDavide Libenzi { 15007ef9964eSDavide Libenzi .procname = "epoll", 15017ef9964eSDavide Libenzi .mode = 0555, 15027ef9964eSDavide Libenzi .child = epoll_table, 15037ef9964eSDavide Libenzi }, 15047ef9964eSDavide Libenzi #endif 15051da177e4SLinus Torvalds #endif 1506d6e71144SAlan Cox { 1507800179c9SKees Cook .procname = "protected_symlinks", 1508800179c9SKees Cook .data = &sysctl_protected_symlinks, 1509800179c9SKees Cook .maxlen = sizeof(int), 1510800179c9SKees Cook .mode = 0600, 1511800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 1512800179c9SKees Cook .extra1 = &zero, 1513800179c9SKees Cook .extra2 = &one, 1514800179c9SKees Cook }, 1515800179c9SKees Cook { 1516800179c9SKees Cook .procname = "protected_hardlinks", 1517800179c9SKees Cook .data = &sysctl_protected_hardlinks, 1518800179c9SKees Cook .maxlen = sizeof(int), 1519800179c9SKees Cook .mode = 0600, 1520800179c9SKees Cook .proc_handler = proc_dointvec_minmax, 1521800179c9SKees Cook .extra1 = &zero, 1522800179c9SKees Cook .extra2 = &one, 1523800179c9SKees Cook }, 1524800179c9SKees Cook { 1525d6e71144SAlan Cox .procname = "suid_dumpable", 1526d6e71144SAlan Cox .data = &suid_dumpable, 1527d6e71144SAlan Cox .maxlen = sizeof(int), 1528d6e71144SAlan Cox .mode = 0644, 152954b50199SKees Cook .proc_handler = proc_dointvec_minmax_coredump, 15308e654fbaSMatthew Wilcox .extra1 = &zero, 15318e654fbaSMatthew Wilcox .extra2 = &two, 1532d6e71144SAlan Cox }, 15332abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 15342abc26fcSEric W. Biederman { 15352abc26fcSEric W. Biederman .procname = "binfmt_misc", 15362abc26fcSEric W. Biederman .mode = 0555, 15372abc26fcSEric W. Biederman .child = binfmt_misc_table, 15382abc26fcSEric W. Biederman }, 15392abc26fcSEric W. Biederman #endif 1540b492e95bSJens Axboe { 1541ff9da691SJens Axboe .procname = "pipe-max-size", 1542ff9da691SJens Axboe .data = &pipe_max_size, 1543b492e95bSJens Axboe .maxlen = sizeof(int), 1544b492e95bSJens Axboe .mode = 0644, 1545ff9da691SJens Axboe .proc_handler = &pipe_proc_fn, 1546ff9da691SJens Axboe .extra1 = &pipe_min_size, 1547b492e95bSJens Axboe }, 15486fce56ecSEric W. Biederman { } 15491da177e4SLinus Torvalds }; 15501da177e4SLinus Torvalds 1551d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 15527ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE 1553abd4f750SMasoud Asgharifard Sharbiani { 1554abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1555abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1556abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1557abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1558abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1559abd4f750SMasoud Asgharifard Sharbiani }, 1560abd4f750SMasoud Asgharifard Sharbiani #endif 1561b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1562b2be84dfSMasami Hiramatsu { 1563b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1564b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1565b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1566b2be84dfSMasami Hiramatsu .mode = 0644, 1567b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1568b2be84dfSMasami Hiramatsu .extra1 = &zero, 1569b2be84dfSMasami Hiramatsu .extra2 = &one, 1570b2be84dfSMasami Hiramatsu }, 1571b2be84dfSMasami Hiramatsu #endif 15726fce56ecSEric W. Biederman { } 15731da177e4SLinus Torvalds }; 15741da177e4SLinus Torvalds 1575d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 15766fce56ecSEric W. Biederman { } 15771da177e4SLinus Torvalds }; 15781da177e4SLinus Torvalds 1579de4e83bdSEric W. Biederman int __init sysctl_init(void) 1580330d57fbSAl Viro { 1581fd4b616bSSteven Rostedt struct ctl_table_header *hdr; 1582fd4b616bSSteven Rostedt 1583fd4b616bSSteven Rostedt hdr = register_sysctl_table(sysctl_base_table); 1584fd4b616bSSteven Rostedt kmemleak_not_leak(hdr); 1585330d57fbSAl Viro return 0; 1586f7e6ced4SAl Viro } 1587f7e6ced4SAl Viro 1588b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1589b89a8171SEric W. Biederman 15901da177e4SLinus Torvalds /* 15911da177e4SLinus Torvalds * /proc/sys support 15921da177e4SLinus Torvalds */ 15931da177e4SLinus Torvalds 1594b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 15951da177e4SLinus Torvalds 1596b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 15978d65af78SAlexey Dobriyan void __user *buffer, 1598b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1599f5dd3d6fSSam Vilain { 1600f5dd3d6fSSam Vilain size_t len; 1601f5dd3d6fSSam Vilain char __user *p; 1602f5dd3d6fSSam Vilain char c; 1603f5dd3d6fSSam Vilain 16048d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1605f5dd3d6fSSam Vilain *lenp = 0; 1606f5dd3d6fSSam Vilain return 0; 1607f5dd3d6fSSam Vilain } 1608f5dd3d6fSSam Vilain 1609f5dd3d6fSSam Vilain if (write) { 1610f5dd3d6fSSam Vilain len = 0; 1611f5dd3d6fSSam Vilain p = buffer; 1612f5dd3d6fSSam Vilain while (len < *lenp) { 1613f5dd3d6fSSam Vilain if (get_user(c, p++)) 1614f5dd3d6fSSam Vilain return -EFAULT; 1615f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1616f5dd3d6fSSam Vilain break; 1617f5dd3d6fSSam Vilain len++; 1618f5dd3d6fSSam Vilain } 1619f5dd3d6fSSam Vilain if (len >= maxlen) 1620f5dd3d6fSSam Vilain len = maxlen-1; 1621f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1622f5dd3d6fSSam Vilain return -EFAULT; 1623f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 1624f5dd3d6fSSam Vilain *ppos += *lenp; 1625f5dd3d6fSSam Vilain } else { 1626f5dd3d6fSSam Vilain len = strlen(data); 1627f5dd3d6fSSam Vilain if (len > maxlen) 1628f5dd3d6fSSam Vilain len = maxlen; 16298d060877SOleg Nesterov 16308d060877SOleg Nesterov if (*ppos > len) { 16318d060877SOleg Nesterov *lenp = 0; 16328d060877SOleg Nesterov return 0; 16338d060877SOleg Nesterov } 16348d060877SOleg Nesterov 16358d060877SOleg Nesterov data += *ppos; 16368d060877SOleg Nesterov len -= *ppos; 16378d060877SOleg Nesterov 1638f5dd3d6fSSam Vilain if (len > *lenp) 1639f5dd3d6fSSam Vilain len = *lenp; 1640f5dd3d6fSSam Vilain if (len) 1641f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 1642f5dd3d6fSSam Vilain return -EFAULT; 1643f5dd3d6fSSam Vilain if (len < *lenp) { 1644f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 1645f5dd3d6fSSam Vilain return -EFAULT; 1646f5dd3d6fSSam Vilain len++; 1647f5dd3d6fSSam Vilain } 1648f5dd3d6fSSam Vilain *lenp = len; 1649f5dd3d6fSSam Vilain *ppos += len; 1650f5dd3d6fSSam Vilain } 1651f5dd3d6fSSam Vilain return 0; 1652f5dd3d6fSSam Vilain } 1653f5dd3d6fSSam Vilain 16541da177e4SLinus Torvalds /** 16551da177e4SLinus Torvalds * proc_dostring - read a string sysctl 16561da177e4SLinus Torvalds * @table: the sysctl table 16571da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 16581da177e4SLinus Torvalds * @buffer: the user buffer 16591da177e4SLinus Torvalds * @lenp: the size of the user buffer 16601da177e4SLinus Torvalds * @ppos: file position 16611da177e4SLinus Torvalds * 16621da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 16631da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 16641da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 16651da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 16661da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 16671da177e4SLinus Torvalds * not large enough. 16681da177e4SLinus Torvalds * 16691da177e4SLinus Torvalds * Returns 0 on success. 16701da177e4SLinus Torvalds */ 16718d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 16721da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 16731da177e4SLinus Torvalds { 16748d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 1675f5dd3d6fSSam Vilain buffer, lenp, ppos); 16761da177e4SLinus Torvalds } 16771da177e4SLinus Torvalds 167800b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 167900b7c339SAmerigo Wang { 168000b7c339SAmerigo Wang size_t ret; 168100b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 168200b7c339SAmerigo Wang ret = tmp - *buf; 168300b7c339SAmerigo Wang *buf = tmp; 168400b7c339SAmerigo Wang return ret; 168500b7c339SAmerigo Wang } 16861da177e4SLinus Torvalds 16879f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v) 16889f977fb7SOctavian Purdila { 16899f977fb7SOctavian Purdila while (*size) { 16909f977fb7SOctavian Purdila if (**buf != v) 16919f977fb7SOctavian Purdila break; 16929f977fb7SOctavian Purdila (*size)--; 16939f977fb7SOctavian Purdila (*buf)++; 16949f977fb7SOctavian Purdila } 16959f977fb7SOctavian Purdila } 16969f977fb7SOctavian Purdila 169700b7c339SAmerigo Wang #define TMPBUFLEN 22 169800b7c339SAmerigo Wang /** 16990fc377bdSRandy Dunlap * proc_get_long - reads an ASCII formatted integer from a user buffer 170000b7c339SAmerigo Wang * 17010fc377bdSRandy Dunlap * @buf: a kernel buffer 17020fc377bdSRandy Dunlap * @size: size of the kernel buffer 17030fc377bdSRandy Dunlap * @val: this is where the number will be stored 17040fc377bdSRandy Dunlap * @neg: set to %TRUE if number is negative 17050fc377bdSRandy Dunlap * @perm_tr: a vector which contains the allowed trailers 17060fc377bdSRandy Dunlap * @perm_tr_len: size of the perm_tr vector 17070fc377bdSRandy Dunlap * @tr: pointer to store the trailer character 170800b7c339SAmerigo Wang * 17090fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 17100fc377bdSRandy Dunlap * the amount of bytes read. If @tr is non-NULL and a trailing 17110fc377bdSRandy Dunlap * character exists (size is non-zero after returning from this 17120fc377bdSRandy Dunlap * function), @tr is updated with the trailing character. 171300b7c339SAmerigo Wang */ 171400b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 171500b7c339SAmerigo Wang unsigned long *val, bool *neg, 171600b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 171700b7c339SAmerigo Wang { 171800b7c339SAmerigo Wang int len; 171900b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 172000b7c339SAmerigo Wang 172100b7c339SAmerigo Wang if (!*size) 172200b7c339SAmerigo Wang return -EINVAL; 172300b7c339SAmerigo Wang 172400b7c339SAmerigo Wang len = *size; 172500b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 172600b7c339SAmerigo Wang len = TMPBUFLEN - 1; 172700b7c339SAmerigo Wang 172800b7c339SAmerigo Wang memcpy(tmp, *buf, len); 172900b7c339SAmerigo Wang 173000b7c339SAmerigo Wang tmp[len] = 0; 173100b7c339SAmerigo Wang p = tmp; 173200b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 173300b7c339SAmerigo Wang *neg = true; 173400b7c339SAmerigo Wang p++; 173500b7c339SAmerigo Wang } else 173600b7c339SAmerigo Wang *neg = false; 173700b7c339SAmerigo Wang if (!isdigit(*p)) 173800b7c339SAmerigo Wang return -EINVAL; 173900b7c339SAmerigo Wang 174000b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 174100b7c339SAmerigo Wang 174200b7c339SAmerigo Wang len = p - tmp; 174300b7c339SAmerigo Wang 174400b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 174500b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 174600b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 174700b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 174800b7c339SAmerigo Wang return -EINVAL; 174900b7c339SAmerigo Wang 175000b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 175100b7c339SAmerigo Wang return -EINVAL; 175200b7c339SAmerigo Wang 175300b7c339SAmerigo Wang if (tr && (len < *size)) 175400b7c339SAmerigo Wang *tr = *p; 175500b7c339SAmerigo Wang 175600b7c339SAmerigo Wang *buf += len; 175700b7c339SAmerigo Wang *size -= len; 175800b7c339SAmerigo Wang 175900b7c339SAmerigo Wang return 0; 176000b7c339SAmerigo Wang } 176100b7c339SAmerigo Wang 176200b7c339SAmerigo Wang /** 17630fc377bdSRandy Dunlap * proc_put_long - converts an integer to a decimal ASCII formatted string 176400b7c339SAmerigo Wang * 17650fc377bdSRandy Dunlap * @buf: the user buffer 17660fc377bdSRandy Dunlap * @size: the size of the user buffer 17670fc377bdSRandy Dunlap * @val: the integer to be converted 17680fc377bdSRandy Dunlap * @neg: sign of the number, %TRUE for negative 176900b7c339SAmerigo Wang * 17700fc377bdSRandy Dunlap * In case of success %0 is returned and @buf and @size are updated with 17710fc377bdSRandy Dunlap * the amount of bytes written. 177200b7c339SAmerigo Wang */ 177300b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 177400b7c339SAmerigo Wang bool neg) 177500b7c339SAmerigo Wang { 177600b7c339SAmerigo Wang int len; 177700b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 177800b7c339SAmerigo Wang 177900b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 178000b7c339SAmerigo Wang len = strlen(tmp); 178100b7c339SAmerigo Wang if (len > *size) 178200b7c339SAmerigo Wang len = *size; 178300b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 178400b7c339SAmerigo Wang return -EFAULT; 178500b7c339SAmerigo Wang *size -= len; 178600b7c339SAmerigo Wang *buf += len; 178700b7c339SAmerigo Wang return 0; 178800b7c339SAmerigo Wang } 178900b7c339SAmerigo Wang #undef TMPBUFLEN 179000b7c339SAmerigo Wang 179100b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 179200b7c339SAmerigo Wang { 179300b7c339SAmerigo Wang if (*size) { 179400b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 179500b7c339SAmerigo Wang if (put_user(c, *buffer)) 179600b7c339SAmerigo Wang return -EFAULT; 179700b7c339SAmerigo Wang (*size)--, (*buffer)++; 179800b7c339SAmerigo Wang *buf = *buffer; 179900b7c339SAmerigo Wang } 180000b7c339SAmerigo Wang return 0; 180100b7c339SAmerigo Wang } 180200b7c339SAmerigo Wang 180300b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 18041da177e4SLinus Torvalds int *valp, 18051da177e4SLinus Torvalds int write, void *data) 18061da177e4SLinus Torvalds { 18071da177e4SLinus Torvalds if (write) { 18081da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 18091da177e4SLinus Torvalds } else { 18101da177e4SLinus Torvalds int val = *valp; 18111da177e4SLinus Torvalds if (val < 0) { 181200b7c339SAmerigo Wang *negp = true; 18131da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 18141da177e4SLinus Torvalds } else { 181500b7c339SAmerigo Wang *negp = false; 18161da177e4SLinus Torvalds *lvalp = (unsigned long)val; 18171da177e4SLinus Torvalds } 18181da177e4SLinus Torvalds } 18191da177e4SLinus Torvalds return 0; 18201da177e4SLinus Torvalds } 18211da177e4SLinus Torvalds 182200b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 182300b7c339SAmerigo Wang 1824d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 18258d65af78SAlexey Dobriyan int write, void __user *buffer, 1826fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 182700b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 18281da177e4SLinus Torvalds int write, void *data), 18291da177e4SLinus Torvalds void *data) 18301da177e4SLinus Torvalds { 183100b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 183200b7c339SAmerigo Wang unsigned long page = 0; 183300b7c339SAmerigo Wang size_t left; 183400b7c339SAmerigo Wang char *kbuf; 18351da177e4SLinus Torvalds 183600b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 18371da177e4SLinus Torvalds *lenp = 0; 18381da177e4SLinus Torvalds return 0; 18391da177e4SLinus Torvalds } 18401da177e4SLinus Torvalds 1841fcfbd547SKirill Korotaev i = (int *) tbl_data; 18421da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 18431da177e4SLinus Torvalds left = *lenp; 18441da177e4SLinus Torvalds 18451da177e4SLinus Torvalds if (!conv) 18461da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 18471da177e4SLinus Torvalds 184800b7c339SAmerigo Wang if (write) { 184900b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 185000b7c339SAmerigo Wang left = PAGE_SIZE - 1; 185100b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 185200b7c339SAmerigo Wang kbuf = (char *) page; 185300b7c339SAmerigo Wang if (!kbuf) 185400b7c339SAmerigo Wang return -ENOMEM; 185500b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 185600b7c339SAmerigo Wang err = -EFAULT; 185700b7c339SAmerigo Wang goto free; 185800b7c339SAmerigo Wang } 185900b7c339SAmerigo Wang kbuf[left] = 0; 186000b7c339SAmerigo Wang } 186100b7c339SAmerigo Wang 18621da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 186300b7c339SAmerigo Wang unsigned long lval; 186400b7c339SAmerigo Wang bool neg; 186500b7c339SAmerigo Wang 18661da177e4SLinus Torvalds if (write) { 186700b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 186800b7c339SAmerigo Wang 1869563b0467SJ. R. Okajima if (!left) 1870563b0467SJ. R. Okajima break; 187100b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 187200b7c339SAmerigo Wang proc_wspace_sep, 187300b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 187400b7c339SAmerigo Wang if (err) 18751da177e4SLinus Torvalds break; 187600b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 187700b7c339SAmerigo Wang err = -EINVAL; 187800b7c339SAmerigo Wang break; 18791da177e4SLinus Torvalds } 18801da177e4SLinus Torvalds } else { 188100b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 188200b7c339SAmerigo Wang err = -EINVAL; 188300b7c339SAmerigo Wang break; 188400b7c339SAmerigo Wang } 18851da177e4SLinus Torvalds if (!first) 188600b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 188700b7c339SAmerigo Wang if (err) 18881da177e4SLinus Torvalds break; 188900b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 189000b7c339SAmerigo Wang if (err) 189100b7c339SAmerigo Wang break; 18921da177e4SLinus Torvalds } 18931da177e4SLinus Torvalds } 18941da177e4SLinus Torvalds 189500b7c339SAmerigo Wang if (!write && !first && left && !err) 189600b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 1897563b0467SJ. R. Okajima if (write && !err && left) 189800b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 189900b7c339SAmerigo Wang free: 19001da177e4SLinus Torvalds if (write) { 190100b7c339SAmerigo Wang free_page(page); 190200b7c339SAmerigo Wang if (first) 190300b7c339SAmerigo Wang return err ? : -EINVAL; 19041da177e4SLinus Torvalds } 19051da177e4SLinus Torvalds *lenp -= left; 19061da177e4SLinus Torvalds *ppos += *lenp; 190700b7c339SAmerigo Wang return err; 19081da177e4SLinus Torvalds } 19091da177e4SLinus Torvalds 19108d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 1911fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 191200b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 1913fcfbd547SKirill Korotaev int write, void *data), 1914fcfbd547SKirill Korotaev void *data) 1915fcfbd547SKirill Korotaev { 19168d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 1917fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 1918fcfbd547SKirill Korotaev } 1919fcfbd547SKirill Korotaev 19201da177e4SLinus Torvalds /** 19211da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 19221da177e4SLinus Torvalds * @table: the sysctl table 19231da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 19241da177e4SLinus Torvalds * @buffer: the user buffer 19251da177e4SLinus Torvalds * @lenp: the size of the user buffer 19261da177e4SLinus Torvalds * @ppos: file position 19271da177e4SLinus Torvalds * 19281da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 19291da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 19301da177e4SLinus Torvalds * 19311da177e4SLinus Torvalds * Returns 0 on success. 19321da177e4SLinus Torvalds */ 19338d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 19341da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 19351da177e4SLinus Torvalds { 19368d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 19371da177e4SLinus Torvalds NULL,NULL); 19381da177e4SLinus Torvalds } 19391da177e4SLinus Torvalds 194034f5a398STheodore Ts'o /* 194134f5a398STheodore Ts'o * Taint values can only be increased 194225ddbb18SAndi Kleen * This means we can safely use a temporary. 194334f5a398STheodore Ts'o */ 19448d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 194534f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 194634f5a398STheodore Ts'o { 194725ddbb18SAndi Kleen struct ctl_table t; 194825ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 194925ddbb18SAndi Kleen int err; 195034f5a398STheodore Ts'o 195191fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 195234f5a398STheodore Ts'o return -EPERM; 195334f5a398STheodore Ts'o 195425ddbb18SAndi Kleen t = *table; 195525ddbb18SAndi Kleen t.data = &tmptaint; 19568d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 195725ddbb18SAndi Kleen if (err < 0) 195825ddbb18SAndi Kleen return err; 195925ddbb18SAndi Kleen 196025ddbb18SAndi Kleen if (write) { 196125ddbb18SAndi Kleen /* 196225ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 196325ddbb18SAndi Kleen * to everyone's atomic.h for this 196425ddbb18SAndi Kleen */ 196525ddbb18SAndi Kleen int i; 196625ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 196725ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 196825ddbb18SAndi Kleen add_taint(i); 196925ddbb18SAndi Kleen } 197025ddbb18SAndi Kleen } 197125ddbb18SAndi Kleen 197225ddbb18SAndi Kleen return err; 197334f5a398STheodore Ts'o } 197434f5a398STheodore Ts'o 1975bfdc0b49SRichard Weinberger #ifdef CONFIG_PRINTK 1976620f6e8eSKees Cook static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, 1977bfdc0b49SRichard Weinberger void __user *buffer, size_t *lenp, loff_t *ppos) 1978bfdc0b49SRichard Weinberger { 1979bfdc0b49SRichard Weinberger if (write && !capable(CAP_SYS_ADMIN)) 1980bfdc0b49SRichard Weinberger return -EPERM; 1981bfdc0b49SRichard Weinberger 1982bfdc0b49SRichard Weinberger return proc_dointvec_minmax(table, write, buffer, lenp, ppos); 1983bfdc0b49SRichard Weinberger } 1984bfdc0b49SRichard Weinberger #endif 1985bfdc0b49SRichard Weinberger 19861da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 19871da177e4SLinus Torvalds int *min; 19881da177e4SLinus Torvalds int *max; 19891da177e4SLinus Torvalds }; 19901da177e4SLinus Torvalds 199100b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 19921da177e4SLinus Torvalds int *valp, 19931da177e4SLinus Torvalds int write, void *data) 19941da177e4SLinus Torvalds { 19951da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 19961da177e4SLinus Torvalds if (write) { 19971da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 19981da177e4SLinus Torvalds if ((param->min && *param->min > val) || 19991da177e4SLinus Torvalds (param->max && *param->max < val)) 20001da177e4SLinus Torvalds return -EINVAL; 20011da177e4SLinus Torvalds *valp = val; 20021da177e4SLinus Torvalds } else { 20031da177e4SLinus Torvalds int val = *valp; 20041da177e4SLinus Torvalds if (val < 0) { 200500b7c339SAmerigo Wang *negp = true; 20061da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 20071da177e4SLinus Torvalds } else { 200800b7c339SAmerigo Wang *negp = false; 20091da177e4SLinus Torvalds *lvalp = (unsigned long)val; 20101da177e4SLinus Torvalds } 20111da177e4SLinus Torvalds } 20121da177e4SLinus Torvalds return 0; 20131da177e4SLinus Torvalds } 20141da177e4SLinus Torvalds 20151da177e4SLinus Torvalds /** 20161da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 20171da177e4SLinus Torvalds * @table: the sysctl table 20181da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20191da177e4SLinus Torvalds * @buffer: the user buffer 20201da177e4SLinus Torvalds * @lenp: the size of the user buffer 20211da177e4SLinus Torvalds * @ppos: file position 20221da177e4SLinus Torvalds * 20231da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 20241da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 20251da177e4SLinus Torvalds * 20261da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 20271da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 20281da177e4SLinus Torvalds * 20291da177e4SLinus Torvalds * Returns 0 on success. 20301da177e4SLinus Torvalds */ 20318d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 20321da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20331da177e4SLinus Torvalds { 20341da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 20351da177e4SLinus Torvalds .min = (int *) table->extra1, 20361da177e4SLinus Torvalds .max = (int *) table->extra2, 20371da177e4SLinus Torvalds }; 20388d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 20391da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 20401da177e4SLinus Torvalds } 20411da177e4SLinus Torvalds 204254b50199SKees Cook static void validate_coredump_safety(void) 204354b50199SKees Cook { 2044046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 204554b50199SKees Cook if (suid_dumpable == SUID_DUMPABLE_SAFE && 204654b50199SKees Cook core_pattern[0] != '/' && core_pattern[0] != '|') { 204754b50199SKees Cook printk(KERN_WARNING "Unsafe core_pattern used with "\ 204854b50199SKees Cook "suid_dumpable=2. Pipe handler or fully qualified "\ 204954b50199SKees Cook "core dump path required.\n"); 205054b50199SKees Cook } 2051046d662fSAlex Kelly #endif 205254b50199SKees Cook } 205354b50199SKees Cook 205454b50199SKees Cook static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, 205554b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos) 205654b50199SKees Cook { 205754b50199SKees Cook int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 205854b50199SKees Cook if (!error) 205954b50199SKees Cook validate_coredump_safety(); 206054b50199SKees Cook return error; 206154b50199SKees Cook } 206254b50199SKees Cook 2063046d662fSAlex Kelly #ifdef CONFIG_COREDUMP 206454b50199SKees Cook static int proc_dostring_coredump(struct ctl_table *table, int write, 206554b50199SKees Cook void __user *buffer, size_t *lenp, loff_t *ppos) 206654b50199SKees Cook { 206754b50199SKees Cook int error = proc_dostring(table, write, buffer, lenp, ppos); 206854b50199SKees Cook if (!error) 206954b50199SKees Cook validate_coredump_safety(); 207054b50199SKees Cook return error; 207154b50199SKees Cook } 2072046d662fSAlex Kelly #endif 207354b50199SKees Cook 2074d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 20751da177e4SLinus Torvalds void __user *buffer, 20761da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 20771da177e4SLinus Torvalds unsigned long convmul, 20781da177e4SLinus Torvalds unsigned long convdiv) 20791da177e4SLinus Torvalds { 208000b7c339SAmerigo Wang unsigned long *i, *min, *max; 208100b7c339SAmerigo Wang int vleft, first = 1, err = 0; 208200b7c339SAmerigo Wang unsigned long page = 0; 208300b7c339SAmerigo Wang size_t left; 208400b7c339SAmerigo Wang char *kbuf; 20851da177e4SLinus Torvalds 208600b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 20871da177e4SLinus Torvalds *lenp = 0; 20881da177e4SLinus Torvalds return 0; 20891da177e4SLinus Torvalds } 20901da177e4SLinus Torvalds 2091fcfbd547SKirill Korotaev i = (unsigned long *) data; 20921da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 20931da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 20941da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 20951da177e4SLinus Torvalds left = *lenp; 20961da177e4SLinus Torvalds 20971da177e4SLinus Torvalds if (write) { 209800b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 209900b7c339SAmerigo Wang left = PAGE_SIZE - 1; 210000b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 210100b7c339SAmerigo Wang kbuf = (char *) page; 210200b7c339SAmerigo Wang if (!kbuf) 210300b7c339SAmerigo Wang return -ENOMEM; 210400b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 210500b7c339SAmerigo Wang err = -EFAULT; 210600b7c339SAmerigo Wang goto free; 21071da177e4SLinus Torvalds } 210800b7c339SAmerigo Wang kbuf[left] = 0; 21091da177e4SLinus Torvalds } 21101da177e4SLinus Torvalds 211127b3d80aSEric Dumazet for (; left && vleft--; i++, first = 0) { 211200b7c339SAmerigo Wang unsigned long val; 211300b7c339SAmerigo Wang 211400b7c339SAmerigo Wang if (write) { 211500b7c339SAmerigo Wang bool neg; 211600b7c339SAmerigo Wang 211700b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 211800b7c339SAmerigo Wang 211900b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 212000b7c339SAmerigo Wang proc_wspace_sep, 212100b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 212200b7c339SAmerigo Wang if (err) 212300b7c339SAmerigo Wang break; 21241da177e4SLinus Torvalds if (neg) 21251da177e4SLinus Torvalds continue; 21261da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 21271da177e4SLinus Torvalds continue; 21281da177e4SLinus Torvalds *i = val; 21291da177e4SLinus Torvalds } else { 213000b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 21311da177e4SLinus Torvalds if (!first) 213200b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 213300b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 213400b7c339SAmerigo Wang if (err) 213500b7c339SAmerigo Wang break; 21361da177e4SLinus Torvalds } 21371da177e4SLinus Torvalds } 21381da177e4SLinus Torvalds 213900b7c339SAmerigo Wang if (!write && !first && left && !err) 214000b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 214100b7c339SAmerigo Wang if (write && !err) 214200b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 214300b7c339SAmerigo Wang free: 21441da177e4SLinus Torvalds if (write) { 214500b7c339SAmerigo Wang free_page(page); 214600b7c339SAmerigo Wang if (first) 214700b7c339SAmerigo Wang return err ? : -EINVAL; 21481da177e4SLinus Torvalds } 21491da177e4SLinus Torvalds *lenp -= left; 21501da177e4SLinus Torvalds *ppos += *lenp; 215100b7c339SAmerigo Wang return err; 21521da177e4SLinus Torvalds } 21531da177e4SLinus Torvalds 2154d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2155fcfbd547SKirill Korotaev void __user *buffer, 2156fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2157fcfbd547SKirill Korotaev unsigned long convmul, 2158fcfbd547SKirill Korotaev unsigned long convdiv) 2159fcfbd547SKirill Korotaev { 2160fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 21618d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2162fcfbd547SKirill Korotaev } 2163fcfbd547SKirill Korotaev 21641da177e4SLinus Torvalds /** 21651da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 21661da177e4SLinus Torvalds * @table: the sysctl table 21671da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21681da177e4SLinus Torvalds * @buffer: the user buffer 21691da177e4SLinus Torvalds * @lenp: the size of the user buffer 21701da177e4SLinus Torvalds * @ppos: file position 21711da177e4SLinus Torvalds * 21721da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 21731da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 21741da177e4SLinus Torvalds * 21751da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 21761da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 21771da177e4SLinus Torvalds * 21781da177e4SLinus Torvalds * Returns 0 on success. 21791da177e4SLinus Torvalds */ 21808d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 21811da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21821da177e4SLinus Torvalds { 21838d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 21841da177e4SLinus Torvalds } 21851da177e4SLinus Torvalds 21861da177e4SLinus Torvalds /** 21871da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 21881da177e4SLinus Torvalds * @table: the sysctl table 21891da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 21901da177e4SLinus Torvalds * @buffer: the user buffer 21911da177e4SLinus Torvalds * @lenp: the size of the user buffer 21921da177e4SLinus Torvalds * @ppos: file position 21931da177e4SLinus Torvalds * 21941da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 21951da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 21961da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 21971da177e4SLinus Torvalds * 21981da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 21991da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 22001da177e4SLinus Torvalds * 22011da177e4SLinus Torvalds * Returns 0 on success. 22021da177e4SLinus Torvalds */ 2203d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 22041da177e4SLinus Torvalds void __user *buffer, 22051da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 22061da177e4SLinus Torvalds { 22078d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 22081da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 22091da177e4SLinus Torvalds } 22101da177e4SLinus Torvalds 22111da177e4SLinus Torvalds 221200b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 22131da177e4SLinus Torvalds int *valp, 22141da177e4SLinus Torvalds int write, void *data) 22151da177e4SLinus Torvalds { 22161da177e4SLinus Torvalds if (write) { 2217cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2218cba9f33dSBart Samwel return 1; 22191da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 22201da177e4SLinus Torvalds } else { 22211da177e4SLinus Torvalds int val = *valp; 22221da177e4SLinus Torvalds unsigned long lval; 22231da177e4SLinus Torvalds if (val < 0) { 222400b7c339SAmerigo Wang *negp = true; 22251da177e4SLinus Torvalds lval = (unsigned long)-val; 22261da177e4SLinus Torvalds } else { 222700b7c339SAmerigo Wang *negp = false; 22281da177e4SLinus Torvalds lval = (unsigned long)val; 22291da177e4SLinus Torvalds } 22301da177e4SLinus Torvalds *lvalp = lval / HZ; 22311da177e4SLinus Torvalds } 22321da177e4SLinus Torvalds return 0; 22331da177e4SLinus Torvalds } 22341da177e4SLinus Torvalds 223500b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 22361da177e4SLinus Torvalds int *valp, 22371da177e4SLinus Torvalds int write, void *data) 22381da177e4SLinus Torvalds { 22391da177e4SLinus Torvalds if (write) { 2240cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2241cba9f33dSBart Samwel return 1; 22421da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 22431da177e4SLinus Torvalds } else { 22441da177e4SLinus Torvalds int val = *valp; 22451da177e4SLinus Torvalds unsigned long lval; 22461da177e4SLinus Torvalds if (val < 0) { 224700b7c339SAmerigo Wang *negp = true; 22481da177e4SLinus Torvalds lval = (unsigned long)-val; 22491da177e4SLinus Torvalds } else { 225000b7c339SAmerigo Wang *negp = false; 22511da177e4SLinus Torvalds lval = (unsigned long)val; 22521da177e4SLinus Torvalds } 22531da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 22541da177e4SLinus Torvalds } 22551da177e4SLinus Torvalds return 0; 22561da177e4SLinus Torvalds } 22571da177e4SLinus Torvalds 225800b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 22591da177e4SLinus Torvalds int *valp, 22601da177e4SLinus Torvalds int write, void *data) 22611da177e4SLinus Torvalds { 22621da177e4SLinus Torvalds if (write) { 22631da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 22641da177e4SLinus Torvalds } else { 22651da177e4SLinus Torvalds int val = *valp; 22661da177e4SLinus Torvalds unsigned long lval; 22671da177e4SLinus Torvalds if (val < 0) { 226800b7c339SAmerigo Wang *negp = true; 22691da177e4SLinus Torvalds lval = (unsigned long)-val; 22701da177e4SLinus Torvalds } else { 227100b7c339SAmerigo Wang *negp = false; 22721da177e4SLinus Torvalds lval = (unsigned long)val; 22731da177e4SLinus Torvalds } 22741da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 22751da177e4SLinus Torvalds } 22761da177e4SLinus Torvalds return 0; 22771da177e4SLinus Torvalds } 22781da177e4SLinus Torvalds 22791da177e4SLinus Torvalds /** 22801da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 22811da177e4SLinus Torvalds * @table: the sysctl table 22821da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22831da177e4SLinus Torvalds * @buffer: the user buffer 22841da177e4SLinus Torvalds * @lenp: the size of the user buffer 22851da177e4SLinus Torvalds * @ppos: file position 22861da177e4SLinus Torvalds * 22871da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22881da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22891da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 22901da177e4SLinus Torvalds * jiffies. 22911da177e4SLinus Torvalds * 22921da177e4SLinus Torvalds * Returns 0 on success. 22931da177e4SLinus Torvalds */ 22948d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 22951da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22961da177e4SLinus Torvalds { 22978d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 22981da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 22991da177e4SLinus Torvalds } 23001da177e4SLinus Torvalds 23011da177e4SLinus Torvalds /** 23021da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 23031da177e4SLinus Torvalds * @table: the sysctl table 23041da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23051da177e4SLinus Torvalds * @buffer: the user buffer 23061da177e4SLinus Torvalds * @lenp: the size of the user buffer 23071e5d5331SRandy Dunlap * @ppos: pointer to the file position 23081da177e4SLinus Torvalds * 23091da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23101da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23111da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 23121da177e4SLinus Torvalds * are converted into jiffies. 23131da177e4SLinus Torvalds * 23141da177e4SLinus Torvalds * Returns 0 on success. 23151da177e4SLinus Torvalds */ 23168d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 23171da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23181da177e4SLinus Torvalds { 23198d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 23201da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 23211da177e4SLinus Torvalds } 23221da177e4SLinus Torvalds 23231da177e4SLinus Torvalds /** 23241da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 23251da177e4SLinus Torvalds * @table: the sysctl table 23261da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23271da177e4SLinus Torvalds * @buffer: the user buffer 23281da177e4SLinus Torvalds * @lenp: the size of the user buffer 232967be2dd1SMartin Waitz * @ppos: file position 233067be2dd1SMartin Waitz * @ppos: the current position in the file 23311da177e4SLinus Torvalds * 23321da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23331da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23341da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 23351da177e4SLinus Torvalds * are converted into jiffies. 23361da177e4SLinus Torvalds * 23371da177e4SLinus Torvalds * Returns 0 on success. 23381da177e4SLinus Torvalds */ 23398d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 23401da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23411da177e4SLinus Torvalds { 23428d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 23431da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 23441da177e4SLinus Torvalds } 23451da177e4SLinus Torvalds 23468d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 23479ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 23489ec52099SCedric Le Goater { 23499ec52099SCedric Le Goater struct pid *new_pid; 23509ec52099SCedric Le Goater pid_t tmp; 23519ec52099SCedric Le Goater int r; 23529ec52099SCedric Le Goater 23536c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 23549ec52099SCedric Le Goater 23558d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 23569ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 23579ec52099SCedric Le Goater if (r || !write) 23589ec52099SCedric Le Goater return r; 23599ec52099SCedric Le Goater 23609ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 23619ec52099SCedric Le Goater if (!new_pid) 23629ec52099SCedric Le Goater return -ESRCH; 23639ec52099SCedric Le Goater 23649ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 23659ec52099SCedric Le Goater return 0; 23669ec52099SCedric Le Goater } 23679ec52099SCedric Le Goater 23689f977fb7SOctavian Purdila /** 23699f977fb7SOctavian Purdila * proc_do_large_bitmap - read/write from/to a large bitmap 23709f977fb7SOctavian Purdila * @table: the sysctl table 23719f977fb7SOctavian Purdila * @write: %TRUE if this is a write to the sysctl file 23729f977fb7SOctavian Purdila * @buffer: the user buffer 23739f977fb7SOctavian Purdila * @lenp: the size of the user buffer 23749f977fb7SOctavian Purdila * @ppos: file position 23759f977fb7SOctavian Purdila * 23769f977fb7SOctavian Purdila * The bitmap is stored at table->data and the bitmap length (in bits) 23779f977fb7SOctavian Purdila * in table->maxlen. 23789f977fb7SOctavian Purdila * 23799f977fb7SOctavian Purdila * We use a range comma separated format (e.g. 1,3-4,10-10) so that 23809f977fb7SOctavian Purdila * large bitmaps may be represented in a compact manner. Writing into 23819f977fb7SOctavian Purdila * the file will clear the bitmap then update it with the given input. 23829f977fb7SOctavian Purdila * 23839f977fb7SOctavian Purdila * Returns 0 on success. 23849f977fb7SOctavian Purdila */ 23859f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write, 23869f977fb7SOctavian Purdila void __user *buffer, size_t *lenp, loff_t *ppos) 23879f977fb7SOctavian Purdila { 23889f977fb7SOctavian Purdila int err = 0; 23899f977fb7SOctavian Purdila bool first = 1; 23909f977fb7SOctavian Purdila size_t left = *lenp; 23919f977fb7SOctavian Purdila unsigned long bitmap_len = table->maxlen; 23929f977fb7SOctavian Purdila unsigned long *bitmap = (unsigned long *) table->data; 23939f977fb7SOctavian Purdila unsigned long *tmp_bitmap = NULL; 23949f977fb7SOctavian Purdila char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 23959f977fb7SOctavian Purdila 23969f977fb7SOctavian Purdila if (!bitmap_len || !left || (*ppos && !write)) { 23979f977fb7SOctavian Purdila *lenp = 0; 23989f977fb7SOctavian Purdila return 0; 23999f977fb7SOctavian Purdila } 24009f977fb7SOctavian Purdila 24019f977fb7SOctavian Purdila if (write) { 24029f977fb7SOctavian Purdila unsigned long page = 0; 24039f977fb7SOctavian Purdila char *kbuf; 24049f977fb7SOctavian Purdila 24059f977fb7SOctavian Purdila if (left > PAGE_SIZE - 1) 24069f977fb7SOctavian Purdila left = PAGE_SIZE - 1; 24079f977fb7SOctavian Purdila 24089f977fb7SOctavian Purdila page = __get_free_page(GFP_TEMPORARY); 24099f977fb7SOctavian Purdila kbuf = (char *) page; 24109f977fb7SOctavian Purdila if (!kbuf) 24119f977fb7SOctavian Purdila return -ENOMEM; 24129f977fb7SOctavian Purdila if (copy_from_user(kbuf, buffer, left)) { 24139f977fb7SOctavian Purdila free_page(page); 24149f977fb7SOctavian Purdila return -EFAULT; 24159f977fb7SOctavian Purdila } 24169f977fb7SOctavian Purdila kbuf[left] = 0; 24179f977fb7SOctavian Purdila 24189f977fb7SOctavian Purdila tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), 24199f977fb7SOctavian Purdila GFP_KERNEL); 24209f977fb7SOctavian Purdila if (!tmp_bitmap) { 24219f977fb7SOctavian Purdila free_page(page); 24229f977fb7SOctavian Purdila return -ENOMEM; 24239f977fb7SOctavian Purdila } 24249f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 24259f977fb7SOctavian Purdila while (!err && left) { 24269f977fb7SOctavian Purdila unsigned long val_a, val_b; 24279f977fb7SOctavian Purdila bool neg; 24289f977fb7SOctavian Purdila 24299f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a, 24309f977fb7SOctavian Purdila sizeof(tr_a), &c); 24319f977fb7SOctavian Purdila if (err) 24329f977fb7SOctavian Purdila break; 24339f977fb7SOctavian Purdila if (val_a >= bitmap_len || neg) { 24349f977fb7SOctavian Purdila err = -EINVAL; 24359f977fb7SOctavian Purdila break; 24369f977fb7SOctavian Purdila } 24379f977fb7SOctavian Purdila 24389f977fb7SOctavian Purdila val_b = val_a; 24399f977fb7SOctavian Purdila if (left) { 24409f977fb7SOctavian Purdila kbuf++; 24419f977fb7SOctavian Purdila left--; 24429f977fb7SOctavian Purdila } 24439f977fb7SOctavian Purdila 24449f977fb7SOctavian Purdila if (c == '-') { 24459f977fb7SOctavian Purdila err = proc_get_long(&kbuf, &left, &val_b, 24469f977fb7SOctavian Purdila &neg, tr_b, sizeof(tr_b), 24479f977fb7SOctavian Purdila &c); 24489f977fb7SOctavian Purdila if (err) 24499f977fb7SOctavian Purdila break; 24509f977fb7SOctavian Purdila if (val_b >= bitmap_len || neg || 24519f977fb7SOctavian Purdila val_a > val_b) { 24529f977fb7SOctavian Purdila err = -EINVAL; 24539f977fb7SOctavian Purdila break; 24549f977fb7SOctavian Purdila } 24559f977fb7SOctavian Purdila if (left) { 24569f977fb7SOctavian Purdila kbuf++; 24579f977fb7SOctavian Purdila left--; 24589f977fb7SOctavian Purdila } 24599f977fb7SOctavian Purdila } 24609f977fb7SOctavian Purdila 24615a04cca6SAkinobu Mita bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); 24629f977fb7SOctavian Purdila first = 0; 24639f977fb7SOctavian Purdila proc_skip_char(&kbuf, &left, '\n'); 24649f977fb7SOctavian Purdila } 24659f977fb7SOctavian Purdila free_page(page); 24669f977fb7SOctavian Purdila } else { 24679f977fb7SOctavian Purdila unsigned long bit_a, bit_b = 0; 24689f977fb7SOctavian Purdila 24699f977fb7SOctavian Purdila while (left) { 24709f977fb7SOctavian Purdila bit_a = find_next_bit(bitmap, bitmap_len, bit_b); 24719f977fb7SOctavian Purdila if (bit_a >= bitmap_len) 24729f977fb7SOctavian Purdila break; 24739f977fb7SOctavian Purdila bit_b = find_next_zero_bit(bitmap, bitmap_len, 24749f977fb7SOctavian Purdila bit_a + 1) - 1; 24759f977fb7SOctavian Purdila 24769f977fb7SOctavian Purdila if (!first) { 24779f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, ','); 24789f977fb7SOctavian Purdila if (err) 24799f977fb7SOctavian Purdila break; 24809f977fb7SOctavian Purdila } 24819f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_a, false); 24829f977fb7SOctavian Purdila if (err) 24839f977fb7SOctavian Purdila break; 24849f977fb7SOctavian Purdila if (bit_a != bit_b) { 24859f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '-'); 24869f977fb7SOctavian Purdila if (err) 24879f977fb7SOctavian Purdila break; 24889f977fb7SOctavian Purdila err = proc_put_long(&buffer, &left, bit_b, false); 24899f977fb7SOctavian Purdila if (err) 24909f977fb7SOctavian Purdila break; 24919f977fb7SOctavian Purdila } 24929f977fb7SOctavian Purdila 24939f977fb7SOctavian Purdila first = 0; bit_b++; 24949f977fb7SOctavian Purdila } 24959f977fb7SOctavian Purdila if (!err) 24969f977fb7SOctavian Purdila err = proc_put_char(&buffer, &left, '\n'); 24979f977fb7SOctavian Purdila } 24989f977fb7SOctavian Purdila 24999f977fb7SOctavian Purdila if (!err) { 25009f977fb7SOctavian Purdila if (write) { 25019f977fb7SOctavian Purdila if (*ppos) 25029f977fb7SOctavian Purdila bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len); 25039f977fb7SOctavian Purdila else 25045a04cca6SAkinobu Mita bitmap_copy(bitmap, tmp_bitmap, bitmap_len); 25059f977fb7SOctavian Purdila } 25069f977fb7SOctavian Purdila kfree(tmp_bitmap); 25079f977fb7SOctavian Purdila *lenp -= left; 25089f977fb7SOctavian Purdila *ppos += *lenp; 25099f977fb7SOctavian Purdila return 0; 25109f977fb7SOctavian Purdila } else { 25119f977fb7SOctavian Purdila kfree(tmp_bitmap); 25129f977fb7SOctavian Purdila return err; 25139f977fb7SOctavian Purdila } 25149f977fb7SOctavian Purdila } 25159f977fb7SOctavian Purdila 251655610500SJovi Zhang #else /* CONFIG_PROC_SYSCTL */ 25171da177e4SLinus Torvalds 25188d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 25191da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25201da177e4SLinus Torvalds { 25211da177e4SLinus Torvalds return -ENOSYS; 25221da177e4SLinus Torvalds } 25231da177e4SLinus Torvalds 25248d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 25251da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25261da177e4SLinus Torvalds { 25271da177e4SLinus Torvalds return -ENOSYS; 25281da177e4SLinus Torvalds } 25291da177e4SLinus Torvalds 25308d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 25311da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25321da177e4SLinus Torvalds { 25331da177e4SLinus Torvalds return -ENOSYS; 25341da177e4SLinus Torvalds } 25351da177e4SLinus Torvalds 25368d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 25371da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25381da177e4SLinus Torvalds { 25391da177e4SLinus Torvalds return -ENOSYS; 25401da177e4SLinus Torvalds } 25411da177e4SLinus Torvalds 25428d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 25431da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25441da177e4SLinus Torvalds { 25451da177e4SLinus Torvalds return -ENOSYS; 25461da177e4SLinus Torvalds } 25471da177e4SLinus Torvalds 25488d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 25491da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25501da177e4SLinus Torvalds { 25511da177e4SLinus Torvalds return -ENOSYS; 25521da177e4SLinus Torvalds } 25531da177e4SLinus Torvalds 25548d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 25551da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 25561da177e4SLinus Torvalds { 25571da177e4SLinus Torvalds return -ENOSYS; 25581da177e4SLinus Torvalds } 25591da177e4SLinus Torvalds 2560d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 25611da177e4SLinus Torvalds void __user *buffer, 25621da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 25631da177e4SLinus Torvalds { 25641da177e4SLinus Torvalds return -ENOSYS; 25651da177e4SLinus Torvalds } 25661da177e4SLinus Torvalds 25671da177e4SLinus Torvalds 256855610500SJovi Zhang #endif /* CONFIG_PROC_SYSCTL */ 25691da177e4SLinus Torvalds 25701da177e4SLinus Torvalds /* 25711da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 25721da177e4SLinus Torvalds * exception granted :-) 25731da177e4SLinus Torvalds */ 25741da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 25751da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 25761da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 25771da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 25781da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 25791da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 25801da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 25811da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 2582