11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * sysctl.c: General linux system control interface 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Begun 24 March 1995, Stephen Tweedie 51da177e4SLinus Torvalds * Added /proc support, Dec 1995 61da177e4SLinus Torvalds * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 71da177e4SLinus Torvalds * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. 81da177e4SLinus Torvalds * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver. 91da177e4SLinus Torvalds * Dynamic registration fixes, Stephen Tweedie. 101da177e4SLinus Torvalds * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn. 111da177e4SLinus Torvalds * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris 121da177e4SLinus Torvalds * Horn. 131da177e4SLinus Torvalds * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer. 141da177e4SLinus Torvalds * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer. 151da177e4SLinus Torvalds * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill 161da177e4SLinus Torvalds * Wendling. 171da177e4SLinus Torvalds * The list_for_each() macro wasn't appropriate for the sysctl loop. 181da177e4SLinus Torvalds * Removed it and replaced it with older style, 03/23/00, Bill Wendling 191da177e4SLinus Torvalds */ 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds #include <linux/module.h> 221da177e4SLinus Torvalds #include <linux/mm.h> 231da177e4SLinus Torvalds #include <linux/swap.h> 241da177e4SLinus Torvalds #include <linux/slab.h> 251da177e4SLinus Torvalds #include <linux/sysctl.h> 26d33ed52dSDave Young #include <linux/signal.h> 271da177e4SLinus Torvalds #include <linux/proc_fs.h> 2872c2d582SAndrew Morgan #include <linux/security.h> 291da177e4SLinus Torvalds #include <linux/ctype.h> 30dfec072eSVegard Nossum #include <linux/kmemcheck.h> 3162239ac2SAdrian Bunk #include <linux/fs.h> 321da177e4SLinus Torvalds #include <linux/init.h> 331da177e4SLinus Torvalds #include <linux/kernel.h> 340296b228SKay Sievers #include <linux/kobject.h> 3520380731SArnaldo Carvalho de Melo #include <linux/net.h> 361da177e4SLinus Torvalds #include <linux/sysrq.h> 371da177e4SLinus Torvalds #include <linux/highuid.h> 381da177e4SLinus Torvalds #include <linux/writeback.h> 393fff4c42SIngo Molnar #include <linux/ratelimit.h> 401da177e4SLinus Torvalds #include <linux/hugetlb.h> 411da177e4SLinus Torvalds #include <linux/initrd.h> 420b77f5bfSDavid Howells #include <linux/key.h> 431da177e4SLinus Torvalds #include <linux/times.h> 441da177e4SLinus Torvalds #include <linux/limits.h> 451da177e4SLinus Torvalds #include <linux/dcache.h> 461da177e4SLinus Torvalds #include <linux/syscalls.h> 47c748e134SAdrian Bunk #include <linux/vmstat.h> 48c255d844SPavel Machek #include <linux/nfs_fs.h> 49c255d844SPavel Machek #include <linux/acpi.h> 5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h> 51b0fc494fSSteven Rostedt #include <linux/ftrace.h> 5212e22c5eSDavid Howells #include <linux/slow-work.h> 53cdd6c482SIngo Molnar #include <linux/perf_event.h> 54b2be84dfSMasami Hiramatsu #include <linux/kprobes.h> 551da177e4SLinus Torvalds 561da177e4SLinus Torvalds #include <asm/uaccess.h> 571da177e4SLinus Torvalds #include <asm/processor.h> 581da177e4SLinus Torvalds 5929cbc78bSAndi Kleen #ifdef CONFIG_X86 6029cbc78bSAndi Kleen #include <asm/nmi.h> 610741f4d2SChuck Ebbert #include <asm/stacktrace.h> 626e7c4025SIngo Molnar #include <asm/io.h> 6329cbc78bSAndi Kleen #endif 64c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT 65c55b7c3eSDave Young #include <linux/acct.h> 66c55b7c3eSDave Young #endif 674f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES 684f0e056fSDave Young #include <linux/rtmutex.h> 694f0e056fSDave Young #endif 702edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) 712edf5e49SDave Young #include <linux/lockdep.h> 722edf5e49SDave Young #endif 7315485a46SDave Young #ifdef CONFIG_CHR_DEV_SG 7415485a46SDave Young #include <scsi/sg.h> 7515485a46SDave Young #endif 7629cbc78bSAndi Kleen 777058cb02SEric W. Biederman 781da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds /* External variables not in a header file. */ 811da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 821da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 83fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom; 84fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task; 85fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks; 861da177e4SLinus Torvalds extern int max_threads; 871da177e4SLinus Torvalds extern int core_uses_pid; 88d6e71144SAlan Cox extern int suid_dumpable; 891da177e4SLinus Torvalds extern char core_pattern[]; 90a293980cSNeil Horman extern unsigned int core_pipe_limit; 911da177e4SLinus Torvalds extern int pid_max; 921da177e4SLinus Torvalds extern int min_free_kbytes; 931da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 949d0243bcSAndrew Morton extern int sysctl_drop_caches; 958ad4b1fbSRohit Seth extern int percpu_pagelist_fraction; 96bebfa101SAndi Kleen extern int compat_log; 979745512cSArjan van de Ven extern int latencytop_enabled; 98eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max; 99dd8632a1SPaul Mundt #ifndef CONFIG_MMU 100dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages; 101dd8632a1SPaul Mundt #endif 102cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 1035e605b64SJens Axboe extern int blk_iopoll_enabled; 104cb684b5bSJens Axboe #endif 1051da177e4SLinus Torvalds 106c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and maximum */ 107195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP 108c4f3b63fSRavikiran G Thirumalai static int sixty = 60; 1099383d967SDimitri Sivanich static int neg_one = -1; 110c4f3b63fSRavikiran G Thirumalai #endif 111c4f3b63fSRavikiran G Thirumalai 112c4f3b63fSRavikiran G Thirumalai static int zero; 113cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1; 114cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2; 115fc3501d4SSven Wegener static unsigned long one_ul = 1; 116c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100; 117af91322eSDave Young #ifdef CONFIG_PRINTK 118af91322eSDave Young static int ten_thousand = 10000; 119af91322eSDave Young #endif 120c4f3b63fSRavikiran G Thirumalai 1219e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ 1229e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE; 1239e4a5bdaSAndrea Righi 1241da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 1251da177e4SLinus Torvalds static int maxolduid = 65535; 1261da177e4SLinus Torvalds static int minolduid; 1278ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8; 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 1301da177e4SLinus Torvalds 13172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 13217f04fbbSDavid S. Miller #include <asm/system.h> 1331da177e4SLinus Torvalds #endif 1341da177e4SLinus Torvalds 1350871420fSDavid S. Miller #ifdef CONFIG_SPARC64 1360871420fSDavid S. Miller extern int sysctl_tsb_ratio; 1370871420fSDavid S. Miller #endif 1380871420fSDavid S. Miller 1391da177e4SLinus Torvalds #ifdef __hppa__ 1401da177e4SLinus Torvalds extern int pwrsw_enabled; 1411da177e4SLinus Torvalds extern int unaligned_enabled; 1421da177e4SLinus Torvalds #endif 1431da177e4SLinus Torvalds 144347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1451da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1461da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1471da177e4SLinus Torvalds #endif 1481da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 149951f22d5SMartin Schwidefsky extern int spin_retry; 1501da177e4SLinus Torvalds #endif 1511da177e4SLinus Torvalds 152d2b176edSJes Sorensen #ifdef CONFIG_IA64 153d2b176edSJes Sorensen extern int no_unaligned_warning; 15488fc241fSDoug Chapman extern int unaligned_dump_stack; 155d2b176edSJes Sorensen #endif 156d2b176edSJes Sorensen 1573fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state; 1583fff4c42SIngo Molnar 159d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 1608d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 1619ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos); 1628d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 16334f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos); 164d6f8ff73SRandy Dunlap #endif 1659ec52099SCedric Le Goater 166d8217f07SEric W. Biederman static struct ctl_table root_table[]; 167e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root; 168e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = { 169b380b0d4SAl Viro .count = 1, 170e51b6ba0SEric W. Biederman .ctl_table = root_table, 17173455092SAl Viro .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list), 172e51b6ba0SEric W. Biederman .root = &sysctl_table_root, 17373455092SAl Viro .set = &sysctl_table_root.default_set, 174e51b6ba0SEric W. Biederman }; 175e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = { 176e51b6ba0SEric W. Biederman .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list), 17773455092SAl Viro .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry), 178e51b6ba0SEric W. Biederman }; 1791da177e4SLinus Torvalds 180d8217f07SEric W. Biederman static struct ctl_table kern_table[]; 181d8217f07SEric W. Biederman static struct ctl_table vm_table[]; 182d8217f07SEric W. Biederman static struct ctl_table fs_table[]; 183d8217f07SEric W. Biederman static struct ctl_table debug_table[]; 184d8217f07SEric W. Biederman static struct ctl_table dev_table[]; 185d8217f07SEric W. Biederman extern struct ctl_table random_table[]; 1862d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 187d8217f07SEric W. Biederman extern struct ctl_table inotify_table[]; 1880399cb08SRobert Love #endif 1897ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 1907ef9964eSDavide Libenzi extern struct ctl_table epoll_table[]; 1917ef9964eSDavide Libenzi #endif 1921da177e4SLinus Torvalds 1931da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 1941da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1951da177e4SLinus Torvalds #endif 1961da177e4SLinus Torvalds 1971da177e4SLinus Torvalds /* The default sysctl tables: */ 1981da177e4SLinus Torvalds 199d8217f07SEric W. Biederman static struct ctl_table root_table[] = { 2001da177e4SLinus Torvalds { 2011da177e4SLinus Torvalds .procname = "kernel", 2021da177e4SLinus Torvalds .mode = 0555, 2031da177e4SLinus Torvalds .child = kern_table, 2041da177e4SLinus Torvalds }, 2051da177e4SLinus Torvalds { 2061da177e4SLinus Torvalds .procname = "vm", 2071da177e4SLinus Torvalds .mode = 0555, 2081da177e4SLinus Torvalds .child = vm_table, 2091da177e4SLinus Torvalds }, 2101da177e4SLinus Torvalds { 2111da177e4SLinus Torvalds .procname = "fs", 2121da177e4SLinus Torvalds .mode = 0555, 2131da177e4SLinus Torvalds .child = fs_table, 2141da177e4SLinus Torvalds }, 2151da177e4SLinus Torvalds { 2161da177e4SLinus Torvalds .procname = "debug", 2171da177e4SLinus Torvalds .mode = 0555, 2181da177e4SLinus Torvalds .child = debug_table, 2191da177e4SLinus Torvalds }, 2201da177e4SLinus Torvalds { 2211da177e4SLinus Torvalds .procname = "dev", 2221da177e4SLinus Torvalds .mode = 0555, 2231da177e4SLinus Torvalds .child = dev_table, 2241da177e4SLinus Torvalds }, 2252be7fe07SAndrew Morton /* 2262be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 2272be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 2282be7fe07SAndrew Morton */ 2296fce56ecSEric W. Biederman { } 2301da177e4SLinus Torvalds }; 2311da177e4SLinus Torvalds 23277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 23373c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000; /* 100 usecs */ 23473c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 23573c4efd2SEric Dumazet static int min_wakeup_granularity_ns; /* 0 usecs */ 23673c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 2371983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE; 2381983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 239acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */ 240acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */ 24177e54a1fSIngo Molnar #endif 24277e54a1fSIngo Molnar 243d8217f07SEric W. Biederman static struct ctl_table kern_table[] = { 2442bba22c5SMike Galbraith { 2452bba22c5SMike Galbraith .procname = "sched_child_runs_first", 2462bba22c5SMike Galbraith .data = &sysctl_sched_child_runs_first, 2472bba22c5SMike Galbraith .maxlen = sizeof(unsigned int), 2482bba22c5SMike Galbraith .mode = 0644, 2496d456111SEric W. Biederman .proc_handler = proc_dointvec, 2502bba22c5SMike Galbraith }, 25177e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG 25277e54a1fSIngo Molnar { 253b2be5e96SPeter Zijlstra .procname = "sched_min_granularity_ns", 254b2be5e96SPeter Zijlstra .data = &sysctl_sched_min_granularity, 25577e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 25677e54a1fSIngo Molnar .mode = 0644, 257702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 258b2be5e96SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 259b2be5e96SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 26077e54a1fSIngo Molnar }, 26177e54a1fSIngo Molnar { 26221805085SPeter Zijlstra .procname = "sched_latency_ns", 26321805085SPeter Zijlstra .data = &sysctl_sched_latency, 26421805085SPeter Zijlstra .maxlen = sizeof(unsigned int), 26521805085SPeter Zijlstra .mode = 0644, 266702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 26721805085SPeter Zijlstra .extra1 = &min_sched_granularity_ns, 26821805085SPeter Zijlstra .extra2 = &max_sched_granularity_ns, 26921805085SPeter Zijlstra }, 27021805085SPeter Zijlstra { 27177e54a1fSIngo Molnar .procname = "sched_wakeup_granularity_ns", 27277e54a1fSIngo Molnar .data = &sysctl_sched_wakeup_granularity, 27377e54a1fSIngo Molnar .maxlen = sizeof(unsigned int), 27477e54a1fSIngo Molnar .mode = 0644, 275702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 27677e54a1fSIngo Molnar .extra1 = &min_wakeup_granularity_ns, 27777e54a1fSIngo Molnar .extra2 = &max_wakeup_granularity_ns, 27877e54a1fSIngo Molnar }, 27977e54a1fSIngo Molnar { 2802398f2c6SPeter Zijlstra .procname = "sched_shares_ratelimit", 2812398f2c6SPeter Zijlstra .data = &sysctl_sched_shares_ratelimit, 2822398f2c6SPeter Zijlstra .maxlen = sizeof(unsigned int), 2832398f2c6SPeter Zijlstra .mode = 0644, 284702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 285acb4a848SChristian Ehrhardt .extra1 = &min_sched_shares_ratelimit, 286acb4a848SChristian Ehrhardt .extra2 = &max_sched_shares_ratelimit, 2872398f2c6SPeter Zijlstra }, 2882398f2c6SPeter Zijlstra { 2891983a922SChristian Ehrhardt .procname = "sched_tunable_scaling", 2901983a922SChristian Ehrhardt .data = &sysctl_sched_tunable_scaling, 2911983a922SChristian Ehrhardt .maxlen = sizeof(enum sched_tunable_scaling), 2921983a922SChristian Ehrhardt .mode = 0644, 293702a7c76SLinus Torvalds .proc_handler = sched_proc_update_handler, 2941983a922SChristian Ehrhardt .extra1 = &min_sched_tunable_scaling, 2951983a922SChristian Ehrhardt .extra2 = &max_sched_tunable_scaling, 2962398f2c6SPeter Zijlstra }, 2972398f2c6SPeter Zijlstra { 298ffda12a1SPeter Zijlstra .procname = "sched_shares_thresh", 299ffda12a1SPeter Zijlstra .data = &sysctl_sched_shares_thresh, 300ffda12a1SPeter Zijlstra .maxlen = sizeof(unsigned int), 301ffda12a1SPeter Zijlstra .mode = 0644, 3026d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 303ffda12a1SPeter Zijlstra .extra1 = &zero, 304ffda12a1SPeter Zijlstra }, 305ffda12a1SPeter Zijlstra { 306da84d961SIngo Molnar .procname = "sched_migration_cost", 307da84d961SIngo Molnar .data = &sysctl_sched_migration_cost, 308da84d961SIngo Molnar .maxlen = sizeof(unsigned int), 309da84d961SIngo Molnar .mode = 0644, 3106d456111SEric W. Biederman .proc_handler = proc_dointvec, 311da84d961SIngo Molnar }, 312b82d9fddSPeter Zijlstra { 313b82d9fddSPeter Zijlstra .procname = "sched_nr_migrate", 314b82d9fddSPeter Zijlstra .data = &sysctl_sched_nr_migrate, 315b82d9fddSPeter Zijlstra .maxlen = sizeof(unsigned int), 316fa85ae24SPeter Zijlstra .mode = 0644, 3176d456111SEric W. Biederman .proc_handler = proc_dointvec, 318fa85ae24SPeter Zijlstra }, 319cd1bb94bSArun R Bharadwaj { 320e9e9250bSPeter Zijlstra .procname = "sched_time_avg", 321e9e9250bSPeter Zijlstra .data = &sysctl_sched_time_avg, 322e9e9250bSPeter Zijlstra .maxlen = sizeof(unsigned int), 323e9e9250bSPeter Zijlstra .mode = 0644, 3246d456111SEric W. Biederman .proc_handler = proc_dointvec, 325e9e9250bSPeter Zijlstra }, 326e9e9250bSPeter Zijlstra { 327cd1bb94bSArun R Bharadwaj .procname = "timer_migration", 328cd1bb94bSArun R Bharadwaj .data = &sysctl_timer_migration, 329cd1bb94bSArun R Bharadwaj .maxlen = sizeof(unsigned int), 330cd1bb94bSArun R Bharadwaj .mode = 0644, 3316d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 332bfdb4d9fSArun R Bharadwaj .extra1 = &zero, 333bfdb4d9fSArun R Bharadwaj .extra2 = &one, 334cd1bb94bSArun R Bharadwaj }, 3351fc84aaaSPeter Zijlstra #endif 3361799e35dSIngo Molnar { 3379f0c1e56SPeter Zijlstra .procname = "sched_rt_period_us", 3389f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_period, 3399f0c1e56SPeter Zijlstra .maxlen = sizeof(unsigned int), 3409f0c1e56SPeter Zijlstra .mode = 0644, 3416d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3429f0c1e56SPeter Zijlstra }, 3439f0c1e56SPeter Zijlstra { 3449f0c1e56SPeter Zijlstra .procname = "sched_rt_runtime_us", 3459f0c1e56SPeter Zijlstra .data = &sysctl_sched_rt_runtime, 3469f0c1e56SPeter Zijlstra .maxlen = sizeof(int), 3479f0c1e56SPeter Zijlstra .mode = 0644, 3486d456111SEric W. Biederman .proc_handler = sched_rt_handler, 3499f0c1e56SPeter Zijlstra }, 3509f0c1e56SPeter Zijlstra { 3511799e35dSIngo Molnar .procname = "sched_compat_yield", 3521799e35dSIngo Molnar .data = &sysctl_sched_compat_yield, 3531799e35dSIngo Molnar .maxlen = sizeof(unsigned int), 3541799e35dSIngo Molnar .mode = 0644, 3556d456111SEric W. Biederman .proc_handler = proc_dointvec, 3561799e35dSIngo Molnar }, 357f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING 358f20786ffSPeter Zijlstra { 359f20786ffSPeter Zijlstra .procname = "prove_locking", 360f20786ffSPeter Zijlstra .data = &prove_locking, 361f20786ffSPeter Zijlstra .maxlen = sizeof(int), 362f20786ffSPeter Zijlstra .mode = 0644, 3636d456111SEric W. Biederman .proc_handler = proc_dointvec, 364f20786ffSPeter Zijlstra }, 365f20786ffSPeter Zijlstra #endif 366f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT 367f20786ffSPeter Zijlstra { 368f20786ffSPeter Zijlstra .procname = "lock_stat", 369f20786ffSPeter Zijlstra .data = &lock_stat, 370f20786ffSPeter Zijlstra .maxlen = sizeof(int), 371f20786ffSPeter Zijlstra .mode = 0644, 3726d456111SEric W. Biederman .proc_handler = proc_dointvec, 373f20786ffSPeter Zijlstra }, 374f20786ffSPeter Zijlstra #endif 37577e54a1fSIngo Molnar { 3761da177e4SLinus Torvalds .procname = "panic", 3771da177e4SLinus Torvalds .data = &panic_timeout, 3781da177e4SLinus Torvalds .maxlen = sizeof(int), 3791da177e4SLinus Torvalds .mode = 0644, 3806d456111SEric W. Biederman .proc_handler = proc_dointvec, 3811da177e4SLinus Torvalds }, 3821da177e4SLinus Torvalds { 3831da177e4SLinus Torvalds .procname = "core_uses_pid", 3841da177e4SLinus Torvalds .data = &core_uses_pid, 3851da177e4SLinus Torvalds .maxlen = sizeof(int), 3861da177e4SLinus Torvalds .mode = 0644, 3876d456111SEric W. Biederman .proc_handler = proc_dointvec, 3881da177e4SLinus Torvalds }, 3891da177e4SLinus Torvalds { 3901da177e4SLinus Torvalds .procname = "core_pattern", 3911da177e4SLinus Torvalds .data = core_pattern, 39271ce92f3SDan Aloni .maxlen = CORENAME_MAX_SIZE, 3931da177e4SLinus Torvalds .mode = 0644, 3946d456111SEric W. Biederman .proc_handler = proc_dostring, 3951da177e4SLinus Torvalds }, 396a293980cSNeil Horman { 397a293980cSNeil Horman .procname = "core_pipe_limit", 398a293980cSNeil Horman .data = &core_pipe_limit, 399a293980cSNeil Horman .maxlen = sizeof(unsigned int), 400a293980cSNeil Horman .mode = 0644, 4016d456111SEric W. Biederman .proc_handler = proc_dointvec, 402a293980cSNeil Horman }, 40334f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL 4041da177e4SLinus Torvalds { 4051da177e4SLinus Torvalds .procname = "tainted", 40625ddbb18SAndi Kleen .maxlen = sizeof(long), 40734f5a398STheodore Ts'o .mode = 0644, 4086d456111SEric W. Biederman .proc_handler = proc_taint, 4091da177e4SLinus Torvalds }, 41034f5a398STheodore Ts'o #endif 4119745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP 4129745512cSArjan van de Ven { 4139745512cSArjan van de Ven .procname = "latencytop", 4149745512cSArjan van de Ven .data = &latencytop_enabled, 4159745512cSArjan van de Ven .maxlen = sizeof(int), 4169745512cSArjan van de Ven .mode = 0644, 4176d456111SEric W. Biederman .proc_handler = proc_dointvec, 4189745512cSArjan van de Ven }, 4199745512cSArjan van de Ven #endif 4201da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 4211da177e4SLinus Torvalds { 4221da177e4SLinus Torvalds .procname = "real-root-dev", 4231da177e4SLinus Torvalds .data = &real_root_dev, 4241da177e4SLinus Torvalds .maxlen = sizeof(int), 4251da177e4SLinus Torvalds .mode = 0644, 4266d456111SEric W. Biederman .proc_handler = proc_dointvec, 4271da177e4SLinus Torvalds }, 4281da177e4SLinus Torvalds #endif 42945807a1dSIngo Molnar { 43045807a1dSIngo Molnar .procname = "print-fatal-signals", 43145807a1dSIngo Molnar .data = &print_fatal_signals, 43245807a1dSIngo Molnar .maxlen = sizeof(int), 43345807a1dSIngo Molnar .mode = 0644, 4346d456111SEric W. Biederman .proc_handler = proc_dointvec, 43545807a1dSIngo Molnar }, 43672c57ed5SDavid S. Miller #ifdef CONFIG_SPARC 4371da177e4SLinus Torvalds { 4381da177e4SLinus Torvalds .procname = "reboot-cmd", 4391da177e4SLinus Torvalds .data = reboot_command, 4401da177e4SLinus Torvalds .maxlen = 256, 4411da177e4SLinus Torvalds .mode = 0644, 4426d456111SEric W. Biederman .proc_handler = proc_dostring, 4431da177e4SLinus Torvalds }, 4441da177e4SLinus Torvalds { 4451da177e4SLinus Torvalds .procname = "stop-a", 4461da177e4SLinus Torvalds .data = &stop_a_enabled, 4471da177e4SLinus Torvalds .maxlen = sizeof (int), 4481da177e4SLinus Torvalds .mode = 0644, 4496d456111SEric W. Biederman .proc_handler = proc_dointvec, 4501da177e4SLinus Torvalds }, 4511da177e4SLinus Torvalds { 4521da177e4SLinus Torvalds .procname = "scons-poweroff", 4531da177e4SLinus Torvalds .data = &scons_pwroff, 4541da177e4SLinus Torvalds .maxlen = sizeof (int), 4551da177e4SLinus Torvalds .mode = 0644, 4566d456111SEric W. Biederman .proc_handler = proc_dointvec, 4571da177e4SLinus Torvalds }, 4581da177e4SLinus Torvalds #endif 4590871420fSDavid S. Miller #ifdef CONFIG_SPARC64 4600871420fSDavid S. Miller { 4610871420fSDavid S. Miller .procname = "tsb-ratio", 4620871420fSDavid S. Miller .data = &sysctl_tsb_ratio, 4630871420fSDavid S. Miller .maxlen = sizeof (int), 4640871420fSDavid S. Miller .mode = 0644, 4656d456111SEric W. Biederman .proc_handler = proc_dointvec, 4660871420fSDavid S. Miller }, 4670871420fSDavid S. Miller #endif 4681da177e4SLinus Torvalds #ifdef __hppa__ 4691da177e4SLinus Torvalds { 4701da177e4SLinus Torvalds .procname = "soft-power", 4711da177e4SLinus Torvalds .data = &pwrsw_enabled, 4721da177e4SLinus Torvalds .maxlen = sizeof (int), 4731da177e4SLinus Torvalds .mode = 0644, 4746d456111SEric W. Biederman .proc_handler = proc_dointvec, 4751da177e4SLinus Torvalds }, 4761da177e4SLinus Torvalds { 4771da177e4SLinus Torvalds .procname = "unaligned-trap", 4781da177e4SLinus Torvalds .data = &unaligned_enabled, 4791da177e4SLinus Torvalds .maxlen = sizeof (int), 4801da177e4SLinus Torvalds .mode = 0644, 4816d456111SEric W. Biederman .proc_handler = proc_dointvec, 4821da177e4SLinus Torvalds }, 4831da177e4SLinus Torvalds #endif 4841da177e4SLinus Torvalds { 4851da177e4SLinus Torvalds .procname = "ctrl-alt-del", 4861da177e4SLinus Torvalds .data = &C_A_D, 4871da177e4SLinus Torvalds .maxlen = sizeof(int), 4881da177e4SLinus Torvalds .mode = 0644, 4896d456111SEric W. Biederman .proc_handler = proc_dointvec, 4901da177e4SLinus Torvalds }, 491606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER 492b0fc494fSSteven Rostedt { 493b0fc494fSSteven Rostedt .procname = "ftrace_enabled", 494b0fc494fSSteven Rostedt .data = &ftrace_enabled, 495b0fc494fSSteven Rostedt .maxlen = sizeof(int), 496b0fc494fSSteven Rostedt .mode = 0644, 4976d456111SEric W. Biederman .proc_handler = ftrace_enable_sysctl, 498b0fc494fSSteven Rostedt }, 499b0fc494fSSteven Rostedt #endif 500f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER 501f38f1d2aSSteven Rostedt { 502f38f1d2aSSteven Rostedt .procname = "stack_tracer_enabled", 503f38f1d2aSSteven Rostedt .data = &stack_tracer_enabled, 504f38f1d2aSSteven Rostedt .maxlen = sizeof(int), 505f38f1d2aSSteven Rostedt .mode = 0644, 5066d456111SEric W. Biederman .proc_handler = stack_trace_sysctl, 507f38f1d2aSSteven Rostedt }, 508f38f1d2aSSteven Rostedt #endif 509944ac425SSteven Rostedt #ifdef CONFIG_TRACING 510944ac425SSteven Rostedt { 5113299b4ddSPeter Zijlstra .procname = "ftrace_dump_on_oops", 512944ac425SSteven Rostedt .data = &ftrace_dump_on_oops, 513944ac425SSteven Rostedt .maxlen = sizeof(int), 514944ac425SSteven Rostedt .mode = 0644, 5156d456111SEric W. Biederman .proc_handler = proc_dointvec, 516944ac425SSteven Rostedt }, 517944ac425SSteven Rostedt #endif 518a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES 5191da177e4SLinus Torvalds { 5201da177e4SLinus Torvalds .procname = "modprobe", 5211da177e4SLinus Torvalds .data = &modprobe_path, 5221da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 5231da177e4SLinus Torvalds .mode = 0644, 5246d456111SEric W. Biederman .proc_handler = proc_dostring, 5251da177e4SLinus Torvalds }, 5263d43321bSKees Cook { 5273d43321bSKees Cook .procname = "modules_disabled", 5283d43321bSKees Cook .data = &modules_disabled, 5293d43321bSKees Cook .maxlen = sizeof(int), 5303d43321bSKees Cook .mode = 0644, 5313d43321bSKees Cook /* only handle a transition from default "0" to "1" */ 5326d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 5333d43321bSKees Cook .extra1 = &one, 5343d43321bSKees Cook .extra2 = &one, 5353d43321bSKees Cook }, 5361da177e4SLinus Torvalds #endif 53757ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) 5381da177e4SLinus Torvalds { 5391da177e4SLinus Torvalds .procname = "hotplug", 540312c004dSKay Sievers .data = &uevent_helper, 541312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 5421da177e4SLinus Torvalds .mode = 0644, 5436d456111SEric W. Biederman .proc_handler = proc_dostring, 5441da177e4SLinus Torvalds }, 5451da177e4SLinus Torvalds #endif 5461da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 5471da177e4SLinus Torvalds { 5481da177e4SLinus Torvalds .procname = "sg-big-buff", 5491da177e4SLinus Torvalds .data = &sg_big_buff, 5501da177e4SLinus Torvalds .maxlen = sizeof (int), 5511da177e4SLinus Torvalds .mode = 0444, 5526d456111SEric W. Biederman .proc_handler = proc_dointvec, 5531da177e4SLinus Torvalds }, 5541da177e4SLinus Torvalds #endif 5551da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 5561da177e4SLinus Torvalds { 5571da177e4SLinus Torvalds .procname = "acct", 5581da177e4SLinus Torvalds .data = &acct_parm, 5591da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 5601da177e4SLinus Torvalds .mode = 0644, 5616d456111SEric W. Biederman .proc_handler = proc_dointvec, 5621da177e4SLinus Torvalds }, 5631da177e4SLinus Torvalds #endif 5641da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 5651da177e4SLinus Torvalds { 5661da177e4SLinus Torvalds .procname = "sysrq", 5675d6f647fSIngo Molnar .data = &__sysrq_enabled, 5681da177e4SLinus Torvalds .maxlen = sizeof (int), 5691da177e4SLinus Torvalds .mode = 0644, 5706d456111SEric W. Biederman .proc_handler = proc_dointvec, 5711da177e4SLinus Torvalds }, 5721da177e4SLinus Torvalds #endif 573d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL 5741da177e4SLinus Torvalds { 5751da177e4SLinus Torvalds .procname = "cad_pid", 5769ec52099SCedric Le Goater .data = NULL, 5771da177e4SLinus Torvalds .maxlen = sizeof (int), 5781da177e4SLinus Torvalds .mode = 0600, 5796d456111SEric W. Biederman .proc_handler = proc_do_cad_pid, 5801da177e4SLinus Torvalds }, 581d6f8ff73SRandy Dunlap #endif 5821da177e4SLinus Torvalds { 5831da177e4SLinus Torvalds .procname = "threads-max", 5841da177e4SLinus Torvalds .data = &max_threads, 5851da177e4SLinus Torvalds .maxlen = sizeof(int), 5861da177e4SLinus Torvalds .mode = 0644, 5876d456111SEric W. Biederman .proc_handler = proc_dointvec, 5881da177e4SLinus Torvalds }, 5891da177e4SLinus Torvalds { 5901da177e4SLinus Torvalds .procname = "random", 5911da177e4SLinus Torvalds .mode = 0555, 5921da177e4SLinus Torvalds .child = random_table, 5931da177e4SLinus Torvalds }, 5941da177e4SLinus Torvalds { 5951da177e4SLinus Torvalds .procname = "overflowuid", 5961da177e4SLinus Torvalds .data = &overflowuid, 5971da177e4SLinus Torvalds .maxlen = sizeof(int), 5981da177e4SLinus Torvalds .mode = 0644, 5996d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6001da177e4SLinus Torvalds .extra1 = &minolduid, 6011da177e4SLinus Torvalds .extra2 = &maxolduid, 6021da177e4SLinus Torvalds }, 6031da177e4SLinus Torvalds { 6041da177e4SLinus Torvalds .procname = "overflowgid", 6051da177e4SLinus Torvalds .data = &overflowgid, 6061da177e4SLinus Torvalds .maxlen = sizeof(int), 6071da177e4SLinus Torvalds .mode = 0644, 6086d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6091da177e4SLinus Torvalds .extra1 = &minolduid, 6101da177e4SLinus Torvalds .extra2 = &maxolduid, 6111da177e4SLinus Torvalds }, 612347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 6131da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 6141da177e4SLinus Torvalds { 6151da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 6161da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 6171da177e4SLinus Torvalds .maxlen = sizeof(int), 6181da177e4SLinus Torvalds .mode = 0644, 6196d456111SEric W. Biederman .proc_handler = proc_dointvec, 6201da177e4SLinus Torvalds }, 6211da177e4SLinus Torvalds #endif 6221da177e4SLinus Torvalds { 6231da177e4SLinus Torvalds .procname = "userprocess_debug", 6241da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 6251da177e4SLinus Torvalds .maxlen = sizeof(int), 6261da177e4SLinus Torvalds .mode = 0644, 6276d456111SEric W. Biederman .proc_handler = proc_dointvec, 6281da177e4SLinus Torvalds }, 6291da177e4SLinus Torvalds #endif 6301da177e4SLinus Torvalds { 6311da177e4SLinus Torvalds .procname = "pid_max", 6321da177e4SLinus Torvalds .data = &pid_max, 6331da177e4SLinus Torvalds .maxlen = sizeof (int), 6341da177e4SLinus Torvalds .mode = 0644, 6356d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 6361da177e4SLinus Torvalds .extra1 = &pid_max_min, 6371da177e4SLinus Torvalds .extra2 = &pid_max_max, 6381da177e4SLinus Torvalds }, 6391da177e4SLinus Torvalds { 6401da177e4SLinus Torvalds .procname = "panic_on_oops", 6411da177e4SLinus Torvalds .data = &panic_on_oops, 6421da177e4SLinus Torvalds .maxlen = sizeof(int), 6431da177e4SLinus Torvalds .mode = 0644, 6446d456111SEric W. Biederman .proc_handler = proc_dointvec, 6451da177e4SLinus Torvalds }, 6467ef3d2fdSJoe Perches #if defined CONFIG_PRINTK 6477ef3d2fdSJoe Perches { 6487ef3d2fdSJoe Perches .procname = "printk", 6497ef3d2fdSJoe Perches .data = &console_loglevel, 6507ef3d2fdSJoe Perches .maxlen = 4*sizeof(int), 6517ef3d2fdSJoe Perches .mode = 0644, 6526d456111SEric W. Biederman .proc_handler = proc_dointvec, 6537ef3d2fdSJoe Perches }, 6541da177e4SLinus Torvalds { 6551da177e4SLinus Torvalds .procname = "printk_ratelimit", 656717115e1SDave Young .data = &printk_ratelimit_state.interval, 6571da177e4SLinus Torvalds .maxlen = sizeof(int), 6581da177e4SLinus Torvalds .mode = 0644, 6596d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 6601da177e4SLinus Torvalds }, 6611da177e4SLinus Torvalds { 6621da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 663717115e1SDave Young .data = &printk_ratelimit_state.burst, 6641da177e4SLinus Torvalds .maxlen = sizeof(int), 6651da177e4SLinus Torvalds .mode = 0644, 6666d456111SEric W. Biederman .proc_handler = proc_dointvec, 6671da177e4SLinus Torvalds }, 668af91322eSDave Young { 669af91322eSDave Young .procname = "printk_delay", 670af91322eSDave Young .data = &printk_delay_msec, 671af91322eSDave Young .maxlen = sizeof(int), 672af91322eSDave Young .mode = 0644, 6736d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 674af91322eSDave Young .extra1 = &zero, 675af91322eSDave Young .extra2 = &ten_thousand, 676af91322eSDave Young }, 6777ef3d2fdSJoe Perches #endif 6781da177e4SLinus Torvalds { 6791da177e4SLinus Torvalds .procname = "ngroups_max", 6801da177e4SLinus Torvalds .data = &ngroups_max, 6811da177e4SLinus Torvalds .maxlen = sizeof (int), 6821da177e4SLinus Torvalds .mode = 0444, 6836d456111SEric W. Biederman .proc_handler = proc_dointvec, 6841da177e4SLinus Torvalds }, 6851da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 6861da177e4SLinus Torvalds { 6871da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 6881da177e4SLinus Torvalds .data = &unknown_nmi_panic, 6891da177e4SLinus Torvalds .maxlen = sizeof (int), 6901da177e4SLinus Torvalds .mode = 0644, 6916d456111SEric W. Biederman .proc_handler = proc_dointvec, 6921da177e4SLinus Torvalds }, 693407984f1SDon Zickus { 694407984f1SDon Zickus .procname = "nmi_watchdog", 695407984f1SDon Zickus .data = &nmi_watchdog_enabled, 696407984f1SDon Zickus .maxlen = sizeof (int), 697407984f1SDon Zickus .mode = 0644, 6986d456111SEric W. Biederman .proc_handler = proc_nmi_enabled, 6991da177e4SLinus Torvalds }, 7001da177e4SLinus Torvalds #endif 7011da177e4SLinus Torvalds #if defined(CONFIG_X86) 7021da177e4SLinus Torvalds { 7038da5addaSDon Zickus .procname = "panic_on_unrecovered_nmi", 7048da5addaSDon Zickus .data = &panic_on_unrecovered_nmi, 7058da5addaSDon Zickus .maxlen = sizeof(int), 7068da5addaSDon Zickus .mode = 0644, 7076d456111SEric W. Biederman .proc_handler = proc_dointvec, 7088da5addaSDon Zickus }, 7098da5addaSDon Zickus { 7105211a242SKurt Garloff .procname = "panic_on_io_nmi", 7115211a242SKurt Garloff .data = &panic_on_io_nmi, 7125211a242SKurt Garloff .maxlen = sizeof(int), 7135211a242SKurt Garloff .mode = 0644, 7146d456111SEric W. Biederman .proc_handler = proc_dointvec, 7155211a242SKurt Garloff }, 7165211a242SKurt Garloff { 7171da177e4SLinus Torvalds .procname = "bootloader_type", 7181da177e4SLinus Torvalds .data = &bootloader_type, 7191da177e4SLinus Torvalds .maxlen = sizeof (int), 7201da177e4SLinus Torvalds .mode = 0444, 7216d456111SEric W. Biederman .proc_handler = proc_dointvec, 7221da177e4SLinus Torvalds }, 7230741f4d2SChuck Ebbert { 7245031296cSH. Peter Anvin .procname = "bootloader_version", 7255031296cSH. Peter Anvin .data = &bootloader_version, 7265031296cSH. Peter Anvin .maxlen = sizeof (int), 7275031296cSH. Peter Anvin .mode = 0444, 7286d456111SEric W. Biederman .proc_handler = proc_dointvec, 7295031296cSH. Peter Anvin }, 7305031296cSH. Peter Anvin { 7310741f4d2SChuck Ebbert .procname = "kstack_depth_to_print", 7320741f4d2SChuck Ebbert .data = &kstack_depth_to_print, 7330741f4d2SChuck Ebbert .maxlen = sizeof(int), 7340741f4d2SChuck Ebbert .mode = 0644, 7356d456111SEric W. Biederman .proc_handler = proc_dointvec, 7360741f4d2SChuck Ebbert }, 7376e7c4025SIngo Molnar { 7386e7c4025SIngo Molnar .procname = "io_delay_type", 7396e7c4025SIngo Molnar .data = &io_delay_type, 7406e7c4025SIngo Molnar .maxlen = sizeof(int), 7416e7c4025SIngo Molnar .mode = 0644, 7426d456111SEric W. Biederman .proc_handler = proc_dointvec, 7436e7c4025SIngo Molnar }, 7441da177e4SLinus Torvalds #endif 7457a9166e3SLuke Yang #if defined(CONFIG_MMU) 7461da177e4SLinus Torvalds { 7471da177e4SLinus Torvalds .procname = "randomize_va_space", 7481da177e4SLinus Torvalds .data = &randomize_va_space, 7491da177e4SLinus Torvalds .maxlen = sizeof(int), 7501da177e4SLinus Torvalds .mode = 0644, 7516d456111SEric W. Biederman .proc_handler = proc_dointvec, 7521da177e4SLinus Torvalds }, 7537a9166e3SLuke Yang #endif 7540152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP) 755951f22d5SMartin Schwidefsky { 756951f22d5SMartin Schwidefsky .procname = "spin_retry", 757951f22d5SMartin Schwidefsky .data = &spin_retry, 758951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 759951f22d5SMartin Schwidefsky .mode = 0644, 7606d456111SEric W. Biederman .proc_handler = proc_dointvec, 761951f22d5SMartin Schwidefsky }, 762951f22d5SMartin Schwidefsky #endif 763673d5b43SLen Brown #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 764c255d844SPavel Machek { 765c255d844SPavel Machek .procname = "acpi_video_flags", 76677afcf78SPavel Machek .data = &acpi_realmode_flags, 767c255d844SPavel Machek .maxlen = sizeof (unsigned long), 768c255d844SPavel Machek .mode = 0644, 7696d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 770c255d844SPavel Machek }, 771c255d844SPavel Machek #endif 772d2b176edSJes Sorensen #ifdef CONFIG_IA64 773d2b176edSJes Sorensen { 774d2b176edSJes Sorensen .procname = "ignore-unaligned-usertrap", 775d2b176edSJes Sorensen .data = &no_unaligned_warning, 776d2b176edSJes Sorensen .maxlen = sizeof (int), 777d2b176edSJes Sorensen .mode = 0644, 7786d456111SEric W. Biederman .proc_handler = proc_dointvec, 779d2b176edSJes Sorensen }, 78088fc241fSDoug Chapman { 78188fc241fSDoug Chapman .procname = "unaligned-dump-stack", 78288fc241fSDoug Chapman .data = &unaligned_dump_stack, 78388fc241fSDoug Chapman .maxlen = sizeof (int), 78488fc241fSDoug Chapman .mode = 0644, 7856d456111SEric W. Biederman .proc_handler = proc_dointvec, 78688fc241fSDoug Chapman }, 787d2b176edSJes Sorensen #endif 788c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP 789c4f3b63fSRavikiran G Thirumalai { 7909c44bc03SIngo Molnar .procname = "softlockup_panic", 7919c44bc03SIngo Molnar .data = &softlockup_panic, 7929c44bc03SIngo Molnar .maxlen = sizeof(int), 7939c44bc03SIngo Molnar .mode = 0644, 7946d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 7959c44bc03SIngo Molnar .extra1 = &zero, 7969c44bc03SIngo Molnar .extra2 = &one, 7979c44bc03SIngo Molnar }, 7989c44bc03SIngo Molnar { 799c4f3b63fSRavikiran G Thirumalai .procname = "softlockup_thresh", 800c4f3b63fSRavikiran G Thirumalai .data = &softlockup_thresh, 8019383d967SDimitri Sivanich .maxlen = sizeof(int), 802c4f3b63fSRavikiran G Thirumalai .mode = 0644, 8036d456111SEric W. Biederman .proc_handler = proc_dosoftlockup_thresh, 8049383d967SDimitri Sivanich .extra1 = &neg_one, 805c4f3b63fSRavikiran G Thirumalai .extra2 = &sixty, 806c4f3b63fSRavikiran G Thirumalai }, 807e162b39aSMandeep Singh Baines #endif 808e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK 809e162b39aSMandeep Singh Baines { 810e162b39aSMandeep Singh Baines .procname = "hung_task_panic", 811e162b39aSMandeep Singh Baines .data = &sysctl_hung_task_panic, 812e162b39aSMandeep Singh Baines .maxlen = sizeof(int), 813e162b39aSMandeep Singh Baines .mode = 0644, 8146d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 815e162b39aSMandeep Singh Baines .extra1 = &zero, 816e162b39aSMandeep Singh Baines .extra2 = &one, 817e162b39aSMandeep Singh Baines }, 81882a1fcb9SIngo Molnar { 81982a1fcb9SIngo Molnar .procname = "hung_task_check_count", 82082a1fcb9SIngo Molnar .data = &sysctl_hung_task_check_count, 82190739081SIngo Molnar .maxlen = sizeof(unsigned long), 82282a1fcb9SIngo Molnar .mode = 0644, 8236d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 82482a1fcb9SIngo Molnar }, 82582a1fcb9SIngo Molnar { 82682a1fcb9SIngo Molnar .procname = "hung_task_timeout_secs", 82782a1fcb9SIngo Molnar .data = &sysctl_hung_task_timeout_secs, 82890739081SIngo Molnar .maxlen = sizeof(unsigned long), 82982a1fcb9SIngo Molnar .mode = 0644, 8306d456111SEric W. Biederman .proc_handler = proc_dohung_task_timeout_secs, 83182a1fcb9SIngo Molnar }, 83282a1fcb9SIngo Molnar { 83382a1fcb9SIngo Molnar .procname = "hung_task_warnings", 83482a1fcb9SIngo Molnar .data = &sysctl_hung_task_warnings, 83590739081SIngo Molnar .maxlen = sizeof(unsigned long), 83682a1fcb9SIngo Molnar .mode = 0644, 8376d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 83882a1fcb9SIngo Molnar }, 839c4f3b63fSRavikiran G Thirumalai #endif 840bebfa101SAndi Kleen #ifdef CONFIG_COMPAT 841bebfa101SAndi Kleen { 842bebfa101SAndi Kleen .procname = "compat-log", 843bebfa101SAndi Kleen .data = &compat_log, 844bebfa101SAndi Kleen .maxlen = sizeof (int), 845bebfa101SAndi Kleen .mode = 0644, 8466d456111SEric W. Biederman .proc_handler = proc_dointvec, 847bebfa101SAndi Kleen }, 848bebfa101SAndi Kleen #endif 84923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES 85023f78d4aSIngo Molnar { 85123f78d4aSIngo Molnar .procname = "max_lock_depth", 85223f78d4aSIngo Molnar .data = &max_lock_depth, 85323f78d4aSIngo Molnar .maxlen = sizeof(int), 85423f78d4aSIngo Molnar .mode = 0644, 8556d456111SEric W. Biederman .proc_handler = proc_dointvec, 85623f78d4aSIngo Molnar }, 85723f78d4aSIngo Molnar #endif 85810a0a8d4SJeremy Fitzhardinge { 85910a0a8d4SJeremy Fitzhardinge .procname = "poweroff_cmd", 86010a0a8d4SJeremy Fitzhardinge .data = &poweroff_cmd, 86110a0a8d4SJeremy Fitzhardinge .maxlen = POWEROFF_CMD_PATH_LEN, 86210a0a8d4SJeremy Fitzhardinge .mode = 0644, 8636d456111SEric W. Biederman .proc_handler = proc_dostring, 86410a0a8d4SJeremy Fitzhardinge }, 8650b77f5bfSDavid Howells #ifdef CONFIG_KEYS 8660b77f5bfSDavid Howells { 8670b77f5bfSDavid Howells .procname = "keys", 8680b77f5bfSDavid Howells .mode = 0555, 8690b77f5bfSDavid Howells .child = key_sysctls, 8700b77f5bfSDavid Howells }, 8710b77f5bfSDavid Howells #endif 87231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST 87331a72bceSPaul E. McKenney { 87431a72bceSPaul E. McKenney .procname = "rcutorture_runnable", 87531a72bceSPaul E. McKenney .data = &rcutorture_runnable, 87631a72bceSPaul E. McKenney .maxlen = sizeof(int), 87731a72bceSPaul E. McKenney .mode = 0644, 8786d456111SEric W. Biederman .proc_handler = proc_dointvec, 87931a72bceSPaul E. McKenney }, 88031a72bceSPaul E. McKenney #endif 88112e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK 88212e22c5eSDavid Howells { 88312e22c5eSDavid Howells .procname = "slow-work", 88412e22c5eSDavid Howells .mode = 0555, 88512e22c5eSDavid Howells .child = slow_work_sysctls, 88612e22c5eSDavid Howells }, 88712e22c5eSDavid Howells #endif 888cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS 8891ccd1549SPeter Zijlstra { 890cdd6c482SIngo Molnar .procname = "perf_event_paranoid", 891cdd6c482SIngo Molnar .data = &sysctl_perf_event_paranoid, 892cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_paranoid), 8931ccd1549SPeter Zijlstra .mode = 0644, 8946d456111SEric W. Biederman .proc_handler = proc_dointvec, 8951ccd1549SPeter Zijlstra }, 896c5078f78SPeter Zijlstra { 897cdd6c482SIngo Molnar .procname = "perf_event_mlock_kb", 898cdd6c482SIngo Molnar .data = &sysctl_perf_event_mlock, 899cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_mlock), 900c5078f78SPeter Zijlstra .mode = 0644, 9016d456111SEric W. Biederman .proc_handler = proc_dointvec, 902c5078f78SPeter Zijlstra }, 903a78ac325SPeter Zijlstra { 904cdd6c482SIngo Molnar .procname = "perf_event_max_sample_rate", 905cdd6c482SIngo Molnar .data = &sysctl_perf_event_sample_rate, 906cdd6c482SIngo Molnar .maxlen = sizeof(sysctl_perf_event_sample_rate), 907a78ac325SPeter Zijlstra .mode = 0644, 9086d456111SEric W. Biederman .proc_handler = proc_dointvec, 909a78ac325SPeter Zijlstra }, 9101ccd1549SPeter Zijlstra #endif 911dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK 912dfec072eSVegard Nossum { 913dfec072eSVegard Nossum .procname = "kmemcheck", 914dfec072eSVegard Nossum .data = &kmemcheck_enabled, 915dfec072eSVegard Nossum .maxlen = sizeof(int), 916dfec072eSVegard Nossum .mode = 0644, 9176d456111SEric W. Biederman .proc_handler = proc_dointvec, 918dfec072eSVegard Nossum }, 919dfec072eSVegard Nossum #endif 920cb684b5bSJens Axboe #ifdef CONFIG_BLOCK 9215e605b64SJens Axboe { 9225e605b64SJens Axboe .procname = "blk_iopoll", 9235e605b64SJens Axboe .data = &blk_iopoll_enabled, 9245e605b64SJens Axboe .maxlen = sizeof(int), 9255e605b64SJens Axboe .mode = 0644, 9266d456111SEric W. Biederman .proc_handler = proc_dointvec, 9275e605b64SJens Axboe }, 928cb684b5bSJens Axboe #endif 929ed2c12f3SAndrew Morton /* 930ed2c12f3SAndrew Morton * NOTE: do not add new entries to this table unless you have read 931ed2c12f3SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 932ed2c12f3SAndrew Morton */ 9336fce56ecSEric W. Biederman { } 9341da177e4SLinus Torvalds }; 9351da177e4SLinus Torvalds 936d8217f07SEric W. Biederman static struct ctl_table vm_table[] = { 9371da177e4SLinus Torvalds { 9381da177e4SLinus Torvalds .procname = "overcommit_memory", 9391da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 9401da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 9411da177e4SLinus Torvalds .mode = 0644, 9426d456111SEric W. Biederman .proc_handler = proc_dointvec, 9431da177e4SLinus Torvalds }, 9441da177e4SLinus Torvalds { 945fadd8fbdSKAMEZAWA Hiroyuki .procname = "panic_on_oom", 946fadd8fbdSKAMEZAWA Hiroyuki .data = &sysctl_panic_on_oom, 947fadd8fbdSKAMEZAWA Hiroyuki .maxlen = sizeof(sysctl_panic_on_oom), 948fadd8fbdSKAMEZAWA Hiroyuki .mode = 0644, 9496d456111SEric W. Biederman .proc_handler = proc_dointvec, 950fadd8fbdSKAMEZAWA Hiroyuki }, 951fadd8fbdSKAMEZAWA Hiroyuki { 952fe071d7eSDavid Rientjes .procname = "oom_kill_allocating_task", 953fe071d7eSDavid Rientjes .data = &sysctl_oom_kill_allocating_task, 954fe071d7eSDavid Rientjes .maxlen = sizeof(sysctl_oom_kill_allocating_task), 955fe071d7eSDavid Rientjes .mode = 0644, 9566d456111SEric W. Biederman .proc_handler = proc_dointvec, 957fe071d7eSDavid Rientjes }, 958fe071d7eSDavid Rientjes { 959fef1bdd6SDavid Rientjes .procname = "oom_dump_tasks", 960fef1bdd6SDavid Rientjes .data = &sysctl_oom_dump_tasks, 961fef1bdd6SDavid Rientjes .maxlen = sizeof(sysctl_oom_dump_tasks), 962fef1bdd6SDavid Rientjes .mode = 0644, 9636d456111SEric W. Biederman .proc_handler = proc_dointvec, 964fef1bdd6SDavid Rientjes }, 965fef1bdd6SDavid Rientjes { 9661da177e4SLinus Torvalds .procname = "overcommit_ratio", 9671da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 9681da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 9691da177e4SLinus Torvalds .mode = 0644, 9706d456111SEric W. Biederman .proc_handler = proc_dointvec, 9711da177e4SLinus Torvalds }, 9721da177e4SLinus Torvalds { 9731da177e4SLinus Torvalds .procname = "page-cluster", 9741da177e4SLinus Torvalds .data = &page_cluster, 9751da177e4SLinus Torvalds .maxlen = sizeof(int), 9761da177e4SLinus Torvalds .mode = 0644, 9776d456111SEric W. Biederman .proc_handler = proc_dointvec, 9781da177e4SLinus Torvalds }, 9791da177e4SLinus Torvalds { 9801da177e4SLinus Torvalds .procname = "dirty_background_ratio", 9811da177e4SLinus Torvalds .data = &dirty_background_ratio, 9821da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 9831da177e4SLinus Torvalds .mode = 0644, 9846d456111SEric W. Biederman .proc_handler = dirty_background_ratio_handler, 9851da177e4SLinus Torvalds .extra1 = &zero, 9861da177e4SLinus Torvalds .extra2 = &one_hundred, 9871da177e4SLinus Torvalds }, 9881da177e4SLinus Torvalds { 9892da02997SDavid Rientjes .procname = "dirty_background_bytes", 9902da02997SDavid Rientjes .data = &dirty_background_bytes, 9912da02997SDavid Rientjes .maxlen = sizeof(dirty_background_bytes), 9922da02997SDavid Rientjes .mode = 0644, 9936d456111SEric W. Biederman .proc_handler = dirty_background_bytes_handler, 994fc3501d4SSven Wegener .extra1 = &one_ul, 9952da02997SDavid Rientjes }, 9962da02997SDavid Rientjes { 9971da177e4SLinus Torvalds .procname = "dirty_ratio", 9981da177e4SLinus Torvalds .data = &vm_dirty_ratio, 9991da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 10001da177e4SLinus Torvalds .mode = 0644, 10016d456111SEric W. Biederman .proc_handler = dirty_ratio_handler, 10021da177e4SLinus Torvalds .extra1 = &zero, 10031da177e4SLinus Torvalds .extra2 = &one_hundred, 10041da177e4SLinus Torvalds }, 10051da177e4SLinus Torvalds { 10062da02997SDavid Rientjes .procname = "dirty_bytes", 10072da02997SDavid Rientjes .data = &vm_dirty_bytes, 10082da02997SDavid Rientjes .maxlen = sizeof(vm_dirty_bytes), 10092da02997SDavid Rientjes .mode = 0644, 10106d456111SEric W. Biederman .proc_handler = dirty_bytes_handler, 10119e4a5bdaSAndrea Righi .extra1 = &dirty_bytes_min, 10122da02997SDavid Rientjes }, 10132da02997SDavid Rientjes { 10141da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 1015f6ef9438SBart Samwel .data = &dirty_writeback_interval, 1016f6ef9438SBart Samwel .maxlen = sizeof(dirty_writeback_interval), 10171da177e4SLinus Torvalds .mode = 0644, 10186d456111SEric W. Biederman .proc_handler = dirty_writeback_centisecs_handler, 10191da177e4SLinus Torvalds }, 10201da177e4SLinus Torvalds { 10211da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 1022f6ef9438SBart Samwel .data = &dirty_expire_interval, 1023f6ef9438SBart Samwel .maxlen = sizeof(dirty_expire_interval), 10241da177e4SLinus Torvalds .mode = 0644, 10256d456111SEric W. Biederman .proc_handler = proc_dointvec, 10261da177e4SLinus Torvalds }, 10271da177e4SLinus Torvalds { 10281da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 10291da177e4SLinus Torvalds .data = &nr_pdflush_threads, 10301da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 10311da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 10326d456111SEric W. Biederman .proc_handler = proc_dointvec, 10331da177e4SLinus Torvalds }, 10341da177e4SLinus Torvalds { 10351da177e4SLinus Torvalds .procname = "swappiness", 10361da177e4SLinus Torvalds .data = &vm_swappiness, 10371da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 10381da177e4SLinus Torvalds .mode = 0644, 10396d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 10401da177e4SLinus Torvalds .extra1 = &zero, 10411da177e4SLinus Torvalds .extra2 = &one_hundred, 10421da177e4SLinus Torvalds }, 10431da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 10441da177e4SLinus Torvalds { 10451da177e4SLinus Torvalds .procname = "nr_hugepages", 1046e5ff2159SAndi Kleen .data = NULL, 10471da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 10481da177e4SLinus Torvalds .mode = 0644, 10496d456111SEric W. Biederman .proc_handler = hugetlb_sysctl_handler, 10501da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 10511da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 10521da177e4SLinus Torvalds }, 105306808b08SLee Schermerhorn #ifdef CONFIG_NUMA 105406808b08SLee Schermerhorn { 105506808b08SLee Schermerhorn .procname = "nr_hugepages_mempolicy", 105606808b08SLee Schermerhorn .data = NULL, 105706808b08SLee Schermerhorn .maxlen = sizeof(unsigned long), 105806808b08SLee Schermerhorn .mode = 0644, 105906808b08SLee Schermerhorn .proc_handler = &hugetlb_mempolicy_sysctl_handler, 106006808b08SLee Schermerhorn .extra1 = (void *)&hugetlb_zero, 106106808b08SLee Schermerhorn .extra2 = (void *)&hugetlb_infinity, 106206808b08SLee Schermerhorn }, 106306808b08SLee Schermerhorn #endif 10641da177e4SLinus Torvalds { 10651da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 10661da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 10671da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 10681da177e4SLinus Torvalds .mode = 0644, 10696d456111SEric W. Biederman .proc_handler = proc_dointvec, 10701da177e4SLinus Torvalds }, 1071396faf03SMel Gorman { 1072396faf03SMel Gorman .procname = "hugepages_treat_as_movable", 1073396faf03SMel Gorman .data = &hugepages_treat_as_movable, 1074396faf03SMel Gorman .maxlen = sizeof(int), 1075396faf03SMel Gorman .mode = 0644, 10766d456111SEric W. Biederman .proc_handler = hugetlb_treat_movable_handler, 1077396faf03SMel Gorman }, 107854f9f80dSAdam Litke { 1079d1c3fb1fSNishanth Aravamudan .procname = "nr_overcommit_hugepages", 1080e5ff2159SAndi Kleen .data = NULL, 1081e5ff2159SAndi Kleen .maxlen = sizeof(unsigned long), 1082d1c3fb1fSNishanth Aravamudan .mode = 0644, 10836d456111SEric W. Biederman .proc_handler = hugetlb_overcommit_handler, 1084e5ff2159SAndi Kleen .extra1 = (void *)&hugetlb_zero, 1085e5ff2159SAndi Kleen .extra2 = (void *)&hugetlb_infinity, 1086d1c3fb1fSNishanth Aravamudan }, 10871da177e4SLinus Torvalds #endif 10881da177e4SLinus Torvalds { 10891da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 10901da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 10911da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 10921da177e4SLinus Torvalds .mode = 0644, 10936d456111SEric W. Biederman .proc_handler = lowmem_reserve_ratio_sysctl_handler, 10941da177e4SLinus Torvalds }, 10951da177e4SLinus Torvalds { 10969d0243bcSAndrew Morton .procname = "drop_caches", 10979d0243bcSAndrew Morton .data = &sysctl_drop_caches, 10989d0243bcSAndrew Morton .maxlen = sizeof(int), 10999d0243bcSAndrew Morton .mode = 0644, 11009d0243bcSAndrew Morton .proc_handler = drop_caches_sysctl_handler, 11019d0243bcSAndrew Morton }, 11029d0243bcSAndrew Morton { 11031da177e4SLinus Torvalds .procname = "min_free_kbytes", 11041da177e4SLinus Torvalds .data = &min_free_kbytes, 11051da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 11061da177e4SLinus Torvalds .mode = 0644, 11076d456111SEric W. Biederman .proc_handler = min_free_kbytes_sysctl_handler, 11081da177e4SLinus Torvalds .extra1 = &zero, 11091da177e4SLinus Torvalds }, 11108ad4b1fbSRohit Seth { 11118ad4b1fbSRohit Seth .procname = "percpu_pagelist_fraction", 11128ad4b1fbSRohit Seth .data = &percpu_pagelist_fraction, 11138ad4b1fbSRohit Seth .maxlen = sizeof(percpu_pagelist_fraction), 11148ad4b1fbSRohit Seth .mode = 0644, 11156d456111SEric W. Biederman .proc_handler = percpu_pagelist_fraction_sysctl_handler, 11168ad4b1fbSRohit Seth .extra1 = &min_percpu_pagelist_fract, 11178ad4b1fbSRohit Seth }, 11181da177e4SLinus Torvalds #ifdef CONFIG_MMU 11191da177e4SLinus Torvalds { 11201da177e4SLinus Torvalds .procname = "max_map_count", 11211da177e4SLinus Torvalds .data = &sysctl_max_map_count, 11221da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 11231da177e4SLinus Torvalds .mode = 0644, 11243e26120cSWANG Cong .proc_handler = proc_dointvec_minmax, 112570da2340SAmerigo Wang .extra1 = &zero, 11261da177e4SLinus Torvalds }, 1127dd8632a1SPaul Mundt #else 1128dd8632a1SPaul Mundt { 1129dd8632a1SPaul Mundt .procname = "nr_trim_pages", 1130dd8632a1SPaul Mundt .data = &sysctl_nr_trim_pages, 1131dd8632a1SPaul Mundt .maxlen = sizeof(sysctl_nr_trim_pages), 1132dd8632a1SPaul Mundt .mode = 0644, 11336d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1134dd8632a1SPaul Mundt .extra1 = &zero, 1135dd8632a1SPaul Mundt }, 11361da177e4SLinus Torvalds #endif 11371da177e4SLinus Torvalds { 11381da177e4SLinus Torvalds .procname = "laptop_mode", 11391da177e4SLinus Torvalds .data = &laptop_mode, 11401da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 11411da177e4SLinus Torvalds .mode = 0644, 11426d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 11431da177e4SLinus Torvalds }, 11441da177e4SLinus Torvalds { 11451da177e4SLinus Torvalds .procname = "block_dump", 11461da177e4SLinus Torvalds .data = &block_dump, 11471da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 11481da177e4SLinus Torvalds .mode = 0644, 11496d456111SEric W. Biederman .proc_handler = proc_dointvec, 11501da177e4SLinus Torvalds .extra1 = &zero, 11511da177e4SLinus Torvalds }, 11521da177e4SLinus Torvalds { 11531da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 11541da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 11551da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 11561da177e4SLinus Torvalds .mode = 0644, 11576d456111SEric W. Biederman .proc_handler = proc_dointvec, 11581da177e4SLinus Torvalds .extra1 = &zero, 11591da177e4SLinus Torvalds }, 11601da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 11611da177e4SLinus Torvalds { 11621da177e4SLinus Torvalds .procname = "legacy_va_layout", 11631da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 11641da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 11651da177e4SLinus Torvalds .mode = 0644, 11666d456111SEric W. Biederman .proc_handler = proc_dointvec, 11671da177e4SLinus Torvalds .extra1 = &zero, 11681da177e4SLinus Torvalds }, 11691da177e4SLinus Torvalds #endif 11701743660bSChristoph Lameter #ifdef CONFIG_NUMA 11711743660bSChristoph Lameter { 11721743660bSChristoph Lameter .procname = "zone_reclaim_mode", 11731743660bSChristoph Lameter .data = &zone_reclaim_mode, 11741743660bSChristoph Lameter .maxlen = sizeof(zone_reclaim_mode), 11751743660bSChristoph Lameter .mode = 0644, 11766d456111SEric W. Biederman .proc_handler = proc_dointvec, 1177c84db23cSChristoph Lameter .extra1 = &zero, 11781743660bSChristoph Lameter }, 11799614634fSChristoph Lameter { 11809614634fSChristoph Lameter .procname = "min_unmapped_ratio", 11819614634fSChristoph Lameter .data = &sysctl_min_unmapped_ratio, 11829614634fSChristoph Lameter .maxlen = sizeof(sysctl_min_unmapped_ratio), 11839614634fSChristoph Lameter .mode = 0644, 11846d456111SEric W. Biederman .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler, 11859614634fSChristoph Lameter .extra1 = &zero, 11869614634fSChristoph Lameter .extra2 = &one_hundred, 11879614634fSChristoph Lameter }, 11880ff38490SChristoph Lameter { 11890ff38490SChristoph Lameter .procname = "min_slab_ratio", 11900ff38490SChristoph Lameter .data = &sysctl_min_slab_ratio, 11910ff38490SChristoph Lameter .maxlen = sizeof(sysctl_min_slab_ratio), 11920ff38490SChristoph Lameter .mode = 0644, 11936d456111SEric W. Biederman .proc_handler = sysctl_min_slab_ratio_sysctl_handler, 11940ff38490SChristoph Lameter .extra1 = &zero, 11950ff38490SChristoph Lameter .extra2 = &one_hundred, 11960ff38490SChristoph Lameter }, 11971743660bSChristoph Lameter #endif 119877461ab3SChristoph Lameter #ifdef CONFIG_SMP 119977461ab3SChristoph Lameter { 120077461ab3SChristoph Lameter .procname = "stat_interval", 120177461ab3SChristoph Lameter .data = &sysctl_stat_interval, 120277461ab3SChristoph Lameter .maxlen = sizeof(sysctl_stat_interval), 120377461ab3SChristoph Lameter .mode = 0644, 12046d456111SEric W. Biederman .proc_handler = proc_dointvec_jiffies, 120577461ab3SChristoph Lameter }, 120677461ab3SChristoph Lameter #endif 12076e141546SDavid Howells #ifdef CONFIG_MMU 1208ed032189SEric Paris { 1209ed032189SEric Paris .procname = "mmap_min_addr", 1210788084abSEric Paris .data = &dac_mmap_min_addr, 1211ed032189SEric Paris .maxlen = sizeof(unsigned long), 1212ed032189SEric Paris .mode = 0644, 12136d456111SEric W. Biederman .proc_handler = mmap_min_addr_handler, 1214ed032189SEric Paris }, 12156e141546SDavid Howells #endif 1216f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA 1217f0c0b2b8SKAMEZAWA Hiroyuki { 1218f0c0b2b8SKAMEZAWA Hiroyuki .procname = "numa_zonelist_order", 1219f0c0b2b8SKAMEZAWA Hiroyuki .data = &numa_zonelist_order, 1220f0c0b2b8SKAMEZAWA Hiroyuki .maxlen = NUMA_ZONELIST_ORDER_LEN, 1221f0c0b2b8SKAMEZAWA Hiroyuki .mode = 0644, 12226d456111SEric W. Biederman .proc_handler = numa_zonelist_order_handler, 1223f0c0b2b8SKAMEZAWA Hiroyuki }, 1224f0c0b2b8SKAMEZAWA Hiroyuki #endif 12252b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ 12265c36e657SPaul Mundt (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) 1227e6e5494cSIngo Molnar { 1228e6e5494cSIngo Molnar .procname = "vdso_enabled", 1229e6e5494cSIngo Molnar .data = &vdso_enabled, 1230e6e5494cSIngo Molnar .maxlen = sizeof(vdso_enabled), 1231e6e5494cSIngo Molnar .mode = 0644, 12326d456111SEric W. Biederman .proc_handler = proc_dointvec, 1233e6e5494cSIngo Molnar .extra1 = &zero, 1234e6e5494cSIngo Molnar }, 1235e6e5494cSIngo Molnar #endif 1236195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM 1237195cf453SBron Gondwana { 1238195cf453SBron Gondwana .procname = "highmem_is_dirtyable", 1239195cf453SBron Gondwana .data = &vm_highmem_is_dirtyable, 1240195cf453SBron Gondwana .maxlen = sizeof(vm_highmem_is_dirtyable), 1241195cf453SBron Gondwana .mode = 0644, 12426d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1243195cf453SBron Gondwana .extra1 = &zero, 1244195cf453SBron Gondwana .extra2 = &one, 1245195cf453SBron Gondwana }, 1246195cf453SBron Gondwana #endif 12474be6f6bbSPeter Zijlstra { 12484be6f6bbSPeter Zijlstra .procname = "scan_unevictable_pages", 12494be6f6bbSPeter Zijlstra .data = &scan_unevictable_pages, 12504be6f6bbSPeter Zijlstra .maxlen = sizeof(scan_unevictable_pages), 12514be6f6bbSPeter Zijlstra .mode = 0644, 12526d456111SEric W. Biederman .proc_handler = scan_unevictable_handler, 12534be6f6bbSPeter Zijlstra }, 12546a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE 12556a46079cSAndi Kleen { 12566a46079cSAndi Kleen .procname = "memory_failure_early_kill", 12576a46079cSAndi Kleen .data = &sysctl_memory_failure_early_kill, 12586a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_early_kill), 12596a46079cSAndi Kleen .mode = 0644, 12606d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12616a46079cSAndi Kleen .extra1 = &zero, 12626a46079cSAndi Kleen .extra2 = &one, 12636a46079cSAndi Kleen }, 12646a46079cSAndi Kleen { 12656a46079cSAndi Kleen .procname = "memory_failure_recovery", 12666a46079cSAndi Kleen .data = &sysctl_memory_failure_recovery, 12676a46079cSAndi Kleen .maxlen = sizeof(sysctl_memory_failure_recovery), 12686a46079cSAndi Kleen .mode = 0644, 12696d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 12706a46079cSAndi Kleen .extra1 = &zero, 12716a46079cSAndi Kleen .extra2 = &one, 12726a46079cSAndi Kleen }, 12736a46079cSAndi Kleen #endif 12746a46079cSAndi Kleen 12752be7fe07SAndrew Morton /* 12762be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 12772be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 12782be7fe07SAndrew Morton */ 12796fce56ecSEric W. Biederman { } 12801da177e4SLinus Torvalds }; 12811da177e4SLinus Torvalds 12822abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1283d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = { 12846fce56ecSEric W. Biederman { } 12852abc26fcSEric W. Biederman }; 12862abc26fcSEric W. Biederman #endif 12872abc26fcSEric W. Biederman 1288d8217f07SEric W. Biederman static struct ctl_table fs_table[] = { 12891da177e4SLinus Torvalds { 12901da177e4SLinus Torvalds .procname = "inode-nr", 12911da177e4SLinus Torvalds .data = &inodes_stat, 12921da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 12931da177e4SLinus Torvalds .mode = 0444, 12946d456111SEric W. Biederman .proc_handler = proc_dointvec, 12951da177e4SLinus Torvalds }, 12961da177e4SLinus Torvalds { 12971da177e4SLinus Torvalds .procname = "inode-state", 12981da177e4SLinus Torvalds .data = &inodes_stat, 12991da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 13001da177e4SLinus Torvalds .mode = 0444, 13016d456111SEric W. Biederman .proc_handler = proc_dointvec, 13021da177e4SLinus Torvalds }, 13031da177e4SLinus Torvalds { 13041da177e4SLinus Torvalds .procname = "file-nr", 13051da177e4SLinus Torvalds .data = &files_stat, 13061da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 13071da177e4SLinus Torvalds .mode = 0444, 13086d456111SEric W. Biederman .proc_handler = proc_nr_files, 13091da177e4SLinus Torvalds }, 13101da177e4SLinus Torvalds { 13111da177e4SLinus Torvalds .procname = "file-max", 13121da177e4SLinus Torvalds .data = &files_stat.max_files, 13131da177e4SLinus Torvalds .maxlen = sizeof(int), 13141da177e4SLinus Torvalds .mode = 0644, 13156d456111SEric W. Biederman .proc_handler = proc_dointvec, 13161da177e4SLinus Torvalds }, 13171da177e4SLinus Torvalds { 13189cfe015aSEric Dumazet .procname = "nr_open", 13199cfe015aSEric Dumazet .data = &sysctl_nr_open, 13209cfe015aSEric Dumazet .maxlen = sizeof(int), 13219cfe015aSEric Dumazet .mode = 0644, 13226d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 1323eceea0b3SAl Viro .extra1 = &sysctl_nr_open_min, 1324eceea0b3SAl Viro .extra2 = &sysctl_nr_open_max, 13259cfe015aSEric Dumazet }, 13269cfe015aSEric Dumazet { 13271da177e4SLinus Torvalds .procname = "dentry-state", 13281da177e4SLinus Torvalds .data = &dentry_stat, 13291da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 13301da177e4SLinus Torvalds .mode = 0444, 13316d456111SEric W. Biederman .proc_handler = proc_dointvec, 13321da177e4SLinus Torvalds }, 13331da177e4SLinus Torvalds { 13341da177e4SLinus Torvalds .procname = "overflowuid", 13351da177e4SLinus Torvalds .data = &fs_overflowuid, 13361da177e4SLinus Torvalds .maxlen = sizeof(int), 13371da177e4SLinus Torvalds .mode = 0644, 13386d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13391da177e4SLinus Torvalds .extra1 = &minolduid, 13401da177e4SLinus Torvalds .extra2 = &maxolduid, 13411da177e4SLinus Torvalds }, 13421da177e4SLinus Torvalds { 13431da177e4SLinus Torvalds .procname = "overflowgid", 13441da177e4SLinus Torvalds .data = &fs_overflowgid, 13451da177e4SLinus Torvalds .maxlen = sizeof(int), 13461da177e4SLinus Torvalds .mode = 0644, 13476d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 13481da177e4SLinus Torvalds .extra1 = &minolduid, 13491da177e4SLinus Torvalds .extra2 = &maxolduid, 13501da177e4SLinus Torvalds }, 1351bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13521da177e4SLinus Torvalds { 13531da177e4SLinus Torvalds .procname = "leases-enable", 13541da177e4SLinus Torvalds .data = &leases_enable, 13551da177e4SLinus Torvalds .maxlen = sizeof(int), 13561da177e4SLinus Torvalds .mode = 0644, 13576d456111SEric W. Biederman .proc_handler = proc_dointvec, 13581da177e4SLinus Torvalds }, 1359bfcd17a6SThomas Petazzoni #endif 13601da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 13611da177e4SLinus Torvalds { 13621da177e4SLinus Torvalds .procname = "dir-notify-enable", 13631da177e4SLinus Torvalds .data = &dir_notify_enable, 13641da177e4SLinus Torvalds .maxlen = sizeof(int), 13651da177e4SLinus Torvalds .mode = 0644, 13666d456111SEric W. Biederman .proc_handler = proc_dointvec, 13671da177e4SLinus Torvalds }, 13681da177e4SLinus Torvalds #endif 13691da177e4SLinus Torvalds #ifdef CONFIG_MMU 1370bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING 13711da177e4SLinus Torvalds { 13721da177e4SLinus Torvalds .procname = "lease-break-time", 13731da177e4SLinus Torvalds .data = &lease_break_time, 13741da177e4SLinus Torvalds .maxlen = sizeof(int), 13751da177e4SLinus Torvalds .mode = 0644, 13766d456111SEric W. Biederman .proc_handler = proc_dointvec, 13771da177e4SLinus Torvalds }, 1378bfcd17a6SThomas Petazzoni #endif 1379ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO 13801da177e4SLinus Torvalds { 13811da177e4SLinus Torvalds .procname = "aio-nr", 13821da177e4SLinus Torvalds .data = &aio_nr, 13831da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 13841da177e4SLinus Torvalds .mode = 0444, 13856d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 13861da177e4SLinus Torvalds }, 13871da177e4SLinus Torvalds { 13881da177e4SLinus Torvalds .procname = "aio-max-nr", 13891da177e4SLinus Torvalds .data = &aio_max_nr, 13901da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 13911da177e4SLinus Torvalds .mode = 0644, 13926d456111SEric W. Biederman .proc_handler = proc_doulongvec_minmax, 13931da177e4SLinus Torvalds }, 1394ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */ 13952d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER 13960399cb08SRobert Love { 13970399cb08SRobert Love .procname = "inotify", 13980399cb08SRobert Love .mode = 0555, 13990399cb08SRobert Love .child = inotify_table, 14000399cb08SRobert Love }, 14010399cb08SRobert Love #endif 14027ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL 14037ef9964eSDavide Libenzi { 14047ef9964eSDavide Libenzi .procname = "epoll", 14057ef9964eSDavide Libenzi .mode = 0555, 14067ef9964eSDavide Libenzi .child = epoll_table, 14077ef9964eSDavide Libenzi }, 14087ef9964eSDavide Libenzi #endif 14091da177e4SLinus Torvalds #endif 1410d6e71144SAlan Cox { 1411d6e71144SAlan Cox .procname = "suid_dumpable", 1412d6e71144SAlan Cox .data = &suid_dumpable, 1413d6e71144SAlan Cox .maxlen = sizeof(int), 1414d6e71144SAlan Cox .mode = 0644, 14156d456111SEric W. Biederman .proc_handler = proc_dointvec_minmax, 14168e654fbaSMatthew Wilcox .extra1 = &zero, 14178e654fbaSMatthew Wilcox .extra2 = &two, 1418d6e71144SAlan Cox }, 14192abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 14202abc26fcSEric W. Biederman { 14212abc26fcSEric W. Biederman .procname = "binfmt_misc", 14222abc26fcSEric W. Biederman .mode = 0555, 14232abc26fcSEric W. Biederman .child = binfmt_misc_table, 14242abc26fcSEric W. Biederman }, 14252abc26fcSEric W. Biederman #endif 14262be7fe07SAndrew Morton /* 14272be7fe07SAndrew Morton * NOTE: do not add new entries to this table unless you have read 14282be7fe07SAndrew Morton * Documentation/sysctl/ctl_unnumbered.txt 14292be7fe07SAndrew Morton */ 14306fce56ecSEric W. Biederman { } 14311da177e4SLinus Torvalds }; 14321da177e4SLinus Torvalds 1433d8217f07SEric W. Biederman static struct ctl_table debug_table[] = { 14344b177647SDavid S. Miller #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) 1435abd4f750SMasoud Asgharifard Sharbiani { 1436abd4f750SMasoud Asgharifard Sharbiani .procname = "exception-trace", 1437abd4f750SMasoud Asgharifard Sharbiani .data = &show_unhandled_signals, 1438abd4f750SMasoud Asgharifard Sharbiani .maxlen = sizeof(int), 1439abd4f750SMasoud Asgharifard Sharbiani .mode = 0644, 1440abd4f750SMasoud Asgharifard Sharbiani .proc_handler = proc_dointvec 1441abd4f750SMasoud Asgharifard Sharbiani }, 1442abd4f750SMasoud Asgharifard Sharbiani #endif 1443b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES) 1444b2be84dfSMasami Hiramatsu { 1445b2be84dfSMasami Hiramatsu .procname = "kprobes-optimization", 1446b2be84dfSMasami Hiramatsu .data = &sysctl_kprobes_optimization, 1447b2be84dfSMasami Hiramatsu .maxlen = sizeof(int), 1448b2be84dfSMasami Hiramatsu .mode = 0644, 1449b2be84dfSMasami Hiramatsu .proc_handler = proc_kprobes_optimization_handler, 1450b2be84dfSMasami Hiramatsu .extra1 = &zero, 1451b2be84dfSMasami Hiramatsu .extra2 = &one, 1452b2be84dfSMasami Hiramatsu }, 1453b2be84dfSMasami Hiramatsu #endif 14546fce56ecSEric W. Biederman { } 14551da177e4SLinus Torvalds }; 14561da177e4SLinus Torvalds 1457d8217f07SEric W. Biederman static struct ctl_table dev_table[] = { 14586fce56ecSEric W. Biederman { } 14591da177e4SLinus Torvalds }; 14601da177e4SLinus Torvalds 1461330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 1462330d57fbSAl Viro 1463330d57fbSAl Viro /* called under sysctl_lock */ 1464330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 1465330d57fbSAl Viro { 1466330d57fbSAl Viro if (unlikely(p->unregistering)) 1467330d57fbSAl Viro return 0; 1468330d57fbSAl Viro p->used++; 1469330d57fbSAl Viro return 1; 1470330d57fbSAl Viro } 1471330d57fbSAl Viro 1472330d57fbSAl Viro /* called under sysctl_lock */ 1473330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1474330d57fbSAl Viro { 1475330d57fbSAl Viro if (!--p->used) 1476330d57fbSAl Viro if (unlikely(p->unregistering)) 1477330d57fbSAl Viro complete(p->unregistering); 1478330d57fbSAl Viro } 1479330d57fbSAl Viro 1480330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1481330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1482330d57fbSAl Viro { 1483330d57fbSAl Viro /* 1484330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1485330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1486330d57fbSAl Viro */ 1487330d57fbSAl Viro if (unlikely(p->used)) { 1488330d57fbSAl Viro struct completion wait; 1489330d57fbSAl Viro init_completion(&wait); 1490330d57fbSAl Viro p->unregistering = &wait; 1491330d57fbSAl Viro spin_unlock(&sysctl_lock); 1492330d57fbSAl Viro wait_for_completion(&wait); 1493330d57fbSAl Viro spin_lock(&sysctl_lock); 1494f7e6ced4SAl Viro } else { 1495f7e6ced4SAl Viro /* anything non-NULL; we'll never dereference it */ 1496f7e6ced4SAl Viro p->unregistering = ERR_PTR(-EINVAL); 1497330d57fbSAl Viro } 1498330d57fbSAl Viro /* 1499330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1500330d57fbSAl Viro * list in do_sysctl() relies on that. 1501330d57fbSAl Viro */ 1502330d57fbSAl Viro list_del_init(&p->ctl_entry); 1503330d57fbSAl Viro } 1504330d57fbSAl Viro 1505f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head) 1506f7e6ced4SAl Viro { 1507f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1508f7e6ced4SAl Viro head->count++; 1509f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1510f7e6ced4SAl Viro } 1511f7e6ced4SAl Viro 1512f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1513f7e6ced4SAl Viro { 1514f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1515f7e6ced4SAl Viro if (!--head->count) 1516f7e6ced4SAl Viro kfree(head); 1517f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1518f7e6ced4SAl Viro } 1519f7e6ced4SAl Viro 1520f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head) 1521f7e6ced4SAl Viro { 1522f7e6ced4SAl Viro if (!head) 1523f7e6ced4SAl Viro BUG(); 1524f7e6ced4SAl Viro spin_lock(&sysctl_lock); 1525f7e6ced4SAl Viro if (!use_table(head)) 1526f7e6ced4SAl Viro head = ERR_PTR(-ENOENT); 1527f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 1528f7e6ced4SAl Viro return head; 1529f7e6ced4SAl Viro } 1530f7e6ced4SAl Viro 1531805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head) 1532805b5d5eSEric W. Biederman { 1533805b5d5eSEric W. Biederman if (!head) 1534805b5d5eSEric W. Biederman return; 1535805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1536805b5d5eSEric W. Biederman unuse_table(head); 1537805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1538805b5d5eSEric W. Biederman } 1539805b5d5eSEric W. Biederman 154073455092SAl Viro static struct ctl_table_set * 154173455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces) 154273455092SAl Viro { 154373455092SAl Viro struct ctl_table_set *set = &root->default_set; 154473455092SAl Viro if (root->lookup) 154573455092SAl Viro set = root->lookup(root, namespaces); 154673455092SAl Viro return set; 154773455092SAl Viro } 154873455092SAl Viro 1549e51b6ba0SEric W. Biederman static struct list_head * 1550e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces) 1551805b5d5eSEric W. Biederman { 155273455092SAl Viro struct ctl_table_set *set = lookup_header_set(root, namespaces); 155373455092SAl Viro return &set->list; 1554e51b6ba0SEric W. Biederman } 1555e51b6ba0SEric W. Biederman 1556e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 1557e51b6ba0SEric W. Biederman struct ctl_table_header *prev) 1558e51b6ba0SEric W. Biederman { 1559e51b6ba0SEric W. Biederman struct ctl_table_root *root; 1560e51b6ba0SEric W. Biederman struct list_head *header_list; 1561805b5d5eSEric W. Biederman struct ctl_table_header *head; 1562805b5d5eSEric W. Biederman struct list_head *tmp; 1563e51b6ba0SEric W. Biederman 1564805b5d5eSEric W. Biederman spin_lock(&sysctl_lock); 1565805b5d5eSEric W. Biederman if (prev) { 1566e51b6ba0SEric W. Biederman head = prev; 1567805b5d5eSEric W. Biederman tmp = &prev->ctl_entry; 1568805b5d5eSEric W. Biederman unuse_table(prev); 1569805b5d5eSEric W. Biederman goto next; 1570805b5d5eSEric W. Biederman } 1571805b5d5eSEric W. Biederman tmp = &root_table_header.ctl_entry; 1572805b5d5eSEric W. Biederman for (;;) { 1573805b5d5eSEric W. Biederman head = list_entry(tmp, struct ctl_table_header, ctl_entry); 1574805b5d5eSEric W. Biederman 1575805b5d5eSEric W. Biederman if (!use_table(head)) 1576805b5d5eSEric W. Biederman goto next; 1577805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1578805b5d5eSEric W. Biederman return head; 1579805b5d5eSEric W. Biederman next: 1580e51b6ba0SEric W. Biederman root = head->root; 1581805b5d5eSEric W. Biederman tmp = tmp->next; 1582e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1583e51b6ba0SEric W. Biederman if (tmp != header_list) 1584e51b6ba0SEric W. Biederman continue; 1585e51b6ba0SEric W. Biederman 1586e51b6ba0SEric W. Biederman do { 1587e51b6ba0SEric W. Biederman root = list_entry(root->root_list.next, 1588e51b6ba0SEric W. Biederman struct ctl_table_root, root_list); 1589e51b6ba0SEric W. Biederman if (root == &sysctl_table_root) 1590e51b6ba0SEric W. Biederman goto out; 1591e51b6ba0SEric W. Biederman header_list = lookup_header_list(root, namespaces); 1592e51b6ba0SEric W. Biederman } while (list_empty(header_list)); 1593e51b6ba0SEric W. Biederman tmp = header_list->next; 1594805b5d5eSEric W. Biederman } 1595e51b6ba0SEric W. Biederman out: 1596805b5d5eSEric W. Biederman spin_unlock(&sysctl_lock); 1597805b5d5eSEric W. Biederman return NULL; 1598805b5d5eSEric W. Biederman } 1599805b5d5eSEric W. Biederman 1600e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev) 1601e51b6ba0SEric W. Biederman { 1602e51b6ba0SEric W. Biederman return __sysctl_head_next(current->nsproxy, prev); 1603e51b6ba0SEric W. Biederman } 1604e51b6ba0SEric W. Biederman 1605e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root) 1606e51b6ba0SEric W. Biederman { 1607e51b6ba0SEric W. Biederman spin_lock(&sysctl_lock); 1608e51b6ba0SEric W. Biederman list_add_tail(&root->root_list, &sysctl_table_root.root_list); 1609e51b6ba0SEric W. Biederman spin_unlock(&sysctl_lock); 1610e51b6ba0SEric W. Biederman } 1611e51b6ba0SEric W. Biederman 16121da177e4SLinus Torvalds /* 16131ff007ebSEric W. Biederman * sysctl_perm does NOT grant the superuser all rights automatically, because 16141da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 16151da177e4SLinus Torvalds */ 16161da177e4SLinus Torvalds 16171da177e4SLinus Torvalds static int test_perm(int mode, int op) 16181da177e4SLinus Torvalds { 161976aac0e9SDavid Howells if (!current_euid()) 16201da177e4SLinus Torvalds mode >>= 6; 16211da177e4SLinus Torvalds else if (in_egroup_p(0)) 16221da177e4SLinus Torvalds mode >>= 3; 1623e6305c43SAl Viro if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0) 16241da177e4SLinus Torvalds return 0; 16251da177e4SLinus Torvalds return -EACCES; 16261da177e4SLinus Torvalds } 16271da177e4SLinus Torvalds 1628d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) 16291da177e4SLinus Torvalds { 16301da177e4SLinus Torvalds int error; 1631d7321cd6SPavel Emelyanov int mode; 1632d7321cd6SPavel Emelyanov 1633e6305c43SAl Viro error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC)); 16341da177e4SLinus Torvalds if (error) 16351da177e4SLinus Torvalds return error; 1636d7321cd6SPavel Emelyanov 1637d7321cd6SPavel Emelyanov if (root->permissions) 1638d7321cd6SPavel Emelyanov mode = root->permissions(root, current->nsproxy, table); 1639d7321cd6SPavel Emelyanov else 1640d7321cd6SPavel Emelyanov mode = table->mode; 1641d7321cd6SPavel Emelyanov 1642d7321cd6SPavel Emelyanov return test_perm(mode, op); 16431da177e4SLinus Torvalds } 16441da177e4SLinus Torvalds 1645d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) 1646d912b0ccSEric W. Biederman { 16472315ffa0SEric W. Biederman for (; table->procname; table++) { 1648d912b0ccSEric W. Biederman table->parent = parent; 1649d912b0ccSEric W. Biederman if (table->child) 1650d912b0ccSEric W. Biederman sysctl_set_parent(table, table->child); 1651d912b0ccSEric W. Biederman } 1652d912b0ccSEric W. Biederman } 1653d912b0ccSEric W. Biederman 1654d912b0ccSEric W. Biederman static __init int sysctl_init(void) 1655d912b0ccSEric W. Biederman { 1656d912b0ccSEric W. Biederman sysctl_set_parent(NULL, root_table); 165788f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 165888f458e4SHolger Schurig { 165988f458e4SHolger Schurig int err; 1660e51b6ba0SEric W. Biederman err = sysctl_check_table(current->nsproxy, root_table); 166188f458e4SHolger Schurig } 166288f458e4SHolger Schurig #endif 1663d912b0ccSEric W. Biederman return 0; 1664d912b0ccSEric W. Biederman } 1665d912b0ccSEric W. Biederman 1666d912b0ccSEric W. Biederman core_initcall(sysctl_init); 1667d912b0ccSEric W. Biederman 1668bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch, 1669bfbcf034SAl Viro struct ctl_table *table) 1670ae7edeccSAl Viro { 1671ae7edeccSAl Viro struct ctl_table *p; 1672ae7edeccSAl Viro const char *s = branch->procname; 1673ae7edeccSAl Viro 1674ae7edeccSAl Viro /* branch should have named subdirectory as its first element */ 1675ae7edeccSAl Viro if (!s || !branch->child) 1676bfbcf034SAl Viro return NULL; 1677ae7edeccSAl Viro 1678ae7edeccSAl Viro /* ... and nothing else */ 16792315ffa0SEric W. Biederman if (branch[1].procname) 1680bfbcf034SAl Viro return NULL; 1681ae7edeccSAl Viro 1682ae7edeccSAl Viro /* table should contain subdirectory with the same name */ 16832315ffa0SEric W. Biederman for (p = table; p->procname; p++) { 1684ae7edeccSAl Viro if (!p->child) 1685ae7edeccSAl Viro continue; 1686ae7edeccSAl Viro if (p->procname && strcmp(p->procname, s) == 0) 1687bfbcf034SAl Viro return p; 1688ae7edeccSAl Viro } 1689bfbcf034SAl Viro return NULL; 1690ae7edeccSAl Viro } 1691ae7edeccSAl Viro 1692ae7edeccSAl Viro /* see if attaching q to p would be an improvement */ 1693ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q) 1694ae7edeccSAl Viro { 1695ae7edeccSAl Viro struct ctl_table *to = p->ctl_table, *by = q->ctl_table; 1696bfbcf034SAl Viro struct ctl_table *next; 1697ae7edeccSAl Viro int is_better = 0; 1698ae7edeccSAl Viro int not_in_parent = !p->attached_by; 1699ae7edeccSAl Viro 1700bfbcf034SAl Viro while ((next = is_branch_in(by, to)) != NULL) { 1701ae7edeccSAl Viro if (by == q->attached_by) 1702ae7edeccSAl Viro is_better = 1; 1703ae7edeccSAl Viro if (to == p->attached_by) 1704ae7edeccSAl Viro not_in_parent = 1; 1705ae7edeccSAl Viro by = by->child; 1706bfbcf034SAl Viro to = next->child; 1707ae7edeccSAl Viro } 1708ae7edeccSAl Viro 1709ae7edeccSAl Viro if (is_better && not_in_parent) { 1710ae7edeccSAl Viro q->attached_by = by; 1711ae7edeccSAl Viro q->attached_to = to; 1712ae7edeccSAl Viro q->parent = p; 1713ae7edeccSAl Viro } 1714ae7edeccSAl Viro } 1715ae7edeccSAl Viro 17161da177e4SLinus Torvalds /** 1717e51b6ba0SEric W. Biederman * __register_sysctl_paths - register a sysctl hierarchy 1718e51b6ba0SEric W. Biederman * @root: List of sysctl headers to register on 1719e51b6ba0SEric W. Biederman * @namespaces: Data to compute which lists of sysctl entries are visible 172029e796fdSEric W. Biederman * @path: The path to the directory the sysctl table is in. 17211da177e4SLinus Torvalds * @table: the top-level table structure 17221da177e4SLinus Torvalds * 17231da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 172429e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 17251da177e4SLinus Torvalds * 1726d8217f07SEric W. Biederman * The members of the &struct ctl_table structure are used as follows: 17271da177e4SLinus Torvalds * 17281da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 17291da177e4SLinus Torvalds * enter a sysctl file 17301da177e4SLinus Torvalds * 17311da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 17321da177e4SLinus Torvalds * 17331da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 17341da177e4SLinus Torvalds * 17351da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 17361da177e4SLinus Torvalds * 17371da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 17381da177e4SLinus Torvalds * %NULL. 17391da177e4SLinus Torvalds * 17401da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 17411da177e4SLinus Torvalds * 17421da177e4SLinus Torvalds * de - for internal use by the sysctl routines 17431da177e4SLinus Torvalds * 17441da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 17451da177e4SLinus Torvalds * 17461da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 17471da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 17481da177e4SLinus Torvalds * 17491da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 17501da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 17511da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 17521da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 17531da177e4SLinus Torvalds * 17541da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 17551da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 17561da177e4SLinus Torvalds * directory handler). Several default handlers are available to 17571da177e4SLinus Torvalds * cover common cases - 17581da177e4SLinus Torvalds * 17591da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 17601da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 17611da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 17621da177e4SLinus Torvalds * 17631da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 17641da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 17651da177e4SLinus Torvalds * 17661da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 17671da177e4SLinus Torvalds * to the table header on success. 17681da177e4SLinus Torvalds */ 1769e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths( 1770e51b6ba0SEric W. Biederman struct ctl_table_root *root, 1771e51b6ba0SEric W. Biederman struct nsproxy *namespaces, 1772e51b6ba0SEric W. Biederman const struct ctl_path *path, struct ctl_table *table) 17731da177e4SLinus Torvalds { 177429e796fdSEric W. Biederman struct ctl_table_header *header; 177529e796fdSEric W. Biederman struct ctl_table *new, **prevp; 177629e796fdSEric W. Biederman unsigned int n, npath; 1777ae7edeccSAl Viro struct ctl_table_set *set; 177829e796fdSEric W. Biederman 177929e796fdSEric W. Biederman /* Count the path components */ 17802315ffa0SEric W. Biederman for (npath = 0; path[npath].procname; ++npath) 178129e796fdSEric W. Biederman ; 178229e796fdSEric W. Biederman 178329e796fdSEric W. Biederman /* 178429e796fdSEric W. Biederman * For each path component, allocate a 2-element ctl_table array. 178529e796fdSEric W. Biederman * The first array element will be filled with the sysctl entry 17862315ffa0SEric W. Biederman * for this, the second will be the sentinel (procname == 0). 178729e796fdSEric W. Biederman * 178829e796fdSEric W. Biederman * We allocate everything in one go so that we don't have to 178929e796fdSEric W. Biederman * worry about freeing additional memory in unregister_sysctl_table. 179029e796fdSEric W. Biederman */ 179129e796fdSEric W. Biederman header = kzalloc(sizeof(struct ctl_table_header) + 179229e796fdSEric W. Biederman (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL); 179329e796fdSEric W. Biederman if (!header) 17941da177e4SLinus Torvalds return NULL; 179529e796fdSEric W. Biederman 179629e796fdSEric W. Biederman new = (struct ctl_table *) (header + 1); 179729e796fdSEric W. Biederman 179829e796fdSEric W. Biederman /* Now connect the dots */ 179929e796fdSEric W. Biederman prevp = &header->ctl_table; 180029e796fdSEric W. Biederman for (n = 0; n < npath; ++n, ++path) { 180129e796fdSEric W. Biederman /* Copy the procname */ 180229e796fdSEric W. Biederman new->procname = path->procname; 180329e796fdSEric W. Biederman new->mode = 0555; 180429e796fdSEric W. Biederman 180529e796fdSEric W. Biederman *prevp = new; 180629e796fdSEric W. Biederman prevp = &new->child; 180729e796fdSEric W. Biederman 180829e796fdSEric W. Biederman new += 2; 180929e796fdSEric W. Biederman } 181029e796fdSEric W. Biederman *prevp = table; 181123eb06deSEric W. Biederman header->ctl_table_arg = table; 181229e796fdSEric W. Biederman 181329e796fdSEric W. Biederman INIT_LIST_HEAD(&header->ctl_entry); 181429e796fdSEric W. Biederman header->used = 0; 181529e796fdSEric W. Biederman header->unregistering = NULL; 1816e51b6ba0SEric W. Biederman header->root = root; 181729e796fdSEric W. Biederman sysctl_set_parent(NULL, header->ctl_table); 1818f7e6ced4SAl Viro header->count = 1; 181988f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK 1820e51b6ba0SEric W. Biederman if (sysctl_check_table(namespaces, header->ctl_table)) { 182129e796fdSEric W. Biederman kfree(header); 1822fc6cd25bSEric W. Biederman return NULL; 1823fc6cd25bSEric W. Biederman } 182488f458e4SHolger Schurig #endif 1825330d57fbSAl Viro spin_lock(&sysctl_lock); 182673455092SAl Viro header->set = lookup_header_set(root, namespaces); 1827ae7edeccSAl Viro header->attached_by = header->ctl_table; 1828ae7edeccSAl Viro header->attached_to = root_table; 1829ae7edeccSAl Viro header->parent = &root_table_header; 1830ae7edeccSAl Viro for (set = header->set; set; set = set->parent) { 1831ae7edeccSAl Viro struct ctl_table_header *p; 1832ae7edeccSAl Viro list_for_each_entry(p, &set->list, ctl_entry) { 1833ae7edeccSAl Viro if (p->unregistering) 1834ae7edeccSAl Viro continue; 1835ae7edeccSAl Viro try_attach(p, header); 1836ae7edeccSAl Viro } 1837ae7edeccSAl Viro } 1838ae7edeccSAl Viro header->parent->count++; 183973455092SAl Viro list_add_tail(&header->ctl_entry, &header->set->list); 1840330d57fbSAl Viro spin_unlock(&sysctl_lock); 184129e796fdSEric W. Biederman 184229e796fdSEric W. Biederman return header; 184329e796fdSEric W. Biederman } 184429e796fdSEric W. Biederman 184529e796fdSEric W. Biederman /** 1846e51b6ba0SEric W. Biederman * register_sysctl_table_path - register a sysctl table hierarchy 1847e51b6ba0SEric W. Biederman * @path: The path to the directory the sysctl table is in. 1848e51b6ba0SEric W. Biederman * @table: the top-level table structure 1849e51b6ba0SEric W. Biederman * 1850e51b6ba0SEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1851e51b6ba0SEric W. Biederman * array. A completely 0 filled entry terminates the table. 1852e51b6ba0SEric W. Biederman * 1853e51b6ba0SEric W. Biederman * See __register_sysctl_paths for more details. 1854e51b6ba0SEric W. Biederman */ 1855e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 1856e51b6ba0SEric W. Biederman struct ctl_table *table) 1857e51b6ba0SEric W. Biederman { 1858e51b6ba0SEric W. Biederman return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, 1859e51b6ba0SEric W. Biederman path, table); 1860e51b6ba0SEric W. Biederman } 1861e51b6ba0SEric W. Biederman 1862e51b6ba0SEric W. Biederman /** 186329e796fdSEric W. Biederman * register_sysctl_table - register a sysctl table hierarchy 186429e796fdSEric W. Biederman * @table: the top-level table structure 186529e796fdSEric W. Biederman * 186629e796fdSEric W. Biederman * Register a sysctl table hierarchy. @table should be a filled in ctl_table 186729e796fdSEric W. Biederman * array. A completely 0 filled entry terminates the table. 186829e796fdSEric W. Biederman * 186929e796fdSEric W. Biederman * See register_sysctl_paths for more details. 187029e796fdSEric W. Biederman */ 187129e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table) 187229e796fdSEric W. Biederman { 187329e796fdSEric W. Biederman static const struct ctl_path null_path[] = { {} }; 187429e796fdSEric W. Biederman 187529e796fdSEric W. Biederman return register_sysctl_paths(null_path, table); 18761da177e4SLinus Torvalds } 18771da177e4SLinus Torvalds 18781da177e4SLinus Torvalds /** 18791da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 18801da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 18811da177e4SLinus Torvalds * 18821da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 18831da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 18841da177e4SLinus Torvalds */ 18851da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 18861da177e4SLinus Torvalds { 1887330d57fbSAl Viro might_sleep(); 1888f1dad166SPavel Emelyanov 1889f1dad166SPavel Emelyanov if (header == NULL) 1890f1dad166SPavel Emelyanov return; 1891f1dad166SPavel Emelyanov 1892330d57fbSAl Viro spin_lock(&sysctl_lock); 1893330d57fbSAl Viro start_unregistering(header); 1894ae7edeccSAl Viro if (!--header->parent->count) { 1895ae7edeccSAl Viro WARN_ON(1); 1896ae7edeccSAl Viro kfree(header->parent); 1897ae7edeccSAl Viro } 1898f7e6ced4SAl Viro if (!--header->count) 18991da177e4SLinus Torvalds kfree(header); 1900f7e6ced4SAl Viro spin_unlock(&sysctl_lock); 19011da177e4SLinus Torvalds } 19021da177e4SLinus Torvalds 19039043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p) 19049043476fSAl Viro { 19059043476fSAl Viro struct ctl_table_set *set = p->set; 19069043476fSAl Viro int res; 19079043476fSAl Viro spin_lock(&sysctl_lock); 19089043476fSAl Viro if (p->unregistering) 19099043476fSAl Viro res = 0; 19109043476fSAl Viro else if (!set->is_seen) 19119043476fSAl Viro res = 1; 19129043476fSAl Viro else 19139043476fSAl Viro res = set->is_seen(set); 19149043476fSAl Viro spin_unlock(&sysctl_lock); 19159043476fSAl Viro return res; 19169043476fSAl Viro } 19179043476fSAl Viro 191873455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 191973455092SAl Viro struct ctl_table_set *parent, 192073455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 192173455092SAl Viro { 192273455092SAl Viro INIT_LIST_HEAD(&p->list); 192373455092SAl Viro p->parent = parent ? parent : &sysctl_table_root.default_set; 192473455092SAl Viro p->is_seen = is_seen; 192573455092SAl Viro } 192673455092SAl Viro 1927b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */ 1928d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table) 1929b89a8171SEric W. Biederman { 1930b89a8171SEric W. Biederman return NULL; 1931b89a8171SEric W. Biederman } 1932b89a8171SEric W. Biederman 193329e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, 193429e796fdSEric W. Biederman struct ctl_table *table) 193529e796fdSEric W. Biederman { 193629e796fdSEric W. Biederman return NULL; 193729e796fdSEric W. Biederman } 193829e796fdSEric W. Biederman 1939b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table) 1940b89a8171SEric W. Biederman { 1941b89a8171SEric W. Biederman } 1942b89a8171SEric W. Biederman 194373455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p, 194473455092SAl Viro struct ctl_table_set *parent, 194573455092SAl Viro int (*is_seen)(struct ctl_table_set *)) 194673455092SAl Viro { 194773455092SAl Viro } 194873455092SAl Viro 1949f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head) 1950f7e6ced4SAl Viro { 1951f7e6ced4SAl Viro } 1952f7e6ced4SAl Viro 1953b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */ 1954b89a8171SEric W. Biederman 19551da177e4SLinus Torvalds /* 19561da177e4SLinus Torvalds * /proc/sys support 19571da177e4SLinus Torvalds */ 19581da177e4SLinus Torvalds 1959b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL 19601da177e4SLinus Torvalds 1961b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write, 19628d65af78SAlexey Dobriyan void __user *buffer, 1963b1ba4dddSAdrian Bunk size_t *lenp, loff_t *ppos) 1964f5dd3d6fSSam Vilain { 1965f5dd3d6fSSam Vilain size_t len; 1966f5dd3d6fSSam Vilain char __user *p; 1967f5dd3d6fSSam Vilain char c; 1968f5dd3d6fSSam Vilain 19698d060877SOleg Nesterov if (!data || !maxlen || !*lenp) { 1970f5dd3d6fSSam Vilain *lenp = 0; 1971f5dd3d6fSSam Vilain return 0; 1972f5dd3d6fSSam Vilain } 1973f5dd3d6fSSam Vilain 1974f5dd3d6fSSam Vilain if (write) { 1975f5dd3d6fSSam Vilain len = 0; 1976f5dd3d6fSSam Vilain p = buffer; 1977f5dd3d6fSSam Vilain while (len < *lenp) { 1978f5dd3d6fSSam Vilain if (get_user(c, p++)) 1979f5dd3d6fSSam Vilain return -EFAULT; 1980f5dd3d6fSSam Vilain if (c == 0 || c == '\n') 1981f5dd3d6fSSam Vilain break; 1982f5dd3d6fSSam Vilain len++; 1983f5dd3d6fSSam Vilain } 1984f5dd3d6fSSam Vilain if (len >= maxlen) 1985f5dd3d6fSSam Vilain len = maxlen-1; 1986f5dd3d6fSSam Vilain if(copy_from_user(data, buffer, len)) 1987f5dd3d6fSSam Vilain return -EFAULT; 1988f5dd3d6fSSam Vilain ((char *) data)[len] = 0; 1989f5dd3d6fSSam Vilain *ppos += *lenp; 1990f5dd3d6fSSam Vilain } else { 1991f5dd3d6fSSam Vilain len = strlen(data); 1992f5dd3d6fSSam Vilain if (len > maxlen) 1993f5dd3d6fSSam Vilain len = maxlen; 19948d060877SOleg Nesterov 19958d060877SOleg Nesterov if (*ppos > len) { 19968d060877SOleg Nesterov *lenp = 0; 19978d060877SOleg Nesterov return 0; 19988d060877SOleg Nesterov } 19998d060877SOleg Nesterov 20008d060877SOleg Nesterov data += *ppos; 20018d060877SOleg Nesterov len -= *ppos; 20028d060877SOleg Nesterov 2003f5dd3d6fSSam Vilain if (len > *lenp) 2004f5dd3d6fSSam Vilain len = *lenp; 2005f5dd3d6fSSam Vilain if (len) 2006f5dd3d6fSSam Vilain if(copy_to_user(buffer, data, len)) 2007f5dd3d6fSSam Vilain return -EFAULT; 2008f5dd3d6fSSam Vilain if (len < *lenp) { 2009f5dd3d6fSSam Vilain if(put_user('\n', ((char __user *) buffer) + len)) 2010f5dd3d6fSSam Vilain return -EFAULT; 2011f5dd3d6fSSam Vilain len++; 2012f5dd3d6fSSam Vilain } 2013f5dd3d6fSSam Vilain *lenp = len; 2014f5dd3d6fSSam Vilain *ppos += len; 2015f5dd3d6fSSam Vilain } 2016f5dd3d6fSSam Vilain return 0; 2017f5dd3d6fSSam Vilain } 2018f5dd3d6fSSam Vilain 20191da177e4SLinus Torvalds /** 20201da177e4SLinus Torvalds * proc_dostring - read a string sysctl 20211da177e4SLinus Torvalds * @table: the sysctl table 20221da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20231da177e4SLinus Torvalds * @buffer: the user buffer 20241da177e4SLinus Torvalds * @lenp: the size of the user buffer 20251da177e4SLinus Torvalds * @ppos: file position 20261da177e4SLinus Torvalds * 20271da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 20281da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 20291da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 20301da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 20311da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 20321da177e4SLinus Torvalds * not large enough. 20331da177e4SLinus Torvalds * 20341da177e4SLinus Torvalds * Returns 0 on success. 20351da177e4SLinus Torvalds */ 20368d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 20371da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20381da177e4SLinus Torvalds { 20398d65af78SAlexey Dobriyan return _proc_do_string(table->data, table->maxlen, write, 2040f5dd3d6fSSam Vilain buffer, lenp, ppos); 20411da177e4SLinus Torvalds } 20421da177e4SLinus Torvalds 2043*00b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf) 2044*00b7c339SAmerigo Wang { 2045*00b7c339SAmerigo Wang size_t ret; 2046*00b7c339SAmerigo Wang char *tmp = skip_spaces(*buf); 2047*00b7c339SAmerigo Wang ret = tmp - *buf; 2048*00b7c339SAmerigo Wang *buf = tmp; 2049*00b7c339SAmerigo Wang return ret; 2050*00b7c339SAmerigo Wang } 20511da177e4SLinus Torvalds 2052*00b7c339SAmerigo Wang #define TMPBUFLEN 22 2053*00b7c339SAmerigo Wang /** 2054*00b7c339SAmerigo Wang * proc_get_long - reads an ASCII formated integer from a user buffer 2055*00b7c339SAmerigo Wang * 2056*00b7c339SAmerigo Wang * @buf - a kernel buffer 2057*00b7c339SAmerigo Wang * @size - size of the kernel buffer 2058*00b7c339SAmerigo Wang * @val - this is where the number will be stored 2059*00b7c339SAmerigo Wang * @neg - set to %TRUE if number is negative 2060*00b7c339SAmerigo Wang * @perm_tr - a vector which contains the allowed trailers 2061*00b7c339SAmerigo Wang * @perm_tr_len - size of the perm_tr vector 2062*00b7c339SAmerigo Wang * @tr - pointer to store the trailer character 2063*00b7c339SAmerigo Wang * 2064*00b7c339SAmerigo Wang * In case of success 0 is returned and buf and size are updated with 2065*00b7c339SAmerigo Wang * the amount of bytes read. If tr is non NULL and a trailing 2066*00b7c339SAmerigo Wang * character exist (size is non zero after returning from this 2067*00b7c339SAmerigo Wang * function) tr is updated with the trailing character. 2068*00b7c339SAmerigo Wang */ 2069*00b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size, 2070*00b7c339SAmerigo Wang unsigned long *val, bool *neg, 2071*00b7c339SAmerigo Wang const char *perm_tr, unsigned perm_tr_len, char *tr) 2072*00b7c339SAmerigo Wang { 2073*00b7c339SAmerigo Wang int len; 2074*00b7c339SAmerigo Wang char *p, tmp[TMPBUFLEN]; 2075*00b7c339SAmerigo Wang 2076*00b7c339SAmerigo Wang if (!*size) 2077*00b7c339SAmerigo Wang return -EINVAL; 2078*00b7c339SAmerigo Wang 2079*00b7c339SAmerigo Wang len = *size; 2080*00b7c339SAmerigo Wang if (len > TMPBUFLEN - 1) 2081*00b7c339SAmerigo Wang len = TMPBUFLEN - 1; 2082*00b7c339SAmerigo Wang 2083*00b7c339SAmerigo Wang memcpy(tmp, *buf, len); 2084*00b7c339SAmerigo Wang 2085*00b7c339SAmerigo Wang tmp[len] = 0; 2086*00b7c339SAmerigo Wang p = tmp; 2087*00b7c339SAmerigo Wang if (*p == '-' && *size > 1) { 2088*00b7c339SAmerigo Wang *neg = true; 2089*00b7c339SAmerigo Wang p++; 2090*00b7c339SAmerigo Wang } else 2091*00b7c339SAmerigo Wang *neg = false; 2092*00b7c339SAmerigo Wang if (!isdigit(*p)) 2093*00b7c339SAmerigo Wang return -EINVAL; 2094*00b7c339SAmerigo Wang 2095*00b7c339SAmerigo Wang *val = simple_strtoul(p, &p, 0); 2096*00b7c339SAmerigo Wang 2097*00b7c339SAmerigo Wang len = p - tmp; 2098*00b7c339SAmerigo Wang 2099*00b7c339SAmerigo Wang /* We don't know if the next char is whitespace thus we may accept 2100*00b7c339SAmerigo Wang * invalid integers (e.g. 1234...a) or two integers instead of one 2101*00b7c339SAmerigo Wang * (e.g. 123...1). So lets not allow such large numbers. */ 2102*00b7c339SAmerigo Wang if (len == TMPBUFLEN - 1) 2103*00b7c339SAmerigo Wang return -EINVAL; 2104*00b7c339SAmerigo Wang 2105*00b7c339SAmerigo Wang if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) 2106*00b7c339SAmerigo Wang return -EINVAL; 2107*00b7c339SAmerigo Wang 2108*00b7c339SAmerigo Wang if (tr && (len < *size)) 2109*00b7c339SAmerigo Wang *tr = *p; 2110*00b7c339SAmerigo Wang 2111*00b7c339SAmerigo Wang *buf += len; 2112*00b7c339SAmerigo Wang *size -= len; 2113*00b7c339SAmerigo Wang 2114*00b7c339SAmerigo Wang return 0; 2115*00b7c339SAmerigo Wang } 2116*00b7c339SAmerigo Wang 2117*00b7c339SAmerigo Wang /** 2118*00b7c339SAmerigo Wang * proc_put_long - coverts an integer to a decimal ASCII formated string 2119*00b7c339SAmerigo Wang * 2120*00b7c339SAmerigo Wang * @buf - the user buffer 2121*00b7c339SAmerigo Wang * @size - the size of the user buffer 2122*00b7c339SAmerigo Wang * @val - the integer to be converted 2123*00b7c339SAmerigo Wang * @neg - sign of the number, %TRUE for negative 2124*00b7c339SAmerigo Wang * 2125*00b7c339SAmerigo Wang * In case of success 0 is returned and buf and size are updated with 2126*00b7c339SAmerigo Wang * the amount of bytes read. 2127*00b7c339SAmerigo Wang */ 2128*00b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val, 2129*00b7c339SAmerigo Wang bool neg) 2130*00b7c339SAmerigo Wang { 2131*00b7c339SAmerigo Wang int len; 2132*00b7c339SAmerigo Wang char tmp[TMPBUFLEN], *p = tmp; 2133*00b7c339SAmerigo Wang 2134*00b7c339SAmerigo Wang sprintf(p, "%s%lu", neg ? "-" : "", val); 2135*00b7c339SAmerigo Wang len = strlen(tmp); 2136*00b7c339SAmerigo Wang if (len > *size) 2137*00b7c339SAmerigo Wang len = *size; 2138*00b7c339SAmerigo Wang if (copy_to_user(*buf, tmp, len)) 2139*00b7c339SAmerigo Wang return -EFAULT; 2140*00b7c339SAmerigo Wang *size -= len; 2141*00b7c339SAmerigo Wang *buf += len; 2142*00b7c339SAmerigo Wang return 0; 2143*00b7c339SAmerigo Wang } 2144*00b7c339SAmerigo Wang #undef TMPBUFLEN 2145*00b7c339SAmerigo Wang 2146*00b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c) 2147*00b7c339SAmerigo Wang { 2148*00b7c339SAmerigo Wang if (*size) { 2149*00b7c339SAmerigo Wang char __user **buffer = (char __user **)buf; 2150*00b7c339SAmerigo Wang if (put_user(c, *buffer)) 2151*00b7c339SAmerigo Wang return -EFAULT; 2152*00b7c339SAmerigo Wang (*size)--, (*buffer)++; 2153*00b7c339SAmerigo Wang *buf = *buffer; 2154*00b7c339SAmerigo Wang } 2155*00b7c339SAmerigo Wang return 0; 2156*00b7c339SAmerigo Wang } 2157*00b7c339SAmerigo Wang 2158*00b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp, 21591da177e4SLinus Torvalds int *valp, 21601da177e4SLinus Torvalds int write, void *data) 21611da177e4SLinus Torvalds { 21621da177e4SLinus Torvalds if (write) { 21631da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 21641da177e4SLinus Torvalds } else { 21651da177e4SLinus Torvalds int val = *valp; 21661da177e4SLinus Torvalds if (val < 0) { 2167*00b7c339SAmerigo Wang *negp = true; 21681da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 21691da177e4SLinus Torvalds } else { 2170*00b7c339SAmerigo Wang *negp = false; 21711da177e4SLinus Torvalds *lvalp = (unsigned long)val; 21721da177e4SLinus Torvalds } 21731da177e4SLinus Torvalds } 21741da177e4SLinus Torvalds return 0; 21751da177e4SLinus Torvalds } 21761da177e4SLinus Torvalds 2177*00b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 2178*00b7c339SAmerigo Wang 2179d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, 21808d65af78SAlexey Dobriyan int write, void __user *buffer, 2181fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2182*00b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 21831da177e4SLinus Torvalds int write, void *data), 21841da177e4SLinus Torvalds void *data) 21851da177e4SLinus Torvalds { 2186*00b7c339SAmerigo Wang int *i, vleft, first = 1, err = 0; 2187*00b7c339SAmerigo Wang unsigned long page = 0; 2188*00b7c339SAmerigo Wang size_t left; 2189*00b7c339SAmerigo Wang char *kbuf; 21901da177e4SLinus Torvalds 2191*00b7c339SAmerigo Wang if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { 21921da177e4SLinus Torvalds *lenp = 0; 21931da177e4SLinus Torvalds return 0; 21941da177e4SLinus Torvalds } 21951da177e4SLinus Torvalds 2196fcfbd547SKirill Korotaev i = (int *) tbl_data; 21971da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 21981da177e4SLinus Torvalds left = *lenp; 21991da177e4SLinus Torvalds 22001da177e4SLinus Torvalds if (!conv) 22011da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 22021da177e4SLinus Torvalds 2203*00b7c339SAmerigo Wang if (write) { 2204*00b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 2205*00b7c339SAmerigo Wang left = PAGE_SIZE - 1; 2206*00b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 2207*00b7c339SAmerigo Wang kbuf = (char *) page; 2208*00b7c339SAmerigo Wang if (!kbuf) 2209*00b7c339SAmerigo Wang return -ENOMEM; 2210*00b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 2211*00b7c339SAmerigo Wang err = -EFAULT; 2212*00b7c339SAmerigo Wang goto free; 2213*00b7c339SAmerigo Wang } 2214*00b7c339SAmerigo Wang kbuf[left] = 0; 2215*00b7c339SAmerigo Wang } 2216*00b7c339SAmerigo Wang 22171da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 2218*00b7c339SAmerigo Wang unsigned long lval; 2219*00b7c339SAmerigo Wang bool neg; 2220*00b7c339SAmerigo Wang 22211da177e4SLinus Torvalds if (write) { 2222*00b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 2223*00b7c339SAmerigo Wang 2224*00b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &lval, &neg, 2225*00b7c339SAmerigo Wang proc_wspace_sep, 2226*00b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 2227*00b7c339SAmerigo Wang if (err) 22281da177e4SLinus Torvalds break; 2229*00b7c339SAmerigo Wang if (conv(&neg, &lval, i, 1, data)) { 2230*00b7c339SAmerigo Wang err = -EINVAL; 2231*00b7c339SAmerigo Wang break; 22321da177e4SLinus Torvalds } 22331da177e4SLinus Torvalds } else { 2234*00b7c339SAmerigo Wang if (conv(&neg, &lval, i, 0, data)) { 2235*00b7c339SAmerigo Wang err = -EINVAL; 2236*00b7c339SAmerigo Wang break; 2237*00b7c339SAmerigo Wang } 22381da177e4SLinus Torvalds if (!first) 2239*00b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 2240*00b7c339SAmerigo Wang if (err) 22411da177e4SLinus Torvalds break; 2242*00b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, lval, neg); 2243*00b7c339SAmerigo Wang if (err) 2244*00b7c339SAmerigo Wang break; 22451da177e4SLinus Torvalds } 22461da177e4SLinus Torvalds } 22471da177e4SLinus Torvalds 2248*00b7c339SAmerigo Wang if (!write && !first && left && !err) 2249*00b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 2250*00b7c339SAmerigo Wang if (write && !err) 2251*00b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 2252*00b7c339SAmerigo Wang free: 22531da177e4SLinus Torvalds if (write) { 2254*00b7c339SAmerigo Wang free_page(page); 2255*00b7c339SAmerigo Wang if (first) 2256*00b7c339SAmerigo Wang return err ? : -EINVAL; 22571da177e4SLinus Torvalds } 22581da177e4SLinus Torvalds *lenp -= left; 22591da177e4SLinus Torvalds *ppos += *lenp; 2260*00b7c339SAmerigo Wang return err; 22611da177e4SLinus Torvalds } 22621da177e4SLinus Torvalds 22638d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write, 2264fcfbd547SKirill Korotaev void __user *buffer, size_t *lenp, loff_t *ppos, 2265*00b7c339SAmerigo Wang int (*conv)(bool *negp, unsigned long *lvalp, int *valp, 2266fcfbd547SKirill Korotaev int write, void *data), 2267fcfbd547SKirill Korotaev void *data) 2268fcfbd547SKirill Korotaev { 22698d65af78SAlexey Dobriyan return __do_proc_dointvec(table->data, table, write, 2270fcfbd547SKirill Korotaev buffer, lenp, ppos, conv, data); 2271fcfbd547SKirill Korotaev } 2272fcfbd547SKirill Korotaev 22731da177e4SLinus Torvalds /** 22741da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 22751da177e4SLinus Torvalds * @table: the sysctl table 22761da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 22771da177e4SLinus Torvalds * @buffer: the user buffer 22781da177e4SLinus Torvalds * @lenp: the size of the user buffer 22791da177e4SLinus Torvalds * @ppos: file position 22801da177e4SLinus Torvalds * 22811da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 22821da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 22831da177e4SLinus Torvalds * 22841da177e4SLinus Torvalds * Returns 0 on success. 22851da177e4SLinus Torvalds */ 22868d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 22871da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 22881da177e4SLinus Torvalds { 22898d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 22901da177e4SLinus Torvalds NULL,NULL); 22911da177e4SLinus Torvalds } 22921da177e4SLinus Torvalds 229334f5a398STheodore Ts'o /* 229434f5a398STheodore Ts'o * Taint values can only be increased 229525ddbb18SAndi Kleen * This means we can safely use a temporary. 229634f5a398STheodore Ts'o */ 22978d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write, 229834f5a398STheodore Ts'o void __user *buffer, size_t *lenp, loff_t *ppos) 229934f5a398STheodore Ts'o { 230025ddbb18SAndi Kleen struct ctl_table t; 230125ddbb18SAndi Kleen unsigned long tmptaint = get_taint(); 230225ddbb18SAndi Kleen int err; 230334f5a398STheodore Ts'o 230491fcd412SBastian Blank if (write && !capable(CAP_SYS_ADMIN)) 230534f5a398STheodore Ts'o return -EPERM; 230634f5a398STheodore Ts'o 230725ddbb18SAndi Kleen t = *table; 230825ddbb18SAndi Kleen t.data = &tmptaint; 23098d65af78SAlexey Dobriyan err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos); 231025ddbb18SAndi Kleen if (err < 0) 231125ddbb18SAndi Kleen return err; 231225ddbb18SAndi Kleen 231325ddbb18SAndi Kleen if (write) { 231425ddbb18SAndi Kleen /* 231525ddbb18SAndi Kleen * Poor man's atomic or. Not worth adding a primitive 231625ddbb18SAndi Kleen * to everyone's atomic.h for this 231725ddbb18SAndi Kleen */ 231825ddbb18SAndi Kleen int i; 231925ddbb18SAndi Kleen for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { 232025ddbb18SAndi Kleen if ((tmptaint >> i) & 1) 232125ddbb18SAndi Kleen add_taint(i); 232225ddbb18SAndi Kleen } 232325ddbb18SAndi Kleen } 232425ddbb18SAndi Kleen 232525ddbb18SAndi Kleen return err; 232634f5a398STheodore Ts'o } 232734f5a398STheodore Ts'o 23281da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 23291da177e4SLinus Torvalds int *min; 23301da177e4SLinus Torvalds int *max; 23311da177e4SLinus Torvalds }; 23321da177e4SLinus Torvalds 2333*00b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, 23341da177e4SLinus Torvalds int *valp, 23351da177e4SLinus Torvalds int write, void *data) 23361da177e4SLinus Torvalds { 23371da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 23381da177e4SLinus Torvalds if (write) { 23391da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 23401da177e4SLinus Torvalds if ((param->min && *param->min > val) || 23411da177e4SLinus Torvalds (param->max && *param->max < val)) 23421da177e4SLinus Torvalds return -EINVAL; 23431da177e4SLinus Torvalds *valp = val; 23441da177e4SLinus Torvalds } else { 23451da177e4SLinus Torvalds int val = *valp; 23461da177e4SLinus Torvalds if (val < 0) { 2347*00b7c339SAmerigo Wang *negp = true; 23481da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 23491da177e4SLinus Torvalds } else { 2350*00b7c339SAmerigo Wang *negp = false; 23511da177e4SLinus Torvalds *lvalp = (unsigned long)val; 23521da177e4SLinus Torvalds } 23531da177e4SLinus Torvalds } 23541da177e4SLinus Torvalds return 0; 23551da177e4SLinus Torvalds } 23561da177e4SLinus Torvalds 23571da177e4SLinus Torvalds /** 23581da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 23591da177e4SLinus Torvalds * @table: the sysctl table 23601da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 23611da177e4SLinus Torvalds * @buffer: the user buffer 23621da177e4SLinus Torvalds * @lenp: the size of the user buffer 23631da177e4SLinus Torvalds * @ppos: file position 23641da177e4SLinus Torvalds * 23651da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 23661da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 23671da177e4SLinus Torvalds * 23681da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 23691da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 23701da177e4SLinus Torvalds * 23711da177e4SLinus Torvalds * Returns 0 on success. 23721da177e4SLinus Torvalds */ 23738d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 23741da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23751da177e4SLinus Torvalds { 23761da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 23771da177e4SLinus Torvalds .min = (int *) table->extra1, 23781da177e4SLinus Torvalds .max = (int *) table->extra2, 23791da177e4SLinus Torvalds }; 23808d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 23811da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 23821da177e4SLinus Torvalds } 23831da177e4SLinus Torvalds 2384d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, 23851da177e4SLinus Torvalds void __user *buffer, 23861da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 23871da177e4SLinus Torvalds unsigned long convmul, 23881da177e4SLinus Torvalds unsigned long convdiv) 23891da177e4SLinus Torvalds { 2390*00b7c339SAmerigo Wang unsigned long *i, *min, *max; 2391*00b7c339SAmerigo Wang int vleft, first = 1, err = 0; 2392*00b7c339SAmerigo Wang unsigned long page = 0; 2393*00b7c339SAmerigo Wang size_t left; 2394*00b7c339SAmerigo Wang char *kbuf; 23951da177e4SLinus Torvalds 2396*00b7c339SAmerigo Wang if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { 23971da177e4SLinus Torvalds *lenp = 0; 23981da177e4SLinus Torvalds return 0; 23991da177e4SLinus Torvalds } 24001da177e4SLinus Torvalds 2401fcfbd547SKirill Korotaev i = (unsigned long *) data; 24021da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 24031da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 24041da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 24051da177e4SLinus Torvalds left = *lenp; 24061da177e4SLinus Torvalds 24071da177e4SLinus Torvalds if (write) { 2408*00b7c339SAmerigo Wang if (left > PAGE_SIZE - 1) 2409*00b7c339SAmerigo Wang left = PAGE_SIZE - 1; 2410*00b7c339SAmerigo Wang page = __get_free_page(GFP_TEMPORARY); 2411*00b7c339SAmerigo Wang kbuf = (char *) page; 2412*00b7c339SAmerigo Wang if (!kbuf) 2413*00b7c339SAmerigo Wang return -ENOMEM; 2414*00b7c339SAmerigo Wang if (copy_from_user(kbuf, buffer, left)) { 2415*00b7c339SAmerigo Wang err = -EFAULT; 2416*00b7c339SAmerigo Wang goto free; 24171da177e4SLinus Torvalds } 2418*00b7c339SAmerigo Wang kbuf[left] = 0; 24191da177e4SLinus Torvalds } 24201da177e4SLinus Torvalds 2421*00b7c339SAmerigo Wang for (; left && vleft--; i++, min++, max++, first=0) { 2422*00b7c339SAmerigo Wang unsigned long val; 2423*00b7c339SAmerigo Wang 2424*00b7c339SAmerigo Wang if (write) { 2425*00b7c339SAmerigo Wang bool neg; 2426*00b7c339SAmerigo Wang 2427*00b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 2428*00b7c339SAmerigo Wang 2429*00b7c339SAmerigo Wang err = proc_get_long(&kbuf, &left, &val, &neg, 2430*00b7c339SAmerigo Wang proc_wspace_sep, 2431*00b7c339SAmerigo Wang sizeof(proc_wspace_sep), NULL); 2432*00b7c339SAmerigo Wang if (err) 2433*00b7c339SAmerigo Wang break; 24341da177e4SLinus Torvalds if (neg) 24351da177e4SLinus Torvalds continue; 24361da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 24371da177e4SLinus Torvalds continue; 24381da177e4SLinus Torvalds *i = val; 24391da177e4SLinus Torvalds } else { 2440*00b7c339SAmerigo Wang val = convdiv * (*i) / convmul; 24411da177e4SLinus Torvalds if (!first) 2442*00b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\t'); 2443*00b7c339SAmerigo Wang err = proc_put_long(&buffer, &left, val, false); 2444*00b7c339SAmerigo Wang if (err) 2445*00b7c339SAmerigo Wang break; 24461da177e4SLinus Torvalds } 24471da177e4SLinus Torvalds } 24481da177e4SLinus Torvalds 2449*00b7c339SAmerigo Wang if (!write && !first && left && !err) 2450*00b7c339SAmerigo Wang err = proc_put_char(&buffer, &left, '\n'); 2451*00b7c339SAmerigo Wang if (write && !err) 2452*00b7c339SAmerigo Wang left -= proc_skip_spaces(&kbuf); 2453*00b7c339SAmerigo Wang free: 24541da177e4SLinus Torvalds if (write) { 2455*00b7c339SAmerigo Wang free_page(page); 2456*00b7c339SAmerigo Wang if (first) 2457*00b7c339SAmerigo Wang return err ? : -EINVAL; 24581da177e4SLinus Torvalds } 24591da177e4SLinus Torvalds *lenp -= left; 24601da177e4SLinus Torvalds *ppos += *lenp; 2461*00b7c339SAmerigo Wang return err; 24621da177e4SLinus Torvalds } 24631da177e4SLinus Torvalds 2464d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, 2465fcfbd547SKirill Korotaev void __user *buffer, 2466fcfbd547SKirill Korotaev size_t *lenp, loff_t *ppos, 2467fcfbd547SKirill Korotaev unsigned long convmul, 2468fcfbd547SKirill Korotaev unsigned long convdiv) 2469fcfbd547SKirill Korotaev { 2470fcfbd547SKirill Korotaev return __do_proc_doulongvec_minmax(table->data, table, write, 24718d65af78SAlexey Dobriyan buffer, lenp, ppos, convmul, convdiv); 2472fcfbd547SKirill Korotaev } 2473fcfbd547SKirill Korotaev 24741da177e4SLinus Torvalds /** 24751da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 24761da177e4SLinus Torvalds * @table: the sysctl table 24771da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 24781da177e4SLinus Torvalds * @buffer: the user buffer 24791da177e4SLinus Torvalds * @lenp: the size of the user buffer 24801da177e4SLinus Torvalds * @ppos: file position 24811da177e4SLinus Torvalds * 24821da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 24831da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 24841da177e4SLinus Torvalds * 24851da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 24861da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 24871da177e4SLinus Torvalds * 24881da177e4SLinus Torvalds * Returns 0 on success. 24891da177e4SLinus Torvalds */ 24908d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 24911da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24921da177e4SLinus Torvalds { 24938d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l); 24941da177e4SLinus Torvalds } 24951da177e4SLinus Torvalds 24961da177e4SLinus Torvalds /** 24971da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 24981da177e4SLinus Torvalds * @table: the sysctl table 24991da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25001da177e4SLinus Torvalds * @buffer: the user buffer 25011da177e4SLinus Torvalds * @lenp: the size of the user buffer 25021da177e4SLinus Torvalds * @ppos: file position 25031da177e4SLinus Torvalds * 25041da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 25051da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 25061da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 25071da177e4SLinus Torvalds * 25081da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 25091da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 25101da177e4SLinus Torvalds * 25111da177e4SLinus Torvalds * Returns 0 on success. 25121da177e4SLinus Torvalds */ 2513d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 25141da177e4SLinus Torvalds void __user *buffer, 25151da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 25161da177e4SLinus Torvalds { 25178d65af78SAlexey Dobriyan return do_proc_doulongvec_minmax(table, write, buffer, 25181da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 25191da177e4SLinus Torvalds } 25201da177e4SLinus Torvalds 25211da177e4SLinus Torvalds 2522*00b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp, 25231da177e4SLinus Torvalds int *valp, 25241da177e4SLinus Torvalds int write, void *data) 25251da177e4SLinus Torvalds { 25261da177e4SLinus Torvalds if (write) { 2527cba9f33dSBart Samwel if (*lvalp > LONG_MAX / HZ) 2528cba9f33dSBart Samwel return 1; 25291da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 25301da177e4SLinus Torvalds } else { 25311da177e4SLinus Torvalds int val = *valp; 25321da177e4SLinus Torvalds unsigned long lval; 25331da177e4SLinus Torvalds if (val < 0) { 2534*00b7c339SAmerigo Wang *negp = true; 25351da177e4SLinus Torvalds lval = (unsigned long)-val; 25361da177e4SLinus Torvalds } else { 2537*00b7c339SAmerigo Wang *negp = false; 25381da177e4SLinus Torvalds lval = (unsigned long)val; 25391da177e4SLinus Torvalds } 25401da177e4SLinus Torvalds *lvalp = lval / HZ; 25411da177e4SLinus Torvalds } 25421da177e4SLinus Torvalds return 0; 25431da177e4SLinus Torvalds } 25441da177e4SLinus Torvalds 2545*00b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp, 25461da177e4SLinus Torvalds int *valp, 25471da177e4SLinus Torvalds int write, void *data) 25481da177e4SLinus Torvalds { 25491da177e4SLinus Torvalds if (write) { 2550cba9f33dSBart Samwel if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ) 2551cba9f33dSBart Samwel return 1; 25521da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 25531da177e4SLinus Torvalds } else { 25541da177e4SLinus Torvalds int val = *valp; 25551da177e4SLinus Torvalds unsigned long lval; 25561da177e4SLinus Torvalds if (val < 0) { 2557*00b7c339SAmerigo Wang *negp = true; 25581da177e4SLinus Torvalds lval = (unsigned long)-val; 25591da177e4SLinus Torvalds } else { 2560*00b7c339SAmerigo Wang *negp = false; 25611da177e4SLinus Torvalds lval = (unsigned long)val; 25621da177e4SLinus Torvalds } 25631da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 25641da177e4SLinus Torvalds } 25651da177e4SLinus Torvalds return 0; 25661da177e4SLinus Torvalds } 25671da177e4SLinus Torvalds 2568*00b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp, 25691da177e4SLinus Torvalds int *valp, 25701da177e4SLinus Torvalds int write, void *data) 25711da177e4SLinus Torvalds { 25721da177e4SLinus Torvalds if (write) { 25731da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 25741da177e4SLinus Torvalds } else { 25751da177e4SLinus Torvalds int val = *valp; 25761da177e4SLinus Torvalds unsigned long lval; 25771da177e4SLinus Torvalds if (val < 0) { 2578*00b7c339SAmerigo Wang *negp = true; 25791da177e4SLinus Torvalds lval = (unsigned long)-val; 25801da177e4SLinus Torvalds } else { 2581*00b7c339SAmerigo Wang *negp = false; 25821da177e4SLinus Torvalds lval = (unsigned long)val; 25831da177e4SLinus Torvalds } 25841da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 25851da177e4SLinus Torvalds } 25861da177e4SLinus Torvalds return 0; 25871da177e4SLinus Torvalds } 25881da177e4SLinus Torvalds 25891da177e4SLinus Torvalds /** 25901da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 25911da177e4SLinus Torvalds * @table: the sysctl table 25921da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 25931da177e4SLinus Torvalds * @buffer: the user buffer 25941da177e4SLinus Torvalds * @lenp: the size of the user buffer 25951da177e4SLinus Torvalds * @ppos: file position 25961da177e4SLinus Torvalds * 25971da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 25981da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 25991da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 26001da177e4SLinus Torvalds * jiffies. 26011da177e4SLinus Torvalds * 26021da177e4SLinus Torvalds * Returns 0 on success. 26031da177e4SLinus Torvalds */ 26048d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 26051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26061da177e4SLinus Torvalds { 26078d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 26081da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 26091da177e4SLinus Torvalds } 26101da177e4SLinus Torvalds 26111da177e4SLinus Torvalds /** 26121da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 26131da177e4SLinus Torvalds * @table: the sysctl table 26141da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26151da177e4SLinus Torvalds * @buffer: the user buffer 26161da177e4SLinus Torvalds * @lenp: the size of the user buffer 26171e5d5331SRandy Dunlap * @ppos: pointer to the file position 26181da177e4SLinus Torvalds * 26191da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 26201da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 26211da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 26221da177e4SLinus Torvalds * are converted into jiffies. 26231da177e4SLinus Torvalds * 26241da177e4SLinus Torvalds * Returns 0 on success. 26251da177e4SLinus Torvalds */ 26268d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 26271da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26281da177e4SLinus Torvalds { 26298d65af78SAlexey Dobriyan return do_proc_dointvec(table,write,buffer,lenp,ppos, 26301da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 26311da177e4SLinus Torvalds } 26321da177e4SLinus Torvalds 26331da177e4SLinus Torvalds /** 26341da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 26351da177e4SLinus Torvalds * @table: the sysctl table 26361da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 26371da177e4SLinus Torvalds * @buffer: the user buffer 26381da177e4SLinus Torvalds * @lenp: the size of the user buffer 263967be2dd1SMartin Waitz * @ppos: file position 264067be2dd1SMartin Waitz * @ppos: the current position in the file 26411da177e4SLinus Torvalds * 26421da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 26431da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 26441da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 26451da177e4SLinus Torvalds * are converted into jiffies. 26461da177e4SLinus Torvalds * 26471da177e4SLinus Torvalds * Returns 0 on success. 26481da177e4SLinus Torvalds */ 26498d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 26501da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26511da177e4SLinus Torvalds { 26528d65af78SAlexey Dobriyan return do_proc_dointvec(table, write, buffer, lenp, ppos, 26531da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 26541da177e4SLinus Torvalds } 26551da177e4SLinus Torvalds 26568d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write, 26579ec52099SCedric Le Goater void __user *buffer, size_t *lenp, loff_t *ppos) 26589ec52099SCedric Le Goater { 26599ec52099SCedric Le Goater struct pid *new_pid; 26609ec52099SCedric Le Goater pid_t tmp; 26619ec52099SCedric Le Goater int r; 26629ec52099SCedric Le Goater 26636c5f3e7bSPavel Emelyanov tmp = pid_vnr(cad_pid); 26649ec52099SCedric Le Goater 26658d65af78SAlexey Dobriyan r = __do_proc_dointvec(&tmp, table, write, buffer, 26669ec52099SCedric Le Goater lenp, ppos, NULL, NULL); 26679ec52099SCedric Le Goater if (r || !write) 26689ec52099SCedric Le Goater return r; 26699ec52099SCedric Le Goater 26709ec52099SCedric Le Goater new_pid = find_get_pid(tmp); 26719ec52099SCedric Le Goater if (!new_pid) 26729ec52099SCedric Le Goater return -ESRCH; 26739ec52099SCedric Le Goater 26749ec52099SCedric Le Goater put_pid(xchg(&cad_pid, new_pid)); 26759ec52099SCedric Le Goater return 0; 26769ec52099SCedric Le Goater } 26779ec52099SCedric Le Goater 26781da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 26791da177e4SLinus Torvalds 26808d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write, 26811da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26821da177e4SLinus Torvalds { 26831da177e4SLinus Torvalds return -ENOSYS; 26841da177e4SLinus Torvalds } 26851da177e4SLinus Torvalds 26868d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write, 26871da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26881da177e4SLinus Torvalds { 26891da177e4SLinus Torvalds return -ENOSYS; 26901da177e4SLinus Torvalds } 26911da177e4SLinus Torvalds 26928d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write, 26931da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 26941da177e4SLinus Torvalds { 26951da177e4SLinus Torvalds return -ENOSYS; 26961da177e4SLinus Torvalds } 26971da177e4SLinus Torvalds 26988d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write, 26991da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27001da177e4SLinus Torvalds { 27011da177e4SLinus Torvalds return -ENOSYS; 27021da177e4SLinus Torvalds } 27031da177e4SLinus Torvalds 27048d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, 27051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27061da177e4SLinus Torvalds { 27071da177e4SLinus Torvalds return -ENOSYS; 27081da177e4SLinus Torvalds } 27091da177e4SLinus Torvalds 27108d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, 27111da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27121da177e4SLinus Torvalds { 27131da177e4SLinus Torvalds return -ENOSYS; 27141da177e4SLinus Torvalds } 27151da177e4SLinus Torvalds 27168d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write, 27171da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 27181da177e4SLinus Torvalds { 27191da177e4SLinus Torvalds return -ENOSYS; 27201da177e4SLinus Torvalds } 27211da177e4SLinus Torvalds 2722d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, 27231da177e4SLinus Torvalds void __user *buffer, 27241da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 27251da177e4SLinus Torvalds { 27261da177e4SLinus Torvalds return -ENOSYS; 27271da177e4SLinus Torvalds } 27281da177e4SLinus Torvalds 27291da177e4SLinus Torvalds 27301da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 27311da177e4SLinus Torvalds 27321da177e4SLinus Torvalds /* 27331da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 27341da177e4SLinus Torvalds * exception granted :-) 27351da177e4SLinus Torvalds */ 27361da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 27371da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 27381da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 27391da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 27401da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 27411da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 27421da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 27431da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 27441da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 274529e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths); 27461da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2747