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/config.h> 221da177e4SLinus Torvalds #include <linux/module.h> 231da177e4SLinus Torvalds #include <linux/mm.h> 241da177e4SLinus Torvalds #include <linux/swap.h> 251da177e4SLinus Torvalds #include <linux/slab.h> 261da177e4SLinus Torvalds #include <linux/sysctl.h> 271da177e4SLinus Torvalds #include <linux/proc_fs.h> 281da177e4SLinus Torvalds #include <linux/ctype.h> 291da177e4SLinus Torvalds #include <linux/utsname.h> 301da177e4SLinus Torvalds #include <linux/capability.h> 311da177e4SLinus Torvalds #include <linux/smp_lock.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> 391da177e4SLinus Torvalds #include <linux/hugetlb.h> 401da177e4SLinus Torvalds #include <linux/security.h> 411da177e4SLinus Torvalds #include <linux/initrd.h> 421da177e4SLinus Torvalds #include <linux/times.h> 431da177e4SLinus Torvalds #include <linux/limits.h> 441da177e4SLinus Torvalds #include <linux/dcache.h> 451da177e4SLinus Torvalds #include <linux/syscalls.h> 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds #include <asm/uaccess.h> 481da177e4SLinus Torvalds #include <asm/processor.h> 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds #ifdef CONFIG_ROOT_NFS 511da177e4SLinus Torvalds #include <linux/nfs_fs.h> 521da177e4SLinus Torvalds #endif 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL) 551da177e4SLinus Torvalds 561da177e4SLinus Torvalds /* External variables not in a header file. */ 571da177e4SLinus Torvalds extern int C_A_D; 581da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 591da177e4SLinus Torvalds extern int sysctl_overcommit_ratio; 601da177e4SLinus Torvalds extern int max_threads; 611da177e4SLinus Torvalds extern int sysrq_enabled; 621da177e4SLinus Torvalds extern int core_uses_pid; 63d6e71144SAlan Cox extern int suid_dumpable; 641da177e4SLinus Torvalds extern char core_pattern[]; 651da177e4SLinus Torvalds extern int cad_pid; 661da177e4SLinus Torvalds extern int pid_max; 671da177e4SLinus Torvalds extern int min_free_kbytes; 681da177e4SLinus Torvalds extern int printk_ratelimit_jiffies; 691da177e4SLinus Torvalds extern int printk_ratelimit_burst; 701da177e4SLinus Torvalds extern int pid_max_min, pid_max_max; 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 731da177e4SLinus Torvalds int unknown_nmi_panic; 741da177e4SLinus Torvalds extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, 751da177e4SLinus Torvalds void __user *, size_t *, loff_t *); 761da177e4SLinus Torvalds #endif 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 791da177e4SLinus Torvalds static int maxolduid = 65535; 801da177e4SLinus Torvalds static int minolduid; 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX; 831da177e4SLinus Torvalds 841da177e4SLinus Torvalds #ifdef CONFIG_KMOD 851da177e4SLinus Torvalds extern char modprobe_path[]; 861da177e4SLinus Torvalds #endif 871da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 881da177e4SLinus Torvalds extern int sg_big_buff; 891da177e4SLinus Torvalds #endif 901da177e4SLinus Torvalds #ifdef CONFIG_SYSVIPC 911da177e4SLinus Torvalds extern size_t shm_ctlmax; 921da177e4SLinus Torvalds extern size_t shm_ctlall; 931da177e4SLinus Torvalds extern int shm_ctlmni; 941da177e4SLinus Torvalds extern int msg_ctlmax; 951da177e4SLinus Torvalds extern int msg_ctlmnb; 961da177e4SLinus Torvalds extern int msg_ctlmni; 971da177e4SLinus Torvalds extern int sem_ctls[]; 981da177e4SLinus Torvalds #endif 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds #ifdef __sparc__ 1011da177e4SLinus Torvalds extern char reboot_command []; 1021da177e4SLinus Torvalds extern int stop_a_enabled; 1031da177e4SLinus Torvalds extern int scons_pwroff; 1041da177e4SLinus Torvalds #endif 1051da177e4SLinus Torvalds 1061da177e4SLinus Torvalds #ifdef __hppa__ 1071da177e4SLinus Torvalds extern int pwrsw_enabled; 1081da177e4SLinus Torvalds extern int unaligned_enabled; 1091da177e4SLinus Torvalds #endif 1101da177e4SLinus Torvalds 111*347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 1121da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 1131da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings; 1141da177e4SLinus Torvalds #endif 1151da177e4SLinus Torvalds extern int sysctl_userprocess_debug; 116951f22d5SMartin Schwidefsky extern int spin_retry; 1171da177e4SLinus Torvalds #endif 1181da177e4SLinus Torvalds 1191da177e4SLinus Torvalds extern int sysctl_hz_timer; 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 1221da177e4SLinus Torvalds extern int acct_parm[]; 1231da177e4SLinus Torvalds #endif 1241da177e4SLinus Torvalds 1251da177e4SLinus Torvalds int randomize_va_space = 1; 1261da177e4SLinus Torvalds 1271da177e4SLinus Torvalds static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 1281da177e4SLinus Torvalds ctl_table *, void **); 1291da177e4SLinus Torvalds static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 1301da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos); 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds static ctl_table root_table[]; 1331da177e4SLinus Torvalds static struct ctl_table_header root_table_header = 1341da177e4SLinus Torvalds { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) }; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds static ctl_table kern_table[]; 1371da177e4SLinus Torvalds static ctl_table vm_table[]; 1381da177e4SLinus Torvalds static ctl_table proc_table[]; 1391da177e4SLinus Torvalds static ctl_table fs_table[]; 1401da177e4SLinus Torvalds static ctl_table debug_table[]; 1411da177e4SLinus Torvalds static ctl_table dev_table[]; 1421da177e4SLinus Torvalds extern ctl_table random_table[]; 1431da177e4SLinus Torvalds #ifdef CONFIG_UNIX98_PTYS 1441da177e4SLinus Torvalds extern ctl_table pty_table[]; 1451da177e4SLinus Torvalds #endif 1460399cb08SRobert Love #ifdef CONFIG_INOTIFY 1470399cb08SRobert Love extern ctl_table inotify_table[]; 1480399cb08SRobert Love #endif 1491da177e4SLinus Torvalds 1501da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 1511da177e4SLinus Torvalds int sysctl_legacy_va_layout; 1521da177e4SLinus Torvalds #endif 1531da177e4SLinus Torvalds 1541da177e4SLinus Torvalds /* /proc declarations: */ 1551da177e4SLinus Torvalds 1561da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 1571da177e4SLinus Torvalds 1581da177e4SLinus Torvalds static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); 1591da177e4SLinus Torvalds static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); 1601da177e4SLinus Torvalds static int proc_opensys(struct inode *, struct file *); 1611da177e4SLinus Torvalds 1621da177e4SLinus Torvalds struct file_operations proc_sys_file_operations = { 1631da177e4SLinus Torvalds .open = proc_opensys, 1641da177e4SLinus Torvalds .read = proc_readsys, 1651da177e4SLinus Torvalds .write = proc_writesys, 1661da177e4SLinus Torvalds }; 1671da177e4SLinus Torvalds 1681da177e4SLinus Torvalds extern struct proc_dir_entry *proc_sys_root; 1691da177e4SLinus Torvalds 170330d57fbSAl Viro static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *); 1711da177e4SLinus Torvalds static void unregister_proc_table(ctl_table *, struct proc_dir_entry *); 1721da177e4SLinus Torvalds #endif 1731da177e4SLinus Torvalds 1741da177e4SLinus Torvalds /* The default sysctl tables: */ 1751da177e4SLinus Torvalds 1761da177e4SLinus Torvalds static ctl_table root_table[] = { 1771da177e4SLinus Torvalds { 1781da177e4SLinus Torvalds .ctl_name = CTL_KERN, 1791da177e4SLinus Torvalds .procname = "kernel", 1801da177e4SLinus Torvalds .mode = 0555, 1811da177e4SLinus Torvalds .child = kern_table, 1821da177e4SLinus Torvalds }, 1831da177e4SLinus Torvalds { 1841da177e4SLinus Torvalds .ctl_name = CTL_VM, 1851da177e4SLinus Torvalds .procname = "vm", 1861da177e4SLinus Torvalds .mode = 0555, 1871da177e4SLinus Torvalds .child = vm_table, 1881da177e4SLinus Torvalds }, 1891da177e4SLinus Torvalds #ifdef CONFIG_NET 1901da177e4SLinus Torvalds { 1911da177e4SLinus Torvalds .ctl_name = CTL_NET, 1921da177e4SLinus Torvalds .procname = "net", 1931da177e4SLinus Torvalds .mode = 0555, 1941da177e4SLinus Torvalds .child = net_table, 1951da177e4SLinus Torvalds }, 1961da177e4SLinus Torvalds #endif 1971da177e4SLinus Torvalds { 1981da177e4SLinus Torvalds .ctl_name = CTL_PROC, 1991da177e4SLinus Torvalds .procname = "proc", 2001da177e4SLinus Torvalds .mode = 0555, 2011da177e4SLinus Torvalds .child = proc_table, 2021da177e4SLinus Torvalds }, 2031da177e4SLinus Torvalds { 2041da177e4SLinus Torvalds .ctl_name = CTL_FS, 2051da177e4SLinus Torvalds .procname = "fs", 2061da177e4SLinus Torvalds .mode = 0555, 2071da177e4SLinus Torvalds .child = fs_table, 2081da177e4SLinus Torvalds }, 2091da177e4SLinus Torvalds { 2101da177e4SLinus Torvalds .ctl_name = CTL_DEBUG, 2111da177e4SLinus Torvalds .procname = "debug", 2121da177e4SLinus Torvalds .mode = 0555, 2131da177e4SLinus Torvalds .child = debug_table, 2141da177e4SLinus Torvalds }, 2151da177e4SLinus Torvalds { 2161da177e4SLinus Torvalds .ctl_name = CTL_DEV, 2171da177e4SLinus Torvalds .procname = "dev", 2181da177e4SLinus Torvalds .mode = 0555, 2191da177e4SLinus Torvalds .child = dev_table, 2201da177e4SLinus Torvalds }, 2210eeca283SRobert Love 2221da177e4SLinus Torvalds { .ctl_name = 0 } 2231da177e4SLinus Torvalds }; 2241da177e4SLinus Torvalds 2251da177e4SLinus Torvalds static ctl_table kern_table[] = { 2261da177e4SLinus Torvalds { 2271da177e4SLinus Torvalds .ctl_name = KERN_OSTYPE, 2281da177e4SLinus Torvalds .procname = "ostype", 2291da177e4SLinus Torvalds .data = system_utsname.sysname, 2301da177e4SLinus Torvalds .maxlen = sizeof(system_utsname.sysname), 2311da177e4SLinus Torvalds .mode = 0444, 2321da177e4SLinus Torvalds .proc_handler = &proc_doutsstring, 2331da177e4SLinus Torvalds .strategy = &sysctl_string, 2341da177e4SLinus Torvalds }, 2351da177e4SLinus Torvalds { 2361da177e4SLinus Torvalds .ctl_name = KERN_OSRELEASE, 2371da177e4SLinus Torvalds .procname = "osrelease", 2381da177e4SLinus Torvalds .data = system_utsname.release, 2391da177e4SLinus Torvalds .maxlen = sizeof(system_utsname.release), 2401da177e4SLinus Torvalds .mode = 0444, 2411da177e4SLinus Torvalds .proc_handler = &proc_doutsstring, 2421da177e4SLinus Torvalds .strategy = &sysctl_string, 2431da177e4SLinus Torvalds }, 2441da177e4SLinus Torvalds { 2451da177e4SLinus Torvalds .ctl_name = KERN_VERSION, 2461da177e4SLinus Torvalds .procname = "version", 2471da177e4SLinus Torvalds .data = system_utsname.version, 2481da177e4SLinus Torvalds .maxlen = sizeof(system_utsname.version), 2491da177e4SLinus Torvalds .mode = 0444, 2501da177e4SLinus Torvalds .proc_handler = &proc_doutsstring, 2511da177e4SLinus Torvalds .strategy = &sysctl_string, 2521da177e4SLinus Torvalds }, 2531da177e4SLinus Torvalds { 2541da177e4SLinus Torvalds .ctl_name = KERN_NODENAME, 2551da177e4SLinus Torvalds .procname = "hostname", 2561da177e4SLinus Torvalds .data = system_utsname.nodename, 2571da177e4SLinus Torvalds .maxlen = sizeof(system_utsname.nodename), 2581da177e4SLinus Torvalds .mode = 0644, 2591da177e4SLinus Torvalds .proc_handler = &proc_doutsstring, 2601da177e4SLinus Torvalds .strategy = &sysctl_string, 2611da177e4SLinus Torvalds }, 2621da177e4SLinus Torvalds { 2631da177e4SLinus Torvalds .ctl_name = KERN_DOMAINNAME, 2641da177e4SLinus Torvalds .procname = "domainname", 2651da177e4SLinus Torvalds .data = system_utsname.domainname, 2661da177e4SLinus Torvalds .maxlen = sizeof(system_utsname.domainname), 2671da177e4SLinus Torvalds .mode = 0644, 2681da177e4SLinus Torvalds .proc_handler = &proc_doutsstring, 2691da177e4SLinus Torvalds .strategy = &sysctl_string, 2701da177e4SLinus Torvalds }, 2711da177e4SLinus Torvalds { 2721da177e4SLinus Torvalds .ctl_name = KERN_PANIC, 2731da177e4SLinus Torvalds .procname = "panic", 2741da177e4SLinus Torvalds .data = &panic_timeout, 2751da177e4SLinus Torvalds .maxlen = sizeof(int), 2761da177e4SLinus Torvalds .mode = 0644, 2771da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 2781da177e4SLinus Torvalds }, 2791da177e4SLinus Torvalds { 2801da177e4SLinus Torvalds .ctl_name = KERN_CORE_USES_PID, 2811da177e4SLinus Torvalds .procname = "core_uses_pid", 2821da177e4SLinus Torvalds .data = &core_uses_pid, 2831da177e4SLinus Torvalds .maxlen = sizeof(int), 2841da177e4SLinus Torvalds .mode = 0644, 2851da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 2861da177e4SLinus Torvalds }, 2871da177e4SLinus Torvalds { 2881da177e4SLinus Torvalds .ctl_name = KERN_CORE_PATTERN, 2891da177e4SLinus Torvalds .procname = "core_pattern", 2901da177e4SLinus Torvalds .data = core_pattern, 2911da177e4SLinus Torvalds .maxlen = 64, 2921da177e4SLinus Torvalds .mode = 0644, 2931da177e4SLinus Torvalds .proc_handler = &proc_dostring, 2941da177e4SLinus Torvalds .strategy = &sysctl_string, 2951da177e4SLinus Torvalds }, 2961da177e4SLinus Torvalds { 2971da177e4SLinus Torvalds .ctl_name = KERN_TAINTED, 2981da177e4SLinus Torvalds .procname = "tainted", 2991da177e4SLinus Torvalds .data = &tainted, 3001da177e4SLinus Torvalds .maxlen = sizeof(int), 3011da177e4SLinus Torvalds .mode = 0444, 3021da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3031da177e4SLinus Torvalds }, 3041da177e4SLinus Torvalds { 3051da177e4SLinus Torvalds .ctl_name = KERN_CAP_BSET, 3061da177e4SLinus Torvalds .procname = "cap-bound", 3071da177e4SLinus Torvalds .data = &cap_bset, 3081da177e4SLinus Torvalds .maxlen = sizeof(kernel_cap_t), 3091da177e4SLinus Torvalds .mode = 0600, 3101da177e4SLinus Torvalds .proc_handler = &proc_dointvec_bset, 3111da177e4SLinus Torvalds }, 3121da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 3131da177e4SLinus Torvalds { 3141da177e4SLinus Torvalds .ctl_name = KERN_REALROOTDEV, 3151da177e4SLinus Torvalds .procname = "real-root-dev", 3161da177e4SLinus Torvalds .data = &real_root_dev, 3171da177e4SLinus Torvalds .maxlen = sizeof(int), 3181da177e4SLinus Torvalds .mode = 0644, 3191da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3201da177e4SLinus Torvalds }, 3211da177e4SLinus Torvalds #endif 3221da177e4SLinus Torvalds #ifdef __sparc__ 3231da177e4SLinus Torvalds { 3241da177e4SLinus Torvalds .ctl_name = KERN_SPARC_REBOOT, 3251da177e4SLinus Torvalds .procname = "reboot-cmd", 3261da177e4SLinus Torvalds .data = reboot_command, 3271da177e4SLinus Torvalds .maxlen = 256, 3281da177e4SLinus Torvalds .mode = 0644, 3291da177e4SLinus Torvalds .proc_handler = &proc_dostring, 3301da177e4SLinus Torvalds .strategy = &sysctl_string, 3311da177e4SLinus Torvalds }, 3321da177e4SLinus Torvalds { 3331da177e4SLinus Torvalds .ctl_name = KERN_SPARC_STOP_A, 3341da177e4SLinus Torvalds .procname = "stop-a", 3351da177e4SLinus Torvalds .data = &stop_a_enabled, 3361da177e4SLinus Torvalds .maxlen = sizeof (int), 3371da177e4SLinus Torvalds .mode = 0644, 3381da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3391da177e4SLinus Torvalds }, 3401da177e4SLinus Torvalds { 3411da177e4SLinus Torvalds .ctl_name = KERN_SPARC_SCONS_PWROFF, 3421da177e4SLinus Torvalds .procname = "scons-poweroff", 3431da177e4SLinus Torvalds .data = &scons_pwroff, 3441da177e4SLinus Torvalds .maxlen = sizeof (int), 3451da177e4SLinus Torvalds .mode = 0644, 3461da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3471da177e4SLinus Torvalds }, 3481da177e4SLinus Torvalds #endif 3491da177e4SLinus Torvalds #ifdef __hppa__ 3501da177e4SLinus Torvalds { 3511da177e4SLinus Torvalds .ctl_name = KERN_HPPA_PWRSW, 3521da177e4SLinus Torvalds .procname = "soft-power", 3531da177e4SLinus Torvalds .data = &pwrsw_enabled, 3541da177e4SLinus Torvalds .maxlen = sizeof (int), 3551da177e4SLinus Torvalds .mode = 0644, 3561da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3571da177e4SLinus Torvalds }, 3581da177e4SLinus Torvalds { 3591da177e4SLinus Torvalds .ctl_name = KERN_HPPA_UNALIGNED, 3601da177e4SLinus Torvalds .procname = "unaligned-trap", 3611da177e4SLinus Torvalds .data = &unaligned_enabled, 3621da177e4SLinus Torvalds .maxlen = sizeof (int), 3631da177e4SLinus Torvalds .mode = 0644, 3641da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3651da177e4SLinus Torvalds }, 3661da177e4SLinus Torvalds #endif 3671da177e4SLinus Torvalds { 3681da177e4SLinus Torvalds .ctl_name = KERN_CTLALTDEL, 3691da177e4SLinus Torvalds .procname = "ctrl-alt-del", 3701da177e4SLinus Torvalds .data = &C_A_D, 3711da177e4SLinus Torvalds .maxlen = sizeof(int), 3721da177e4SLinus Torvalds .mode = 0644, 3731da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3741da177e4SLinus Torvalds }, 3751da177e4SLinus Torvalds { 3761da177e4SLinus Torvalds .ctl_name = KERN_PRINTK, 3771da177e4SLinus Torvalds .procname = "printk", 3781da177e4SLinus Torvalds .data = &console_loglevel, 3791da177e4SLinus Torvalds .maxlen = 4*sizeof(int), 3801da177e4SLinus Torvalds .mode = 0644, 3811da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 3821da177e4SLinus Torvalds }, 3831da177e4SLinus Torvalds #ifdef CONFIG_KMOD 3841da177e4SLinus Torvalds { 3851da177e4SLinus Torvalds .ctl_name = KERN_MODPROBE, 3861da177e4SLinus Torvalds .procname = "modprobe", 3871da177e4SLinus Torvalds .data = &modprobe_path, 3881da177e4SLinus Torvalds .maxlen = KMOD_PATH_LEN, 3891da177e4SLinus Torvalds .mode = 0644, 3901da177e4SLinus Torvalds .proc_handler = &proc_dostring, 3911da177e4SLinus Torvalds .strategy = &sysctl_string, 3921da177e4SLinus Torvalds }, 3931da177e4SLinus Torvalds #endif 3941da177e4SLinus Torvalds #ifdef CONFIG_HOTPLUG 3951da177e4SLinus Torvalds { 3961da177e4SLinus Torvalds .ctl_name = KERN_HOTPLUG, 3971da177e4SLinus Torvalds .procname = "hotplug", 398312c004dSKay Sievers .data = &uevent_helper, 399312c004dSKay Sievers .maxlen = UEVENT_HELPER_PATH_LEN, 4001da177e4SLinus Torvalds .mode = 0644, 4011da177e4SLinus Torvalds .proc_handler = &proc_dostring, 4021da177e4SLinus Torvalds .strategy = &sysctl_string, 4031da177e4SLinus Torvalds }, 4041da177e4SLinus Torvalds #endif 4051da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG 4061da177e4SLinus Torvalds { 4071da177e4SLinus Torvalds .ctl_name = KERN_SG_BIG_BUFF, 4081da177e4SLinus Torvalds .procname = "sg-big-buff", 4091da177e4SLinus Torvalds .data = &sg_big_buff, 4101da177e4SLinus Torvalds .maxlen = sizeof (int), 4111da177e4SLinus Torvalds .mode = 0444, 4121da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4131da177e4SLinus Torvalds }, 4141da177e4SLinus Torvalds #endif 4151da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT 4161da177e4SLinus Torvalds { 4171da177e4SLinus Torvalds .ctl_name = KERN_ACCT, 4181da177e4SLinus Torvalds .procname = "acct", 4191da177e4SLinus Torvalds .data = &acct_parm, 4201da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 4211da177e4SLinus Torvalds .mode = 0644, 4221da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4231da177e4SLinus Torvalds }, 4241da177e4SLinus Torvalds #endif 4251da177e4SLinus Torvalds #ifdef CONFIG_SYSVIPC 4261da177e4SLinus Torvalds { 4271da177e4SLinus Torvalds .ctl_name = KERN_SHMMAX, 4281da177e4SLinus Torvalds .procname = "shmmax", 4291da177e4SLinus Torvalds .data = &shm_ctlmax, 4301da177e4SLinus Torvalds .maxlen = sizeof (size_t), 4311da177e4SLinus Torvalds .mode = 0644, 4321da177e4SLinus Torvalds .proc_handler = &proc_doulongvec_minmax, 4331da177e4SLinus Torvalds }, 4341da177e4SLinus Torvalds { 4351da177e4SLinus Torvalds .ctl_name = KERN_SHMALL, 4361da177e4SLinus Torvalds .procname = "shmall", 4371da177e4SLinus Torvalds .data = &shm_ctlall, 4381da177e4SLinus Torvalds .maxlen = sizeof (size_t), 4391da177e4SLinus Torvalds .mode = 0644, 4401da177e4SLinus Torvalds .proc_handler = &proc_doulongvec_minmax, 4411da177e4SLinus Torvalds }, 4421da177e4SLinus Torvalds { 4431da177e4SLinus Torvalds .ctl_name = KERN_SHMMNI, 4441da177e4SLinus Torvalds .procname = "shmmni", 4451da177e4SLinus Torvalds .data = &shm_ctlmni, 4461da177e4SLinus Torvalds .maxlen = sizeof (int), 4471da177e4SLinus Torvalds .mode = 0644, 4481da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4491da177e4SLinus Torvalds }, 4501da177e4SLinus Torvalds { 4511da177e4SLinus Torvalds .ctl_name = KERN_MSGMAX, 4521da177e4SLinus Torvalds .procname = "msgmax", 4531da177e4SLinus Torvalds .data = &msg_ctlmax, 4541da177e4SLinus Torvalds .maxlen = sizeof (int), 4551da177e4SLinus Torvalds .mode = 0644, 4561da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4571da177e4SLinus Torvalds }, 4581da177e4SLinus Torvalds { 4591da177e4SLinus Torvalds .ctl_name = KERN_MSGMNI, 4601da177e4SLinus Torvalds .procname = "msgmni", 4611da177e4SLinus Torvalds .data = &msg_ctlmni, 4621da177e4SLinus Torvalds .maxlen = sizeof (int), 4631da177e4SLinus Torvalds .mode = 0644, 4641da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4651da177e4SLinus Torvalds }, 4661da177e4SLinus Torvalds { 4671da177e4SLinus Torvalds .ctl_name = KERN_MSGMNB, 4681da177e4SLinus Torvalds .procname = "msgmnb", 4691da177e4SLinus Torvalds .data = &msg_ctlmnb, 4701da177e4SLinus Torvalds .maxlen = sizeof (int), 4711da177e4SLinus Torvalds .mode = 0644, 4721da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4731da177e4SLinus Torvalds }, 4741da177e4SLinus Torvalds { 4751da177e4SLinus Torvalds .ctl_name = KERN_SEM, 4761da177e4SLinus Torvalds .procname = "sem", 4771da177e4SLinus Torvalds .data = &sem_ctls, 4781da177e4SLinus Torvalds .maxlen = 4*sizeof (int), 4791da177e4SLinus Torvalds .mode = 0644, 4801da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4811da177e4SLinus Torvalds }, 4821da177e4SLinus Torvalds #endif 4831da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ 4841da177e4SLinus Torvalds { 4851da177e4SLinus Torvalds .ctl_name = KERN_SYSRQ, 4861da177e4SLinus Torvalds .procname = "sysrq", 4871da177e4SLinus Torvalds .data = &sysrq_enabled, 4881da177e4SLinus Torvalds .maxlen = sizeof (int), 4891da177e4SLinus Torvalds .mode = 0644, 4901da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 4911da177e4SLinus Torvalds }, 4921da177e4SLinus Torvalds #endif 4931da177e4SLinus Torvalds { 4941da177e4SLinus Torvalds .ctl_name = KERN_CADPID, 4951da177e4SLinus Torvalds .procname = "cad_pid", 4961da177e4SLinus Torvalds .data = &cad_pid, 4971da177e4SLinus Torvalds .maxlen = sizeof (int), 4981da177e4SLinus Torvalds .mode = 0600, 4991da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5001da177e4SLinus Torvalds }, 5011da177e4SLinus Torvalds { 5021da177e4SLinus Torvalds .ctl_name = KERN_MAX_THREADS, 5031da177e4SLinus Torvalds .procname = "threads-max", 5041da177e4SLinus Torvalds .data = &max_threads, 5051da177e4SLinus Torvalds .maxlen = sizeof(int), 5061da177e4SLinus Torvalds .mode = 0644, 5071da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5081da177e4SLinus Torvalds }, 5091da177e4SLinus Torvalds { 5101da177e4SLinus Torvalds .ctl_name = KERN_RANDOM, 5111da177e4SLinus Torvalds .procname = "random", 5121da177e4SLinus Torvalds .mode = 0555, 5131da177e4SLinus Torvalds .child = random_table, 5141da177e4SLinus Torvalds }, 5151da177e4SLinus Torvalds #ifdef CONFIG_UNIX98_PTYS 5161da177e4SLinus Torvalds { 5171da177e4SLinus Torvalds .ctl_name = KERN_PTY, 5181da177e4SLinus Torvalds .procname = "pty", 5191da177e4SLinus Torvalds .mode = 0555, 5201da177e4SLinus Torvalds .child = pty_table, 5211da177e4SLinus Torvalds }, 5221da177e4SLinus Torvalds #endif 5231da177e4SLinus Torvalds { 5241da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWUID, 5251da177e4SLinus Torvalds .procname = "overflowuid", 5261da177e4SLinus Torvalds .data = &overflowuid, 5271da177e4SLinus Torvalds .maxlen = sizeof(int), 5281da177e4SLinus Torvalds .mode = 0644, 5291da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 5301da177e4SLinus Torvalds .strategy = &sysctl_intvec, 5311da177e4SLinus Torvalds .extra1 = &minolduid, 5321da177e4SLinus Torvalds .extra2 = &maxolduid, 5331da177e4SLinus Torvalds }, 5341da177e4SLinus Torvalds { 5351da177e4SLinus Torvalds .ctl_name = KERN_OVERFLOWGID, 5361da177e4SLinus Torvalds .procname = "overflowgid", 5371da177e4SLinus Torvalds .data = &overflowgid, 5381da177e4SLinus Torvalds .maxlen = sizeof(int), 5391da177e4SLinus Torvalds .mode = 0644, 5401da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 5411da177e4SLinus Torvalds .strategy = &sysctl_intvec, 5421da177e4SLinus Torvalds .extra1 = &minolduid, 5431da177e4SLinus Torvalds .extra2 = &maxolduid, 5441da177e4SLinus Torvalds }, 545*347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390 5461da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU 5471da177e4SLinus Torvalds { 5481da177e4SLinus Torvalds .ctl_name = KERN_IEEE_EMULATION_WARNINGS, 5491da177e4SLinus Torvalds .procname = "ieee_emulation_warnings", 5501da177e4SLinus Torvalds .data = &sysctl_ieee_emulation_warnings, 5511da177e4SLinus Torvalds .maxlen = sizeof(int), 5521da177e4SLinus Torvalds .mode = 0644, 5531da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5541da177e4SLinus Torvalds }, 5551da177e4SLinus Torvalds #endif 5561da177e4SLinus Torvalds #ifdef CONFIG_NO_IDLE_HZ 5571da177e4SLinus Torvalds { 5581da177e4SLinus Torvalds .ctl_name = KERN_HZ_TIMER, 5591da177e4SLinus Torvalds .procname = "hz_timer", 5601da177e4SLinus Torvalds .data = &sysctl_hz_timer, 5611da177e4SLinus Torvalds .maxlen = sizeof(int), 5621da177e4SLinus Torvalds .mode = 0644, 5631da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5641da177e4SLinus Torvalds }, 5651da177e4SLinus Torvalds #endif 5661da177e4SLinus Torvalds { 5671da177e4SLinus Torvalds .ctl_name = KERN_S390_USER_DEBUG_LOGGING, 5681da177e4SLinus Torvalds .procname = "userprocess_debug", 5691da177e4SLinus Torvalds .data = &sysctl_userprocess_debug, 5701da177e4SLinus Torvalds .maxlen = sizeof(int), 5711da177e4SLinus Torvalds .mode = 0644, 5721da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5731da177e4SLinus Torvalds }, 5741da177e4SLinus Torvalds #endif 5751da177e4SLinus Torvalds { 5761da177e4SLinus Torvalds .ctl_name = KERN_PIDMAX, 5771da177e4SLinus Torvalds .procname = "pid_max", 5781da177e4SLinus Torvalds .data = &pid_max, 5791da177e4SLinus Torvalds .maxlen = sizeof (int), 5801da177e4SLinus Torvalds .mode = 0644, 5811da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 5821da177e4SLinus Torvalds .strategy = sysctl_intvec, 5831da177e4SLinus Torvalds .extra1 = &pid_max_min, 5841da177e4SLinus Torvalds .extra2 = &pid_max_max, 5851da177e4SLinus Torvalds }, 5861da177e4SLinus Torvalds { 5871da177e4SLinus Torvalds .ctl_name = KERN_PANIC_ON_OOPS, 5881da177e4SLinus Torvalds .procname = "panic_on_oops", 5891da177e4SLinus Torvalds .data = &panic_on_oops, 5901da177e4SLinus Torvalds .maxlen = sizeof(int), 5911da177e4SLinus Torvalds .mode = 0644, 5921da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 5931da177e4SLinus Torvalds }, 5941da177e4SLinus Torvalds { 5951da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT, 5961da177e4SLinus Torvalds .procname = "printk_ratelimit", 5971da177e4SLinus Torvalds .data = &printk_ratelimit_jiffies, 5981da177e4SLinus Torvalds .maxlen = sizeof(int), 5991da177e4SLinus Torvalds .mode = 0644, 6001da177e4SLinus Torvalds .proc_handler = &proc_dointvec_jiffies, 6011da177e4SLinus Torvalds .strategy = &sysctl_jiffies, 6021da177e4SLinus Torvalds }, 6031da177e4SLinus Torvalds { 6041da177e4SLinus Torvalds .ctl_name = KERN_PRINTK_RATELIMIT_BURST, 6051da177e4SLinus Torvalds .procname = "printk_ratelimit_burst", 6061da177e4SLinus Torvalds .data = &printk_ratelimit_burst, 6071da177e4SLinus Torvalds .maxlen = sizeof(int), 6081da177e4SLinus Torvalds .mode = 0644, 6091da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6101da177e4SLinus Torvalds }, 6111da177e4SLinus Torvalds { 6121da177e4SLinus Torvalds .ctl_name = KERN_NGROUPS_MAX, 6131da177e4SLinus Torvalds .procname = "ngroups_max", 6141da177e4SLinus Torvalds .data = &ngroups_max, 6151da177e4SLinus Torvalds .maxlen = sizeof (int), 6161da177e4SLinus Torvalds .mode = 0444, 6171da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6181da177e4SLinus Torvalds }, 6191da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 6201da177e4SLinus Torvalds { 6211da177e4SLinus Torvalds .ctl_name = KERN_UNKNOWN_NMI_PANIC, 6221da177e4SLinus Torvalds .procname = "unknown_nmi_panic", 6231da177e4SLinus Torvalds .data = &unknown_nmi_panic, 6241da177e4SLinus Torvalds .maxlen = sizeof (int), 6251da177e4SLinus Torvalds .mode = 0644, 6261da177e4SLinus Torvalds .proc_handler = &proc_unknown_nmi_panic, 6271da177e4SLinus Torvalds }, 6281da177e4SLinus Torvalds #endif 6291da177e4SLinus Torvalds #if defined(CONFIG_X86) 6301da177e4SLinus Torvalds { 6311da177e4SLinus Torvalds .ctl_name = KERN_BOOTLOADER_TYPE, 6321da177e4SLinus Torvalds .procname = "bootloader_type", 6331da177e4SLinus Torvalds .data = &bootloader_type, 6341da177e4SLinus Torvalds .maxlen = sizeof (int), 6351da177e4SLinus Torvalds .mode = 0444, 6361da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6371da177e4SLinus Torvalds }, 6381da177e4SLinus Torvalds #endif 6391da177e4SLinus Torvalds { 6401da177e4SLinus Torvalds .ctl_name = KERN_RANDOMIZE, 6411da177e4SLinus Torvalds .procname = "randomize_va_space", 6421da177e4SLinus Torvalds .data = &randomize_va_space, 6431da177e4SLinus Torvalds .maxlen = sizeof(int), 6441da177e4SLinus Torvalds .mode = 0644, 6451da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6461da177e4SLinus Torvalds }, 647*347a8dc3SMartin Schwidefsky #if defined(CONFIG_S390) 648951f22d5SMartin Schwidefsky { 649951f22d5SMartin Schwidefsky .ctl_name = KERN_SPIN_RETRY, 650951f22d5SMartin Schwidefsky .procname = "spin_retry", 651951f22d5SMartin Schwidefsky .data = &spin_retry, 652951f22d5SMartin Schwidefsky .maxlen = sizeof (int), 653951f22d5SMartin Schwidefsky .mode = 0644, 654951f22d5SMartin Schwidefsky .proc_handler = &proc_dointvec, 655951f22d5SMartin Schwidefsky }, 656951f22d5SMartin Schwidefsky #endif 6571da177e4SLinus Torvalds { .ctl_name = 0 } 6581da177e4SLinus Torvalds }; 6591da177e4SLinus Torvalds 6601da177e4SLinus Torvalds /* Constants for minimum and maximum testing in vm_table. 6611da177e4SLinus Torvalds We use these as one-element integer vectors. */ 6621da177e4SLinus Torvalds static int zero; 6631da177e4SLinus Torvalds static int one_hundred = 100; 6641da177e4SLinus Torvalds 6651da177e4SLinus Torvalds 6661da177e4SLinus Torvalds static ctl_table vm_table[] = { 6671da177e4SLinus Torvalds { 6681da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_MEMORY, 6691da177e4SLinus Torvalds .procname = "overcommit_memory", 6701da177e4SLinus Torvalds .data = &sysctl_overcommit_memory, 6711da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_memory), 6721da177e4SLinus Torvalds .mode = 0644, 6731da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6741da177e4SLinus Torvalds }, 6751da177e4SLinus Torvalds { 6761da177e4SLinus Torvalds .ctl_name = VM_OVERCOMMIT_RATIO, 6771da177e4SLinus Torvalds .procname = "overcommit_ratio", 6781da177e4SLinus Torvalds .data = &sysctl_overcommit_ratio, 6791da177e4SLinus Torvalds .maxlen = sizeof(sysctl_overcommit_ratio), 6801da177e4SLinus Torvalds .mode = 0644, 6811da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6821da177e4SLinus Torvalds }, 6831da177e4SLinus Torvalds { 6841da177e4SLinus Torvalds .ctl_name = VM_PAGE_CLUSTER, 6851da177e4SLinus Torvalds .procname = "page-cluster", 6861da177e4SLinus Torvalds .data = &page_cluster, 6871da177e4SLinus Torvalds .maxlen = sizeof(int), 6881da177e4SLinus Torvalds .mode = 0644, 6891da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 6901da177e4SLinus Torvalds }, 6911da177e4SLinus Torvalds { 6921da177e4SLinus Torvalds .ctl_name = VM_DIRTY_BACKGROUND, 6931da177e4SLinus Torvalds .procname = "dirty_background_ratio", 6941da177e4SLinus Torvalds .data = &dirty_background_ratio, 6951da177e4SLinus Torvalds .maxlen = sizeof(dirty_background_ratio), 6961da177e4SLinus Torvalds .mode = 0644, 6971da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 6981da177e4SLinus Torvalds .strategy = &sysctl_intvec, 6991da177e4SLinus Torvalds .extra1 = &zero, 7001da177e4SLinus Torvalds .extra2 = &one_hundred, 7011da177e4SLinus Torvalds }, 7021da177e4SLinus Torvalds { 7031da177e4SLinus Torvalds .ctl_name = VM_DIRTY_RATIO, 7041da177e4SLinus Torvalds .procname = "dirty_ratio", 7051da177e4SLinus Torvalds .data = &vm_dirty_ratio, 7061da177e4SLinus Torvalds .maxlen = sizeof(vm_dirty_ratio), 7071da177e4SLinus Torvalds .mode = 0644, 7081da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 7091da177e4SLinus Torvalds .strategy = &sysctl_intvec, 7101da177e4SLinus Torvalds .extra1 = &zero, 7111da177e4SLinus Torvalds .extra2 = &one_hundred, 7121da177e4SLinus Torvalds }, 7131da177e4SLinus Torvalds { 7141da177e4SLinus Torvalds .ctl_name = VM_DIRTY_WB_CS, 7151da177e4SLinus Torvalds .procname = "dirty_writeback_centisecs", 7161da177e4SLinus Torvalds .data = &dirty_writeback_centisecs, 7171da177e4SLinus Torvalds .maxlen = sizeof(dirty_writeback_centisecs), 7181da177e4SLinus Torvalds .mode = 0644, 7191da177e4SLinus Torvalds .proc_handler = &dirty_writeback_centisecs_handler, 7201da177e4SLinus Torvalds }, 7211da177e4SLinus Torvalds { 7221da177e4SLinus Torvalds .ctl_name = VM_DIRTY_EXPIRE_CS, 7231da177e4SLinus Torvalds .procname = "dirty_expire_centisecs", 7241da177e4SLinus Torvalds .data = &dirty_expire_centisecs, 7251da177e4SLinus Torvalds .maxlen = sizeof(dirty_expire_centisecs), 7261da177e4SLinus Torvalds .mode = 0644, 7271da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7281da177e4SLinus Torvalds }, 7291da177e4SLinus Torvalds { 7301da177e4SLinus Torvalds .ctl_name = VM_NR_PDFLUSH_THREADS, 7311da177e4SLinus Torvalds .procname = "nr_pdflush_threads", 7321da177e4SLinus Torvalds .data = &nr_pdflush_threads, 7331da177e4SLinus Torvalds .maxlen = sizeof nr_pdflush_threads, 7341da177e4SLinus Torvalds .mode = 0444 /* read-only*/, 7351da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7361da177e4SLinus Torvalds }, 7371da177e4SLinus Torvalds { 7381da177e4SLinus Torvalds .ctl_name = VM_SWAPPINESS, 7391da177e4SLinus Torvalds .procname = "swappiness", 7401da177e4SLinus Torvalds .data = &vm_swappiness, 7411da177e4SLinus Torvalds .maxlen = sizeof(vm_swappiness), 7421da177e4SLinus Torvalds .mode = 0644, 7431da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 7441da177e4SLinus Torvalds .strategy = &sysctl_intvec, 7451da177e4SLinus Torvalds .extra1 = &zero, 7461da177e4SLinus Torvalds .extra2 = &one_hundred, 7471da177e4SLinus Torvalds }, 7481da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE 7491da177e4SLinus Torvalds { 7501da177e4SLinus Torvalds .ctl_name = VM_HUGETLB_PAGES, 7511da177e4SLinus Torvalds .procname = "nr_hugepages", 7521da177e4SLinus Torvalds .data = &max_huge_pages, 7531da177e4SLinus Torvalds .maxlen = sizeof(unsigned long), 7541da177e4SLinus Torvalds .mode = 0644, 7551da177e4SLinus Torvalds .proc_handler = &hugetlb_sysctl_handler, 7561da177e4SLinus Torvalds .extra1 = (void *)&hugetlb_zero, 7571da177e4SLinus Torvalds .extra2 = (void *)&hugetlb_infinity, 7581da177e4SLinus Torvalds }, 7591da177e4SLinus Torvalds { 7601da177e4SLinus Torvalds .ctl_name = VM_HUGETLB_GROUP, 7611da177e4SLinus Torvalds .procname = "hugetlb_shm_group", 7621da177e4SLinus Torvalds .data = &sysctl_hugetlb_shm_group, 7631da177e4SLinus Torvalds .maxlen = sizeof(gid_t), 7641da177e4SLinus Torvalds .mode = 0644, 7651da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 7661da177e4SLinus Torvalds }, 7671da177e4SLinus Torvalds #endif 7681da177e4SLinus Torvalds { 7691da177e4SLinus Torvalds .ctl_name = VM_LOWMEM_RESERVE_RATIO, 7701da177e4SLinus Torvalds .procname = "lowmem_reserve_ratio", 7711da177e4SLinus Torvalds .data = &sysctl_lowmem_reserve_ratio, 7721da177e4SLinus Torvalds .maxlen = sizeof(sysctl_lowmem_reserve_ratio), 7731da177e4SLinus Torvalds .mode = 0644, 7741da177e4SLinus Torvalds .proc_handler = &lowmem_reserve_ratio_sysctl_handler, 7751da177e4SLinus Torvalds .strategy = &sysctl_intvec, 7761da177e4SLinus Torvalds }, 7771da177e4SLinus Torvalds { 7781da177e4SLinus Torvalds .ctl_name = VM_MIN_FREE_KBYTES, 7791da177e4SLinus Torvalds .procname = "min_free_kbytes", 7801da177e4SLinus Torvalds .data = &min_free_kbytes, 7811da177e4SLinus Torvalds .maxlen = sizeof(min_free_kbytes), 7821da177e4SLinus Torvalds .mode = 0644, 7831da177e4SLinus Torvalds .proc_handler = &min_free_kbytes_sysctl_handler, 7841da177e4SLinus Torvalds .strategy = &sysctl_intvec, 7851da177e4SLinus Torvalds .extra1 = &zero, 7861da177e4SLinus Torvalds }, 7871da177e4SLinus Torvalds #ifdef CONFIG_MMU 7881da177e4SLinus Torvalds { 7891da177e4SLinus Torvalds .ctl_name = VM_MAX_MAP_COUNT, 7901da177e4SLinus Torvalds .procname = "max_map_count", 7911da177e4SLinus Torvalds .data = &sysctl_max_map_count, 7921da177e4SLinus Torvalds .maxlen = sizeof(sysctl_max_map_count), 7931da177e4SLinus Torvalds .mode = 0644, 7941da177e4SLinus Torvalds .proc_handler = &proc_dointvec 7951da177e4SLinus Torvalds }, 7961da177e4SLinus Torvalds #endif 7971da177e4SLinus Torvalds { 7981da177e4SLinus Torvalds .ctl_name = VM_LAPTOP_MODE, 7991da177e4SLinus Torvalds .procname = "laptop_mode", 8001da177e4SLinus Torvalds .data = &laptop_mode, 8011da177e4SLinus Torvalds .maxlen = sizeof(laptop_mode), 8021da177e4SLinus Torvalds .mode = 0644, 8031da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8041da177e4SLinus Torvalds .strategy = &sysctl_intvec, 8051da177e4SLinus Torvalds .extra1 = &zero, 8061da177e4SLinus Torvalds }, 8071da177e4SLinus Torvalds { 8081da177e4SLinus Torvalds .ctl_name = VM_BLOCK_DUMP, 8091da177e4SLinus Torvalds .procname = "block_dump", 8101da177e4SLinus Torvalds .data = &block_dump, 8111da177e4SLinus Torvalds .maxlen = sizeof(block_dump), 8121da177e4SLinus Torvalds .mode = 0644, 8131da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8141da177e4SLinus Torvalds .strategy = &sysctl_intvec, 8151da177e4SLinus Torvalds .extra1 = &zero, 8161da177e4SLinus Torvalds }, 8171da177e4SLinus Torvalds { 8181da177e4SLinus Torvalds .ctl_name = VM_VFS_CACHE_PRESSURE, 8191da177e4SLinus Torvalds .procname = "vfs_cache_pressure", 8201da177e4SLinus Torvalds .data = &sysctl_vfs_cache_pressure, 8211da177e4SLinus Torvalds .maxlen = sizeof(sysctl_vfs_cache_pressure), 8221da177e4SLinus Torvalds .mode = 0644, 8231da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8241da177e4SLinus Torvalds .strategy = &sysctl_intvec, 8251da177e4SLinus Torvalds .extra1 = &zero, 8261da177e4SLinus Torvalds }, 8271da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 8281da177e4SLinus Torvalds { 8291da177e4SLinus Torvalds .ctl_name = VM_LEGACY_VA_LAYOUT, 8301da177e4SLinus Torvalds .procname = "legacy_va_layout", 8311da177e4SLinus Torvalds .data = &sysctl_legacy_va_layout, 8321da177e4SLinus Torvalds .maxlen = sizeof(sysctl_legacy_va_layout), 8331da177e4SLinus Torvalds .mode = 0644, 8341da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8351da177e4SLinus Torvalds .strategy = &sysctl_intvec, 8361da177e4SLinus Torvalds .extra1 = &zero, 8371da177e4SLinus Torvalds }, 8381da177e4SLinus Torvalds #endif 8391da177e4SLinus Torvalds #ifdef CONFIG_SWAP 8401da177e4SLinus Torvalds { 8411da177e4SLinus Torvalds .ctl_name = VM_SWAP_TOKEN_TIMEOUT, 8421da177e4SLinus Torvalds .procname = "swap_token_timeout", 8431da177e4SLinus Torvalds .data = &swap_token_default_timeout, 8441da177e4SLinus Torvalds .maxlen = sizeof(swap_token_default_timeout), 8451da177e4SLinus Torvalds .mode = 0644, 8461da177e4SLinus Torvalds .proc_handler = &proc_dointvec_jiffies, 8471da177e4SLinus Torvalds .strategy = &sysctl_jiffies, 8481da177e4SLinus Torvalds }, 8491da177e4SLinus Torvalds #endif 8501da177e4SLinus Torvalds { .ctl_name = 0 } 8511da177e4SLinus Torvalds }; 8521da177e4SLinus Torvalds 8531da177e4SLinus Torvalds static ctl_table proc_table[] = { 8541da177e4SLinus Torvalds { .ctl_name = 0 } 8551da177e4SLinus Torvalds }; 8561da177e4SLinus Torvalds 8571da177e4SLinus Torvalds static ctl_table fs_table[] = { 8581da177e4SLinus Torvalds { 8591da177e4SLinus Torvalds .ctl_name = FS_NRINODE, 8601da177e4SLinus Torvalds .procname = "inode-nr", 8611da177e4SLinus Torvalds .data = &inodes_stat, 8621da177e4SLinus Torvalds .maxlen = 2*sizeof(int), 8631da177e4SLinus Torvalds .mode = 0444, 8641da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8651da177e4SLinus Torvalds }, 8661da177e4SLinus Torvalds { 8671da177e4SLinus Torvalds .ctl_name = FS_STATINODE, 8681da177e4SLinus Torvalds .procname = "inode-state", 8691da177e4SLinus Torvalds .data = &inodes_stat, 8701da177e4SLinus Torvalds .maxlen = 7*sizeof(int), 8711da177e4SLinus Torvalds .mode = 0444, 8721da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8731da177e4SLinus Torvalds }, 8741da177e4SLinus Torvalds { 8751da177e4SLinus Torvalds .ctl_name = FS_NRFILE, 8761da177e4SLinus Torvalds .procname = "file-nr", 8771da177e4SLinus Torvalds .data = &files_stat, 8781da177e4SLinus Torvalds .maxlen = 3*sizeof(int), 8791da177e4SLinus Torvalds .mode = 0444, 8801da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8811da177e4SLinus Torvalds }, 8821da177e4SLinus Torvalds { 8831da177e4SLinus Torvalds .ctl_name = FS_MAXFILE, 8841da177e4SLinus Torvalds .procname = "file-max", 8851da177e4SLinus Torvalds .data = &files_stat.max_files, 8861da177e4SLinus Torvalds .maxlen = sizeof(int), 8871da177e4SLinus Torvalds .mode = 0644, 8881da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8891da177e4SLinus Torvalds }, 8901da177e4SLinus Torvalds { 8911da177e4SLinus Torvalds .ctl_name = FS_DENTRY, 8921da177e4SLinus Torvalds .procname = "dentry-state", 8931da177e4SLinus Torvalds .data = &dentry_stat, 8941da177e4SLinus Torvalds .maxlen = 6*sizeof(int), 8951da177e4SLinus Torvalds .mode = 0444, 8961da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 8971da177e4SLinus Torvalds }, 8981da177e4SLinus Torvalds { 8991da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWUID, 9001da177e4SLinus Torvalds .procname = "overflowuid", 9011da177e4SLinus Torvalds .data = &fs_overflowuid, 9021da177e4SLinus Torvalds .maxlen = sizeof(int), 9031da177e4SLinus Torvalds .mode = 0644, 9041da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 9051da177e4SLinus Torvalds .strategy = &sysctl_intvec, 9061da177e4SLinus Torvalds .extra1 = &minolduid, 9071da177e4SLinus Torvalds .extra2 = &maxolduid, 9081da177e4SLinus Torvalds }, 9091da177e4SLinus Torvalds { 9101da177e4SLinus Torvalds .ctl_name = FS_OVERFLOWGID, 9111da177e4SLinus Torvalds .procname = "overflowgid", 9121da177e4SLinus Torvalds .data = &fs_overflowgid, 9131da177e4SLinus Torvalds .maxlen = sizeof(int), 9141da177e4SLinus Torvalds .mode = 0644, 9151da177e4SLinus Torvalds .proc_handler = &proc_dointvec_minmax, 9161da177e4SLinus Torvalds .strategy = &sysctl_intvec, 9171da177e4SLinus Torvalds .extra1 = &minolduid, 9181da177e4SLinus Torvalds .extra2 = &maxolduid, 9191da177e4SLinus Torvalds }, 9201da177e4SLinus Torvalds { 9211da177e4SLinus Torvalds .ctl_name = FS_LEASES, 9221da177e4SLinus Torvalds .procname = "leases-enable", 9231da177e4SLinus Torvalds .data = &leases_enable, 9241da177e4SLinus Torvalds .maxlen = sizeof(int), 9251da177e4SLinus Torvalds .mode = 0644, 9261da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9271da177e4SLinus Torvalds }, 9281da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY 9291da177e4SLinus Torvalds { 9301da177e4SLinus Torvalds .ctl_name = FS_DIR_NOTIFY, 9311da177e4SLinus Torvalds .procname = "dir-notify-enable", 9321da177e4SLinus Torvalds .data = &dir_notify_enable, 9331da177e4SLinus Torvalds .maxlen = sizeof(int), 9341da177e4SLinus Torvalds .mode = 0644, 9351da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9361da177e4SLinus Torvalds }, 9371da177e4SLinus Torvalds #endif 9381da177e4SLinus Torvalds #ifdef CONFIG_MMU 9391da177e4SLinus Torvalds { 9401da177e4SLinus Torvalds .ctl_name = FS_LEASE_TIME, 9411da177e4SLinus Torvalds .procname = "lease-break-time", 9421da177e4SLinus Torvalds .data = &lease_break_time, 9431da177e4SLinus Torvalds .maxlen = sizeof(int), 9441da177e4SLinus Torvalds .mode = 0644, 9451da177e4SLinus Torvalds .proc_handler = &proc_dointvec, 9461da177e4SLinus Torvalds }, 9471da177e4SLinus Torvalds { 9481da177e4SLinus Torvalds .ctl_name = FS_AIO_NR, 9491da177e4SLinus Torvalds .procname = "aio-nr", 9501da177e4SLinus Torvalds .data = &aio_nr, 9511da177e4SLinus Torvalds .maxlen = sizeof(aio_nr), 9521da177e4SLinus Torvalds .mode = 0444, 953d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 9541da177e4SLinus Torvalds }, 9551da177e4SLinus Torvalds { 9561da177e4SLinus Torvalds .ctl_name = FS_AIO_MAX_NR, 9571da177e4SLinus Torvalds .procname = "aio-max-nr", 9581da177e4SLinus Torvalds .data = &aio_max_nr, 9591da177e4SLinus Torvalds .maxlen = sizeof(aio_max_nr), 9601da177e4SLinus Torvalds .mode = 0644, 961d55b5fdaSZach Brown .proc_handler = &proc_doulongvec_minmax, 9621da177e4SLinus Torvalds }, 9630399cb08SRobert Love #ifdef CONFIG_INOTIFY 9640399cb08SRobert Love { 9650399cb08SRobert Love .ctl_name = FS_INOTIFY, 9660399cb08SRobert Love .procname = "inotify", 9670399cb08SRobert Love .mode = 0555, 9680399cb08SRobert Love .child = inotify_table, 9690399cb08SRobert Love }, 9700399cb08SRobert Love #endif 9711da177e4SLinus Torvalds #endif 972d6e71144SAlan Cox { 973d6e71144SAlan Cox .ctl_name = KERN_SETUID_DUMPABLE, 974d6e71144SAlan Cox .procname = "suid_dumpable", 975d6e71144SAlan Cox .data = &suid_dumpable, 976d6e71144SAlan Cox .maxlen = sizeof(int), 977d6e71144SAlan Cox .mode = 0644, 978d6e71144SAlan Cox .proc_handler = &proc_dointvec, 979d6e71144SAlan Cox }, 9801da177e4SLinus Torvalds { .ctl_name = 0 } 9811da177e4SLinus Torvalds }; 9821da177e4SLinus Torvalds 9831da177e4SLinus Torvalds static ctl_table debug_table[] = { 9841da177e4SLinus Torvalds { .ctl_name = 0 } 9851da177e4SLinus Torvalds }; 9861da177e4SLinus Torvalds 9871da177e4SLinus Torvalds static ctl_table dev_table[] = { 9881da177e4SLinus Torvalds { .ctl_name = 0 } 9891da177e4SLinus Torvalds }; 9901da177e4SLinus Torvalds 9911da177e4SLinus Torvalds extern void init_irq_proc (void); 9921da177e4SLinus Torvalds 993330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock); 994330d57fbSAl Viro 995330d57fbSAl Viro /* called under sysctl_lock */ 996330d57fbSAl Viro static int use_table(struct ctl_table_header *p) 997330d57fbSAl Viro { 998330d57fbSAl Viro if (unlikely(p->unregistering)) 999330d57fbSAl Viro return 0; 1000330d57fbSAl Viro p->used++; 1001330d57fbSAl Viro return 1; 1002330d57fbSAl Viro } 1003330d57fbSAl Viro 1004330d57fbSAl Viro /* called under sysctl_lock */ 1005330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p) 1006330d57fbSAl Viro { 1007330d57fbSAl Viro if (!--p->used) 1008330d57fbSAl Viro if (unlikely(p->unregistering)) 1009330d57fbSAl Viro complete(p->unregistering); 1010330d57fbSAl Viro } 1011330d57fbSAl Viro 1012330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */ 1013330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p) 1014330d57fbSAl Viro { 1015330d57fbSAl Viro /* 1016330d57fbSAl Viro * if p->used is 0, nobody will ever touch that entry again; 1017330d57fbSAl Viro * we'll eliminate all paths to it before dropping sysctl_lock 1018330d57fbSAl Viro */ 1019330d57fbSAl Viro if (unlikely(p->used)) { 1020330d57fbSAl Viro struct completion wait; 1021330d57fbSAl Viro init_completion(&wait); 1022330d57fbSAl Viro p->unregistering = &wait; 1023330d57fbSAl Viro spin_unlock(&sysctl_lock); 1024330d57fbSAl Viro wait_for_completion(&wait); 1025330d57fbSAl Viro spin_lock(&sysctl_lock); 1026330d57fbSAl Viro } 1027330d57fbSAl Viro /* 1028330d57fbSAl Viro * do not remove from the list until nobody holds it; walking the 1029330d57fbSAl Viro * list in do_sysctl() relies on that. 1030330d57fbSAl Viro */ 1031330d57fbSAl Viro list_del_init(&p->ctl_entry); 1032330d57fbSAl Viro } 1033330d57fbSAl Viro 10341da177e4SLinus Torvalds void __init sysctl_init(void) 10351da177e4SLinus Torvalds { 10361da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 1037330d57fbSAl Viro register_proc_table(root_table, proc_sys_root, &root_table_header); 10381da177e4SLinus Torvalds init_irq_proc(); 10391da177e4SLinus Torvalds #endif 10401da177e4SLinus Torvalds } 10411da177e4SLinus Torvalds 10421da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 10431da177e4SLinus Torvalds void __user *newval, size_t newlen) 10441da177e4SLinus Torvalds { 10451da177e4SLinus Torvalds struct list_head *tmp; 1046330d57fbSAl Viro int error = -ENOTDIR; 10471da177e4SLinus Torvalds 10481da177e4SLinus Torvalds if (nlen <= 0 || nlen >= CTL_MAXNAME) 10491da177e4SLinus Torvalds return -ENOTDIR; 10501da177e4SLinus Torvalds if (oldval) { 10511da177e4SLinus Torvalds int old_len; 10521da177e4SLinus Torvalds if (!oldlenp || get_user(old_len, oldlenp)) 10531da177e4SLinus Torvalds return -EFAULT; 10541da177e4SLinus Torvalds } 1055330d57fbSAl Viro spin_lock(&sysctl_lock); 10561da177e4SLinus Torvalds tmp = &root_table_header.ctl_entry; 10571da177e4SLinus Torvalds do { 10581da177e4SLinus Torvalds struct ctl_table_header *head = 10591da177e4SLinus Torvalds list_entry(tmp, struct ctl_table_header, ctl_entry); 10601da177e4SLinus Torvalds void *context = NULL; 1061330d57fbSAl Viro 1062330d57fbSAl Viro if (!use_table(head)) 1063330d57fbSAl Viro continue; 1064330d57fbSAl Viro 1065330d57fbSAl Viro spin_unlock(&sysctl_lock); 1066330d57fbSAl Viro 1067330d57fbSAl Viro error = parse_table(name, nlen, oldval, oldlenp, 10681da177e4SLinus Torvalds newval, newlen, head->ctl_table, 10691da177e4SLinus Torvalds &context); 10701da177e4SLinus Torvalds kfree(context); 1071330d57fbSAl Viro 1072330d57fbSAl Viro spin_lock(&sysctl_lock); 1073330d57fbSAl Viro unuse_table(head); 10741da177e4SLinus Torvalds if (error != -ENOTDIR) 1075330d57fbSAl Viro break; 1076330d57fbSAl Viro } while ((tmp = tmp->next) != &root_table_header.ctl_entry); 1077330d57fbSAl Viro spin_unlock(&sysctl_lock); 10781da177e4SLinus Torvalds return error; 10791da177e4SLinus Torvalds } 10801da177e4SLinus Torvalds 10811da177e4SLinus Torvalds asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 10821da177e4SLinus Torvalds { 10831da177e4SLinus Torvalds struct __sysctl_args tmp; 10841da177e4SLinus Torvalds int error; 10851da177e4SLinus Torvalds 10861da177e4SLinus Torvalds if (copy_from_user(&tmp, args, sizeof(tmp))) 10871da177e4SLinus Torvalds return -EFAULT; 10881da177e4SLinus Torvalds 10891da177e4SLinus Torvalds lock_kernel(); 10901da177e4SLinus Torvalds error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, 10911da177e4SLinus Torvalds tmp.newval, tmp.newlen); 10921da177e4SLinus Torvalds unlock_kernel(); 10931da177e4SLinus Torvalds return error; 10941da177e4SLinus Torvalds } 10951da177e4SLinus Torvalds 10961da177e4SLinus Torvalds /* 10971da177e4SLinus Torvalds * ctl_perm does NOT grant the superuser all rights automatically, because 10981da177e4SLinus Torvalds * some sysctl variables are readonly even to root. 10991da177e4SLinus Torvalds */ 11001da177e4SLinus Torvalds 11011da177e4SLinus Torvalds static int test_perm(int mode, int op) 11021da177e4SLinus Torvalds { 11031da177e4SLinus Torvalds if (!current->euid) 11041da177e4SLinus Torvalds mode >>= 6; 11051da177e4SLinus Torvalds else if (in_egroup_p(0)) 11061da177e4SLinus Torvalds mode >>= 3; 11071da177e4SLinus Torvalds if ((mode & op & 0007) == op) 11081da177e4SLinus Torvalds return 0; 11091da177e4SLinus Torvalds return -EACCES; 11101da177e4SLinus Torvalds } 11111da177e4SLinus Torvalds 11121da177e4SLinus Torvalds static inline int ctl_perm(ctl_table *table, int op) 11131da177e4SLinus Torvalds { 11141da177e4SLinus Torvalds int error; 11151da177e4SLinus Torvalds error = security_sysctl(table, op); 11161da177e4SLinus Torvalds if (error) 11171da177e4SLinus Torvalds return error; 11181da177e4SLinus Torvalds return test_perm(table->mode, op); 11191da177e4SLinus Torvalds } 11201da177e4SLinus Torvalds 11211da177e4SLinus Torvalds static int parse_table(int __user *name, int nlen, 11221da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 11231da177e4SLinus Torvalds void __user *newval, size_t newlen, 11241da177e4SLinus Torvalds ctl_table *table, void **context) 11251da177e4SLinus Torvalds { 11261da177e4SLinus Torvalds int n; 11271da177e4SLinus Torvalds repeat: 11281da177e4SLinus Torvalds if (!nlen) 11291da177e4SLinus Torvalds return -ENOTDIR; 11301da177e4SLinus Torvalds if (get_user(n, name)) 11311da177e4SLinus Torvalds return -EFAULT; 11321da177e4SLinus Torvalds for ( ; table->ctl_name; table++) { 11331da177e4SLinus Torvalds if (n == table->ctl_name || table->ctl_name == CTL_ANY) { 11341da177e4SLinus Torvalds int error; 11351da177e4SLinus Torvalds if (table->child) { 11361da177e4SLinus Torvalds if (ctl_perm(table, 001)) 11371da177e4SLinus Torvalds return -EPERM; 11381da177e4SLinus Torvalds if (table->strategy) { 11391da177e4SLinus Torvalds error = table->strategy( 11401da177e4SLinus Torvalds table, name, nlen, 11411da177e4SLinus Torvalds oldval, oldlenp, 11421da177e4SLinus Torvalds newval, newlen, context); 11431da177e4SLinus Torvalds if (error) 11441da177e4SLinus Torvalds return error; 11451da177e4SLinus Torvalds } 11461da177e4SLinus Torvalds name++; 11471da177e4SLinus Torvalds nlen--; 11481da177e4SLinus Torvalds table = table->child; 11491da177e4SLinus Torvalds goto repeat; 11501da177e4SLinus Torvalds } 11511da177e4SLinus Torvalds error = do_sysctl_strategy(table, name, nlen, 11521da177e4SLinus Torvalds oldval, oldlenp, 11531da177e4SLinus Torvalds newval, newlen, context); 11541da177e4SLinus Torvalds return error; 11551da177e4SLinus Torvalds } 11561da177e4SLinus Torvalds } 11571da177e4SLinus Torvalds return -ENOTDIR; 11581da177e4SLinus Torvalds } 11591da177e4SLinus Torvalds 11601da177e4SLinus Torvalds /* Perform the actual read/write of a sysctl table entry. */ 11611da177e4SLinus Torvalds int do_sysctl_strategy (ctl_table *table, 11621da177e4SLinus Torvalds int __user *name, int nlen, 11631da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 11641da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 11651da177e4SLinus Torvalds { 11661da177e4SLinus Torvalds int op = 0, rc; 11671da177e4SLinus Torvalds size_t len; 11681da177e4SLinus Torvalds 11691da177e4SLinus Torvalds if (oldval) 11701da177e4SLinus Torvalds op |= 004; 11711da177e4SLinus Torvalds if (newval) 11721da177e4SLinus Torvalds op |= 002; 11731da177e4SLinus Torvalds if (ctl_perm(table, op)) 11741da177e4SLinus Torvalds return -EPERM; 11751da177e4SLinus Torvalds 11761da177e4SLinus Torvalds if (table->strategy) { 11771da177e4SLinus Torvalds rc = table->strategy(table, name, nlen, oldval, oldlenp, 11781da177e4SLinus Torvalds newval, newlen, context); 11791da177e4SLinus Torvalds if (rc < 0) 11801da177e4SLinus Torvalds return rc; 11811da177e4SLinus Torvalds if (rc > 0) 11821da177e4SLinus Torvalds return 0; 11831da177e4SLinus Torvalds } 11841da177e4SLinus Torvalds 11851da177e4SLinus Torvalds /* If there is no strategy routine, or if the strategy returns 11861da177e4SLinus Torvalds * zero, proceed with automatic r/w */ 11871da177e4SLinus Torvalds if (table->data && table->maxlen) { 11881da177e4SLinus Torvalds if (oldval && oldlenp) { 11891da177e4SLinus Torvalds if (get_user(len, oldlenp)) 11901da177e4SLinus Torvalds return -EFAULT; 11911da177e4SLinus Torvalds if (len) { 11921da177e4SLinus Torvalds if (len > table->maxlen) 11931da177e4SLinus Torvalds len = table->maxlen; 11941da177e4SLinus Torvalds if(copy_to_user(oldval, table->data, len)) 11951da177e4SLinus Torvalds return -EFAULT; 11961da177e4SLinus Torvalds if(put_user(len, oldlenp)) 11971da177e4SLinus Torvalds return -EFAULT; 11981da177e4SLinus Torvalds } 11991da177e4SLinus Torvalds } 12001da177e4SLinus Torvalds if (newval && newlen) { 12011da177e4SLinus Torvalds len = newlen; 12021da177e4SLinus Torvalds if (len > table->maxlen) 12031da177e4SLinus Torvalds len = table->maxlen; 12041da177e4SLinus Torvalds if(copy_from_user(table->data, newval, len)) 12051da177e4SLinus Torvalds return -EFAULT; 12061da177e4SLinus Torvalds } 12071da177e4SLinus Torvalds } 12081da177e4SLinus Torvalds return 0; 12091da177e4SLinus Torvalds } 12101da177e4SLinus Torvalds 12111da177e4SLinus Torvalds /** 12121da177e4SLinus Torvalds * register_sysctl_table - register a sysctl hierarchy 12131da177e4SLinus Torvalds * @table: the top-level table structure 12141da177e4SLinus Torvalds * @insert_at_head: whether the entry should be inserted in front or at the end 12151da177e4SLinus Torvalds * 12161da177e4SLinus Torvalds * Register a sysctl table hierarchy. @table should be a filled in ctl_table 12171da177e4SLinus Torvalds * array. An entry with a ctl_name of 0 terminates the table. 12181da177e4SLinus Torvalds * 12191da177e4SLinus Torvalds * The members of the &ctl_table structure are used as follows: 12201da177e4SLinus Torvalds * 12211da177e4SLinus Torvalds * ctl_name - This is the numeric sysctl value used by sysctl(2). The number 12221da177e4SLinus Torvalds * must be unique within that level of sysctl 12231da177e4SLinus Torvalds * 12241da177e4SLinus Torvalds * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not 12251da177e4SLinus Torvalds * enter a sysctl file 12261da177e4SLinus Torvalds * 12271da177e4SLinus Torvalds * data - a pointer to data for use by proc_handler 12281da177e4SLinus Torvalds * 12291da177e4SLinus Torvalds * maxlen - the maximum size in bytes of the data 12301da177e4SLinus Torvalds * 12311da177e4SLinus Torvalds * mode - the file permissions for the /proc/sys file, and for sysctl(2) 12321da177e4SLinus Torvalds * 12331da177e4SLinus Torvalds * child - a pointer to the child sysctl table if this entry is a directory, or 12341da177e4SLinus Torvalds * %NULL. 12351da177e4SLinus Torvalds * 12361da177e4SLinus Torvalds * proc_handler - the text handler routine (described below) 12371da177e4SLinus Torvalds * 12381da177e4SLinus Torvalds * strategy - the strategy routine (described below) 12391da177e4SLinus Torvalds * 12401da177e4SLinus Torvalds * de - for internal use by the sysctl routines 12411da177e4SLinus Torvalds * 12421da177e4SLinus Torvalds * extra1, extra2 - extra pointers usable by the proc handler routines 12431da177e4SLinus Torvalds * 12441da177e4SLinus Torvalds * Leaf nodes in the sysctl tree will be represented by a single file 12451da177e4SLinus Torvalds * under /proc; non-leaf nodes will be represented by directories. 12461da177e4SLinus Torvalds * 12471da177e4SLinus Torvalds * sysctl(2) can automatically manage read and write requests through 12481da177e4SLinus Torvalds * the sysctl table. The data and maxlen fields of the ctl_table 12491da177e4SLinus Torvalds * struct enable minimal validation of the values being written to be 12501da177e4SLinus Torvalds * performed, and the mode field allows minimal authentication. 12511da177e4SLinus Torvalds * 12521da177e4SLinus Torvalds * More sophisticated management can be enabled by the provision of a 12531da177e4SLinus Torvalds * strategy routine with the table entry. This will be called before 12541da177e4SLinus Torvalds * any automatic read or write of the data is performed. 12551da177e4SLinus Torvalds * 12561da177e4SLinus Torvalds * The strategy routine may return 12571da177e4SLinus Torvalds * 12581da177e4SLinus Torvalds * < 0 - Error occurred (error is passed to user process) 12591da177e4SLinus Torvalds * 12601da177e4SLinus Torvalds * 0 - OK - proceed with automatic read or write. 12611da177e4SLinus Torvalds * 12621da177e4SLinus Torvalds * > 0 - OK - read or write has been done by the strategy routine, so 12631da177e4SLinus Torvalds * return immediately. 12641da177e4SLinus Torvalds * 12651da177e4SLinus Torvalds * There must be a proc_handler routine for any terminal nodes 12661da177e4SLinus Torvalds * mirrored under /proc/sys (non-terminals are handled by a built-in 12671da177e4SLinus Torvalds * directory handler). Several default handlers are available to 12681da177e4SLinus Torvalds * cover common cases - 12691da177e4SLinus Torvalds * 12701da177e4SLinus Torvalds * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(), 12711da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(), 12721da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax() 12731da177e4SLinus Torvalds * 12741da177e4SLinus Torvalds * It is the handler's job to read the input buffer from user memory 12751da177e4SLinus Torvalds * and process it. The handler should return 0 on success. 12761da177e4SLinus Torvalds * 12771da177e4SLinus Torvalds * This routine returns %NULL on a failure to register, and a pointer 12781da177e4SLinus Torvalds * to the table header on success. 12791da177e4SLinus Torvalds */ 12801da177e4SLinus Torvalds struct ctl_table_header *register_sysctl_table(ctl_table * table, 12811da177e4SLinus Torvalds int insert_at_head) 12821da177e4SLinus Torvalds { 12831da177e4SLinus Torvalds struct ctl_table_header *tmp; 12841da177e4SLinus Torvalds tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL); 12851da177e4SLinus Torvalds if (!tmp) 12861da177e4SLinus Torvalds return NULL; 12871da177e4SLinus Torvalds tmp->ctl_table = table; 12881da177e4SLinus Torvalds INIT_LIST_HEAD(&tmp->ctl_entry); 1289330d57fbSAl Viro tmp->used = 0; 1290330d57fbSAl Viro tmp->unregistering = NULL; 1291330d57fbSAl Viro spin_lock(&sysctl_lock); 12921da177e4SLinus Torvalds if (insert_at_head) 12931da177e4SLinus Torvalds list_add(&tmp->ctl_entry, &root_table_header.ctl_entry); 12941da177e4SLinus Torvalds else 12951da177e4SLinus Torvalds list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1296330d57fbSAl Viro spin_unlock(&sysctl_lock); 12971da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 1298330d57fbSAl Viro register_proc_table(table, proc_sys_root, tmp); 12991da177e4SLinus Torvalds #endif 13001da177e4SLinus Torvalds return tmp; 13011da177e4SLinus Torvalds } 13021da177e4SLinus Torvalds 13031da177e4SLinus Torvalds /** 13041da177e4SLinus Torvalds * unregister_sysctl_table - unregister a sysctl table hierarchy 13051da177e4SLinus Torvalds * @header: the header returned from register_sysctl_table 13061da177e4SLinus Torvalds * 13071da177e4SLinus Torvalds * Unregisters the sysctl table and all children. proc entries may not 13081da177e4SLinus Torvalds * actually be removed until they are no longer used by anyone. 13091da177e4SLinus Torvalds */ 13101da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header) 13111da177e4SLinus Torvalds { 1312330d57fbSAl Viro might_sleep(); 1313330d57fbSAl Viro spin_lock(&sysctl_lock); 1314330d57fbSAl Viro start_unregistering(header); 13151da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 13161da177e4SLinus Torvalds unregister_proc_table(header->ctl_table, proc_sys_root); 13171da177e4SLinus Torvalds #endif 1318330d57fbSAl Viro spin_unlock(&sysctl_lock); 13191da177e4SLinus Torvalds kfree(header); 13201da177e4SLinus Torvalds } 13211da177e4SLinus Torvalds 13221da177e4SLinus Torvalds /* 13231da177e4SLinus Torvalds * /proc/sys support 13241da177e4SLinus Torvalds */ 13251da177e4SLinus Torvalds 13261da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 13271da177e4SLinus Torvalds 13281da177e4SLinus Torvalds /* Scan the sysctl entries in table and add them all into /proc */ 1329330d57fbSAl Viro static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set) 13301da177e4SLinus Torvalds { 13311da177e4SLinus Torvalds struct proc_dir_entry *de; 13321da177e4SLinus Torvalds int len; 13331da177e4SLinus Torvalds mode_t mode; 13341da177e4SLinus Torvalds 13351da177e4SLinus Torvalds for (; table->ctl_name; table++) { 13361da177e4SLinus Torvalds /* Can't do anything without a proc name. */ 13371da177e4SLinus Torvalds if (!table->procname) 13381da177e4SLinus Torvalds continue; 13391da177e4SLinus Torvalds /* Maybe we can't do anything with it... */ 13401da177e4SLinus Torvalds if (!table->proc_handler && !table->child) { 13411da177e4SLinus Torvalds printk(KERN_WARNING "SYSCTL: Can't register %s\n", 13421da177e4SLinus Torvalds table->procname); 13431da177e4SLinus Torvalds continue; 13441da177e4SLinus Torvalds } 13451da177e4SLinus Torvalds 13461da177e4SLinus Torvalds len = strlen(table->procname); 13471da177e4SLinus Torvalds mode = table->mode; 13481da177e4SLinus Torvalds 13491da177e4SLinus Torvalds de = NULL; 13501da177e4SLinus Torvalds if (table->proc_handler) 13511da177e4SLinus Torvalds mode |= S_IFREG; 13521da177e4SLinus Torvalds else { 13531da177e4SLinus Torvalds mode |= S_IFDIR; 13541da177e4SLinus Torvalds for (de = root->subdir; de; de = de->next) { 13551da177e4SLinus Torvalds if (proc_match(len, table->procname, de)) 13561da177e4SLinus Torvalds break; 13571da177e4SLinus Torvalds } 13581da177e4SLinus Torvalds /* If the subdir exists already, de is non-NULL */ 13591da177e4SLinus Torvalds } 13601da177e4SLinus Torvalds 13611da177e4SLinus Torvalds if (!de) { 13621da177e4SLinus Torvalds de = create_proc_entry(table->procname, mode, root); 13631da177e4SLinus Torvalds if (!de) 13641da177e4SLinus Torvalds continue; 1365330d57fbSAl Viro de->set = set; 13661da177e4SLinus Torvalds de->data = (void *) table; 13671da177e4SLinus Torvalds if (table->proc_handler) 13681da177e4SLinus Torvalds de->proc_fops = &proc_sys_file_operations; 13691da177e4SLinus Torvalds } 13701da177e4SLinus Torvalds table->de = de; 13711da177e4SLinus Torvalds if (de->mode & S_IFDIR) 1372330d57fbSAl Viro register_proc_table(table->child, de, set); 13731da177e4SLinus Torvalds } 13741da177e4SLinus Torvalds } 13751da177e4SLinus Torvalds 13761da177e4SLinus Torvalds /* 13771da177e4SLinus Torvalds * Unregister a /proc sysctl table and any subdirectories. 13781da177e4SLinus Torvalds */ 13791da177e4SLinus Torvalds static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root) 13801da177e4SLinus Torvalds { 13811da177e4SLinus Torvalds struct proc_dir_entry *de; 13821da177e4SLinus Torvalds for (; table->ctl_name; table++) { 13831da177e4SLinus Torvalds if (!(de = table->de)) 13841da177e4SLinus Torvalds continue; 13851da177e4SLinus Torvalds if (de->mode & S_IFDIR) { 13861da177e4SLinus Torvalds if (!table->child) { 13871da177e4SLinus Torvalds printk (KERN_ALERT "Help - malformed sysctl tree on free\n"); 13881da177e4SLinus Torvalds continue; 13891da177e4SLinus Torvalds } 13901da177e4SLinus Torvalds unregister_proc_table(table->child, de); 13911da177e4SLinus Torvalds 13921da177e4SLinus Torvalds /* Don't unregister directories which still have entries.. */ 13931da177e4SLinus Torvalds if (de->subdir) 13941da177e4SLinus Torvalds continue; 13951da177e4SLinus Torvalds } 13961da177e4SLinus Torvalds 1397330d57fbSAl Viro /* 1398330d57fbSAl Viro * In any case, mark the entry as goner; we'll keep it 1399330d57fbSAl Viro * around if it's busy, but we'll know to do nothing with 1400330d57fbSAl Viro * its fields. We are under sysctl_lock here. 1401330d57fbSAl Viro */ 1402330d57fbSAl Viro de->data = NULL; 1403330d57fbSAl Viro 14041da177e4SLinus Torvalds /* Don't unregister proc entries that are still being used.. */ 14051da177e4SLinus Torvalds if (atomic_read(&de->count)) 14061da177e4SLinus Torvalds continue; 14071da177e4SLinus Torvalds 14081da177e4SLinus Torvalds table->de = NULL; 14091da177e4SLinus Torvalds remove_proc_entry(table->procname, root); 14101da177e4SLinus Torvalds } 14111da177e4SLinus Torvalds } 14121da177e4SLinus Torvalds 14131da177e4SLinus Torvalds static ssize_t do_rw_proc(int write, struct file * file, char __user * buf, 14141da177e4SLinus Torvalds size_t count, loff_t *ppos) 14151da177e4SLinus Torvalds { 14161da177e4SLinus Torvalds int op; 1417330d57fbSAl Viro struct proc_dir_entry *de = PDE(file->f_dentry->d_inode); 14181da177e4SLinus Torvalds struct ctl_table *table; 14191da177e4SLinus Torvalds size_t res; 1420330d57fbSAl Viro ssize_t error = -ENOTDIR; 14211da177e4SLinus Torvalds 1422330d57fbSAl Viro spin_lock(&sysctl_lock); 1423330d57fbSAl Viro if (de && de->data && use_table(de->set)) { 1424330d57fbSAl Viro /* 1425330d57fbSAl Viro * at that point we know that sysctl was not unregistered 1426330d57fbSAl Viro * and won't be until we finish 1427330d57fbSAl Viro */ 1428330d57fbSAl Viro spin_unlock(&sysctl_lock); 14291da177e4SLinus Torvalds table = (struct ctl_table *) de->data; 14301da177e4SLinus Torvalds if (!table || !table->proc_handler) 1431330d57fbSAl Viro goto out; 1432330d57fbSAl Viro error = -EPERM; 14331da177e4SLinus Torvalds op = (write ? 002 : 004); 14341da177e4SLinus Torvalds if (ctl_perm(table, op)) 1435330d57fbSAl Viro goto out; 14361da177e4SLinus Torvalds 1437330d57fbSAl Viro /* careful: calling conventions are nasty here */ 14381da177e4SLinus Torvalds res = count; 1439330d57fbSAl Viro error = (*table->proc_handler)(table, write, file, 1440330d57fbSAl Viro buf, &res, ppos); 1441330d57fbSAl Viro if (!error) 1442330d57fbSAl Viro error = res; 1443330d57fbSAl Viro out: 1444330d57fbSAl Viro spin_lock(&sysctl_lock); 1445330d57fbSAl Viro unuse_table(de->set); 1446330d57fbSAl Viro } 1447330d57fbSAl Viro spin_unlock(&sysctl_lock); 14481da177e4SLinus Torvalds return error; 14491da177e4SLinus Torvalds } 14501da177e4SLinus Torvalds 14511da177e4SLinus Torvalds static int proc_opensys(struct inode *inode, struct file *file) 14521da177e4SLinus Torvalds { 14531da177e4SLinus Torvalds if (file->f_mode & FMODE_WRITE) { 14541da177e4SLinus Torvalds /* 14551da177e4SLinus Torvalds * sysctl entries that are not writable, 14561da177e4SLinus Torvalds * are _NOT_ writable, capabilities or not. 14571da177e4SLinus Torvalds */ 14581da177e4SLinus Torvalds if (!(inode->i_mode & S_IWUSR)) 14591da177e4SLinus Torvalds return -EPERM; 14601da177e4SLinus Torvalds } 14611da177e4SLinus Torvalds 14621da177e4SLinus Torvalds return 0; 14631da177e4SLinus Torvalds } 14641da177e4SLinus Torvalds 14651da177e4SLinus Torvalds static ssize_t proc_readsys(struct file * file, char __user * buf, 14661da177e4SLinus Torvalds size_t count, loff_t *ppos) 14671da177e4SLinus Torvalds { 14681da177e4SLinus Torvalds return do_rw_proc(0, file, buf, count, ppos); 14691da177e4SLinus Torvalds } 14701da177e4SLinus Torvalds 14711da177e4SLinus Torvalds static ssize_t proc_writesys(struct file * file, const char __user * buf, 14721da177e4SLinus Torvalds size_t count, loff_t *ppos) 14731da177e4SLinus Torvalds { 14741da177e4SLinus Torvalds return do_rw_proc(1, file, (char __user *) buf, count, ppos); 14751da177e4SLinus Torvalds } 14761da177e4SLinus Torvalds 14771da177e4SLinus Torvalds /** 14781da177e4SLinus Torvalds * proc_dostring - read a string sysctl 14791da177e4SLinus Torvalds * @table: the sysctl table 14801da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 14811da177e4SLinus Torvalds * @filp: the file structure 14821da177e4SLinus Torvalds * @buffer: the user buffer 14831da177e4SLinus Torvalds * @lenp: the size of the user buffer 14841da177e4SLinus Torvalds * @ppos: file position 14851da177e4SLinus Torvalds * 14861da177e4SLinus Torvalds * Reads/writes a string from/to the user buffer. If the kernel 14871da177e4SLinus Torvalds * buffer provided is not large enough to hold the string, the 14881da177e4SLinus Torvalds * string is truncated. The copied string is %NULL-terminated. 14891da177e4SLinus Torvalds * If the string is being read by the user process, it is copied 14901da177e4SLinus Torvalds * and a newline '\n' is added. It is truncated if the buffer is 14911da177e4SLinus Torvalds * not large enough. 14921da177e4SLinus Torvalds * 14931da177e4SLinus Torvalds * Returns 0 on success. 14941da177e4SLinus Torvalds */ 14951da177e4SLinus Torvalds int proc_dostring(ctl_table *table, int write, struct file *filp, 14961da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 14971da177e4SLinus Torvalds { 14981da177e4SLinus Torvalds size_t len; 14991da177e4SLinus Torvalds char __user *p; 15001da177e4SLinus Torvalds char c; 15011da177e4SLinus Torvalds 15021da177e4SLinus Torvalds if (!table->data || !table->maxlen || !*lenp || 15031da177e4SLinus Torvalds (*ppos && !write)) { 15041da177e4SLinus Torvalds *lenp = 0; 15051da177e4SLinus Torvalds return 0; 15061da177e4SLinus Torvalds } 15071da177e4SLinus Torvalds 15081da177e4SLinus Torvalds if (write) { 15091da177e4SLinus Torvalds len = 0; 15101da177e4SLinus Torvalds p = buffer; 15111da177e4SLinus Torvalds while (len < *lenp) { 15121da177e4SLinus Torvalds if (get_user(c, p++)) 15131da177e4SLinus Torvalds return -EFAULT; 15141da177e4SLinus Torvalds if (c == 0 || c == '\n') 15151da177e4SLinus Torvalds break; 15161da177e4SLinus Torvalds len++; 15171da177e4SLinus Torvalds } 15181da177e4SLinus Torvalds if (len >= table->maxlen) 15191da177e4SLinus Torvalds len = table->maxlen-1; 15201da177e4SLinus Torvalds if(copy_from_user(table->data, buffer, len)) 15211da177e4SLinus Torvalds return -EFAULT; 15221da177e4SLinus Torvalds ((char *) table->data)[len] = 0; 15231da177e4SLinus Torvalds *ppos += *lenp; 15241da177e4SLinus Torvalds } else { 15251da177e4SLinus Torvalds len = strlen(table->data); 15261da177e4SLinus Torvalds if (len > table->maxlen) 15271da177e4SLinus Torvalds len = table->maxlen; 15281da177e4SLinus Torvalds if (len > *lenp) 15291da177e4SLinus Torvalds len = *lenp; 15301da177e4SLinus Torvalds if (len) 15311da177e4SLinus Torvalds if(copy_to_user(buffer, table->data, len)) 15321da177e4SLinus Torvalds return -EFAULT; 15331da177e4SLinus Torvalds if (len < *lenp) { 15341da177e4SLinus Torvalds if(put_user('\n', ((char __user *) buffer) + len)) 15351da177e4SLinus Torvalds return -EFAULT; 15361da177e4SLinus Torvalds len++; 15371da177e4SLinus Torvalds } 15381da177e4SLinus Torvalds *lenp = len; 15391da177e4SLinus Torvalds *ppos += len; 15401da177e4SLinus Torvalds } 15411da177e4SLinus Torvalds return 0; 15421da177e4SLinus Torvalds } 15431da177e4SLinus Torvalds 15441da177e4SLinus Torvalds /* 15451da177e4SLinus Torvalds * Special case of dostring for the UTS structure. This has locks 15461da177e4SLinus Torvalds * to observe. Should this be in kernel/sys.c ???? 15471da177e4SLinus Torvalds */ 15481da177e4SLinus Torvalds 15491da177e4SLinus Torvalds static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 15501da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 15511da177e4SLinus Torvalds { 15521da177e4SLinus Torvalds int r; 15531da177e4SLinus Torvalds 15541da177e4SLinus Torvalds if (!write) { 15551da177e4SLinus Torvalds down_read(&uts_sem); 15561da177e4SLinus Torvalds r=proc_dostring(table,0,filp,buffer,lenp, ppos); 15571da177e4SLinus Torvalds up_read(&uts_sem); 15581da177e4SLinus Torvalds } else { 15591da177e4SLinus Torvalds down_write(&uts_sem); 15601da177e4SLinus Torvalds r=proc_dostring(table,1,filp,buffer,lenp, ppos); 15611da177e4SLinus Torvalds up_write(&uts_sem); 15621da177e4SLinus Torvalds } 15631da177e4SLinus Torvalds return r; 15641da177e4SLinus Torvalds } 15651da177e4SLinus Torvalds 15661da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 15671da177e4SLinus Torvalds int *valp, 15681da177e4SLinus Torvalds int write, void *data) 15691da177e4SLinus Torvalds { 15701da177e4SLinus Torvalds if (write) { 15711da177e4SLinus Torvalds *valp = *negp ? -*lvalp : *lvalp; 15721da177e4SLinus Torvalds } else { 15731da177e4SLinus Torvalds int val = *valp; 15741da177e4SLinus Torvalds if (val < 0) { 15751da177e4SLinus Torvalds *negp = -1; 15761da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 15771da177e4SLinus Torvalds } else { 15781da177e4SLinus Torvalds *negp = 0; 15791da177e4SLinus Torvalds *lvalp = (unsigned long)val; 15801da177e4SLinus Torvalds } 15811da177e4SLinus Torvalds } 15821da177e4SLinus Torvalds return 0; 15831da177e4SLinus Torvalds } 15841da177e4SLinus Torvalds 15851da177e4SLinus Torvalds static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, 15861da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos, 15871da177e4SLinus Torvalds int (*conv)(int *negp, unsigned long *lvalp, int *valp, 15881da177e4SLinus Torvalds int write, void *data), 15891da177e4SLinus Torvalds void *data) 15901da177e4SLinus Torvalds { 15911da177e4SLinus Torvalds #define TMPBUFLEN 21 15921da177e4SLinus Torvalds int *i, vleft, first=1, neg, val; 15931da177e4SLinus Torvalds unsigned long lval; 15941da177e4SLinus Torvalds size_t left, len; 15951da177e4SLinus Torvalds 15961da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 15971da177e4SLinus Torvalds char __user *s = buffer; 15981da177e4SLinus Torvalds 15991da177e4SLinus Torvalds if (!table->data || !table->maxlen || !*lenp || 16001da177e4SLinus Torvalds (*ppos && !write)) { 16011da177e4SLinus Torvalds *lenp = 0; 16021da177e4SLinus Torvalds return 0; 16031da177e4SLinus Torvalds } 16041da177e4SLinus Torvalds 16051da177e4SLinus Torvalds i = (int *) table->data; 16061da177e4SLinus Torvalds vleft = table->maxlen / sizeof(*i); 16071da177e4SLinus Torvalds left = *lenp; 16081da177e4SLinus Torvalds 16091da177e4SLinus Torvalds if (!conv) 16101da177e4SLinus Torvalds conv = do_proc_dointvec_conv; 16111da177e4SLinus Torvalds 16121da177e4SLinus Torvalds for (; left && vleft--; i++, first=0) { 16131da177e4SLinus Torvalds if (write) { 16141da177e4SLinus Torvalds while (left) { 16151da177e4SLinus Torvalds char c; 16161da177e4SLinus Torvalds if (get_user(c, s)) 16171da177e4SLinus Torvalds return -EFAULT; 16181da177e4SLinus Torvalds if (!isspace(c)) 16191da177e4SLinus Torvalds break; 16201da177e4SLinus Torvalds left--; 16211da177e4SLinus Torvalds s++; 16221da177e4SLinus Torvalds } 16231da177e4SLinus Torvalds if (!left) 16241da177e4SLinus Torvalds break; 16251da177e4SLinus Torvalds neg = 0; 16261da177e4SLinus Torvalds len = left; 16271da177e4SLinus Torvalds if (len > sizeof(buf) - 1) 16281da177e4SLinus Torvalds len = sizeof(buf) - 1; 16291da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 16301da177e4SLinus Torvalds return -EFAULT; 16311da177e4SLinus Torvalds buf[len] = 0; 16321da177e4SLinus Torvalds p = buf; 16331da177e4SLinus Torvalds if (*p == '-' && left > 1) { 16341da177e4SLinus Torvalds neg = 1; 16351da177e4SLinus Torvalds left--, p++; 16361da177e4SLinus Torvalds } 16371da177e4SLinus Torvalds if (*p < '0' || *p > '9') 16381da177e4SLinus Torvalds break; 16391da177e4SLinus Torvalds 16401da177e4SLinus Torvalds lval = simple_strtoul(p, &p, 0); 16411da177e4SLinus Torvalds 16421da177e4SLinus Torvalds len = p-buf; 16431da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 16441da177e4SLinus Torvalds break; 16451da177e4SLinus Torvalds if (neg) 16461da177e4SLinus Torvalds val = -val; 16471da177e4SLinus Torvalds s += len; 16481da177e4SLinus Torvalds left -= len; 16491da177e4SLinus Torvalds 16501da177e4SLinus Torvalds if (conv(&neg, &lval, i, 1, data)) 16511da177e4SLinus Torvalds break; 16521da177e4SLinus Torvalds } else { 16531da177e4SLinus Torvalds p = buf; 16541da177e4SLinus Torvalds if (!first) 16551da177e4SLinus Torvalds *p++ = '\t'; 16561da177e4SLinus Torvalds 16571da177e4SLinus Torvalds if (conv(&neg, &lval, i, 0, data)) 16581da177e4SLinus Torvalds break; 16591da177e4SLinus Torvalds 16601da177e4SLinus Torvalds sprintf(p, "%s%lu", neg ? "-" : "", lval); 16611da177e4SLinus Torvalds len = strlen(buf); 16621da177e4SLinus Torvalds if (len > left) 16631da177e4SLinus Torvalds len = left; 16641da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 16651da177e4SLinus Torvalds return -EFAULT; 16661da177e4SLinus Torvalds left -= len; 16671da177e4SLinus Torvalds s += len; 16681da177e4SLinus Torvalds } 16691da177e4SLinus Torvalds } 16701da177e4SLinus Torvalds 16711da177e4SLinus Torvalds if (!write && !first && left) { 16721da177e4SLinus Torvalds if(put_user('\n', s)) 16731da177e4SLinus Torvalds return -EFAULT; 16741da177e4SLinus Torvalds left--, s++; 16751da177e4SLinus Torvalds } 16761da177e4SLinus Torvalds if (write) { 16771da177e4SLinus Torvalds while (left) { 16781da177e4SLinus Torvalds char c; 16791da177e4SLinus Torvalds if (get_user(c, s++)) 16801da177e4SLinus Torvalds return -EFAULT; 16811da177e4SLinus Torvalds if (!isspace(c)) 16821da177e4SLinus Torvalds break; 16831da177e4SLinus Torvalds left--; 16841da177e4SLinus Torvalds } 16851da177e4SLinus Torvalds } 16861da177e4SLinus Torvalds if (write && first) 16871da177e4SLinus Torvalds return -EINVAL; 16881da177e4SLinus Torvalds *lenp -= left; 16891da177e4SLinus Torvalds *ppos += *lenp; 16901da177e4SLinus Torvalds return 0; 16911da177e4SLinus Torvalds #undef TMPBUFLEN 16921da177e4SLinus Torvalds } 16931da177e4SLinus Torvalds 16941da177e4SLinus Torvalds /** 16951da177e4SLinus Torvalds * proc_dointvec - read a vector of integers 16961da177e4SLinus Torvalds * @table: the sysctl table 16971da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 16981da177e4SLinus Torvalds * @filp: the file structure 16991da177e4SLinus Torvalds * @buffer: the user buffer 17001da177e4SLinus Torvalds * @lenp: the size of the user buffer 17011da177e4SLinus Torvalds * @ppos: file position 17021da177e4SLinus Torvalds * 17031da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 17041da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 17051da177e4SLinus Torvalds * 17061da177e4SLinus Torvalds * Returns 0 on success. 17071da177e4SLinus Torvalds */ 17081da177e4SLinus Torvalds int proc_dointvec(ctl_table *table, int write, struct file *filp, 17091da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 17101da177e4SLinus Torvalds { 17111da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 17121da177e4SLinus Torvalds NULL,NULL); 17131da177e4SLinus Torvalds } 17141da177e4SLinus Torvalds 17151da177e4SLinus Torvalds #define OP_SET 0 17161da177e4SLinus Torvalds #define OP_AND 1 17171da177e4SLinus Torvalds #define OP_OR 2 17181da177e4SLinus Torvalds #define OP_MAX 3 17191da177e4SLinus Torvalds #define OP_MIN 4 17201da177e4SLinus Torvalds 17211da177e4SLinus Torvalds static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp, 17221da177e4SLinus Torvalds int *valp, 17231da177e4SLinus Torvalds int write, void *data) 17241da177e4SLinus Torvalds { 17251da177e4SLinus Torvalds int op = *(int *)data; 17261da177e4SLinus Torvalds if (write) { 17271da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 17281da177e4SLinus Torvalds switch(op) { 17291da177e4SLinus Torvalds case OP_SET: *valp = val; break; 17301da177e4SLinus Torvalds case OP_AND: *valp &= val; break; 17311da177e4SLinus Torvalds case OP_OR: *valp |= val; break; 17321da177e4SLinus Torvalds case OP_MAX: if(*valp < val) 17331da177e4SLinus Torvalds *valp = val; 17341da177e4SLinus Torvalds break; 17351da177e4SLinus Torvalds case OP_MIN: if(*valp > val) 17361da177e4SLinus Torvalds *valp = val; 17371da177e4SLinus Torvalds break; 17381da177e4SLinus Torvalds } 17391da177e4SLinus Torvalds } else { 17401da177e4SLinus Torvalds int val = *valp; 17411da177e4SLinus Torvalds if (val < 0) { 17421da177e4SLinus Torvalds *negp = -1; 17431da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 17441da177e4SLinus Torvalds } else { 17451da177e4SLinus Torvalds *negp = 0; 17461da177e4SLinus Torvalds *lvalp = (unsigned long)val; 17471da177e4SLinus Torvalds } 17481da177e4SLinus Torvalds } 17491da177e4SLinus Torvalds return 0; 17501da177e4SLinus Torvalds } 17511da177e4SLinus Torvalds 17521da177e4SLinus Torvalds /* 17531da177e4SLinus Torvalds * init may raise the set. 17541da177e4SLinus Torvalds */ 17551da177e4SLinus Torvalds 17561da177e4SLinus Torvalds int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, 17571da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 17581da177e4SLinus Torvalds { 17591da177e4SLinus Torvalds int op; 17601da177e4SLinus Torvalds 17611da177e4SLinus Torvalds if (!capable(CAP_SYS_MODULE)) { 17621da177e4SLinus Torvalds return -EPERM; 17631da177e4SLinus Torvalds } 17641da177e4SLinus Torvalds 17651da177e4SLinus Torvalds op = (current->pid == 1) ? OP_SET : OP_AND; 17661da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 17671da177e4SLinus Torvalds do_proc_dointvec_bset_conv,&op); 17681da177e4SLinus Torvalds } 17691da177e4SLinus Torvalds 17701da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param { 17711da177e4SLinus Torvalds int *min; 17721da177e4SLinus Torvalds int *max; 17731da177e4SLinus Torvalds }; 17741da177e4SLinus Torvalds 17751da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, 17761da177e4SLinus Torvalds int *valp, 17771da177e4SLinus Torvalds int write, void *data) 17781da177e4SLinus Torvalds { 17791da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param *param = data; 17801da177e4SLinus Torvalds if (write) { 17811da177e4SLinus Torvalds int val = *negp ? -*lvalp : *lvalp; 17821da177e4SLinus Torvalds if ((param->min && *param->min > val) || 17831da177e4SLinus Torvalds (param->max && *param->max < val)) 17841da177e4SLinus Torvalds return -EINVAL; 17851da177e4SLinus Torvalds *valp = val; 17861da177e4SLinus Torvalds } else { 17871da177e4SLinus Torvalds int val = *valp; 17881da177e4SLinus Torvalds if (val < 0) { 17891da177e4SLinus Torvalds *negp = -1; 17901da177e4SLinus Torvalds *lvalp = (unsigned long)-val; 17911da177e4SLinus Torvalds } else { 17921da177e4SLinus Torvalds *negp = 0; 17931da177e4SLinus Torvalds *lvalp = (unsigned long)val; 17941da177e4SLinus Torvalds } 17951da177e4SLinus Torvalds } 17961da177e4SLinus Torvalds return 0; 17971da177e4SLinus Torvalds } 17981da177e4SLinus Torvalds 17991da177e4SLinus Torvalds /** 18001da177e4SLinus Torvalds * proc_dointvec_minmax - read a vector of integers with min/max values 18011da177e4SLinus Torvalds * @table: the sysctl table 18021da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 18031da177e4SLinus Torvalds * @filp: the file structure 18041da177e4SLinus Torvalds * @buffer: the user buffer 18051da177e4SLinus Torvalds * @lenp: the size of the user buffer 18061da177e4SLinus Torvalds * @ppos: file position 18071da177e4SLinus Torvalds * 18081da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 18091da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 18101da177e4SLinus Torvalds * 18111da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 18121da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 18131da177e4SLinus Torvalds * 18141da177e4SLinus Torvalds * Returns 0 on success. 18151da177e4SLinus Torvalds */ 18161da177e4SLinus Torvalds int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, 18171da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 18181da177e4SLinus Torvalds { 18191da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param param = { 18201da177e4SLinus Torvalds .min = (int *) table->extra1, 18211da177e4SLinus Torvalds .max = (int *) table->extra2, 18221da177e4SLinus Torvalds }; 18231da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 18241da177e4SLinus Torvalds do_proc_dointvec_minmax_conv, ¶m); 18251da177e4SLinus Torvalds } 18261da177e4SLinus Torvalds 18271da177e4SLinus Torvalds static int do_proc_doulongvec_minmax(ctl_table *table, int write, 18281da177e4SLinus Torvalds struct file *filp, 18291da177e4SLinus Torvalds void __user *buffer, 18301da177e4SLinus Torvalds size_t *lenp, loff_t *ppos, 18311da177e4SLinus Torvalds unsigned long convmul, 18321da177e4SLinus Torvalds unsigned long convdiv) 18331da177e4SLinus Torvalds { 18341da177e4SLinus Torvalds #define TMPBUFLEN 21 18351da177e4SLinus Torvalds unsigned long *i, *min, *max, val; 18361da177e4SLinus Torvalds int vleft, first=1, neg; 18371da177e4SLinus Torvalds size_t len, left; 18381da177e4SLinus Torvalds char buf[TMPBUFLEN], *p; 18391da177e4SLinus Torvalds char __user *s = buffer; 18401da177e4SLinus Torvalds 18411da177e4SLinus Torvalds if (!table->data || !table->maxlen || !*lenp || 18421da177e4SLinus Torvalds (*ppos && !write)) { 18431da177e4SLinus Torvalds *lenp = 0; 18441da177e4SLinus Torvalds return 0; 18451da177e4SLinus Torvalds } 18461da177e4SLinus Torvalds 18471da177e4SLinus Torvalds i = (unsigned long *) table->data; 18481da177e4SLinus Torvalds min = (unsigned long *) table->extra1; 18491da177e4SLinus Torvalds max = (unsigned long *) table->extra2; 18501da177e4SLinus Torvalds vleft = table->maxlen / sizeof(unsigned long); 18511da177e4SLinus Torvalds left = *lenp; 18521da177e4SLinus Torvalds 18531da177e4SLinus Torvalds for (; left && vleft--; i++, min++, max++, first=0) { 18541da177e4SLinus Torvalds if (write) { 18551da177e4SLinus Torvalds while (left) { 18561da177e4SLinus Torvalds char c; 18571da177e4SLinus Torvalds if (get_user(c, s)) 18581da177e4SLinus Torvalds return -EFAULT; 18591da177e4SLinus Torvalds if (!isspace(c)) 18601da177e4SLinus Torvalds break; 18611da177e4SLinus Torvalds left--; 18621da177e4SLinus Torvalds s++; 18631da177e4SLinus Torvalds } 18641da177e4SLinus Torvalds if (!left) 18651da177e4SLinus Torvalds break; 18661da177e4SLinus Torvalds neg = 0; 18671da177e4SLinus Torvalds len = left; 18681da177e4SLinus Torvalds if (len > TMPBUFLEN-1) 18691da177e4SLinus Torvalds len = TMPBUFLEN-1; 18701da177e4SLinus Torvalds if (copy_from_user(buf, s, len)) 18711da177e4SLinus Torvalds return -EFAULT; 18721da177e4SLinus Torvalds buf[len] = 0; 18731da177e4SLinus Torvalds p = buf; 18741da177e4SLinus Torvalds if (*p == '-' && left > 1) { 18751da177e4SLinus Torvalds neg = 1; 18761da177e4SLinus Torvalds left--, p++; 18771da177e4SLinus Torvalds } 18781da177e4SLinus Torvalds if (*p < '0' || *p > '9') 18791da177e4SLinus Torvalds break; 18801da177e4SLinus Torvalds val = simple_strtoul(p, &p, 0) * convmul / convdiv ; 18811da177e4SLinus Torvalds len = p-buf; 18821da177e4SLinus Torvalds if ((len < left) && *p && !isspace(*p)) 18831da177e4SLinus Torvalds break; 18841da177e4SLinus Torvalds if (neg) 18851da177e4SLinus Torvalds val = -val; 18861da177e4SLinus Torvalds s += len; 18871da177e4SLinus Torvalds left -= len; 18881da177e4SLinus Torvalds 18891da177e4SLinus Torvalds if(neg) 18901da177e4SLinus Torvalds continue; 18911da177e4SLinus Torvalds if ((min && val < *min) || (max && val > *max)) 18921da177e4SLinus Torvalds continue; 18931da177e4SLinus Torvalds *i = val; 18941da177e4SLinus Torvalds } else { 18951da177e4SLinus Torvalds p = buf; 18961da177e4SLinus Torvalds if (!first) 18971da177e4SLinus Torvalds *p++ = '\t'; 18981da177e4SLinus Torvalds sprintf(p, "%lu", convdiv * (*i) / convmul); 18991da177e4SLinus Torvalds len = strlen(buf); 19001da177e4SLinus Torvalds if (len > left) 19011da177e4SLinus Torvalds len = left; 19021da177e4SLinus Torvalds if(copy_to_user(s, buf, len)) 19031da177e4SLinus Torvalds return -EFAULT; 19041da177e4SLinus Torvalds left -= len; 19051da177e4SLinus Torvalds s += len; 19061da177e4SLinus Torvalds } 19071da177e4SLinus Torvalds } 19081da177e4SLinus Torvalds 19091da177e4SLinus Torvalds if (!write && !first && left) { 19101da177e4SLinus Torvalds if(put_user('\n', s)) 19111da177e4SLinus Torvalds return -EFAULT; 19121da177e4SLinus Torvalds left--, s++; 19131da177e4SLinus Torvalds } 19141da177e4SLinus Torvalds if (write) { 19151da177e4SLinus Torvalds while (left) { 19161da177e4SLinus Torvalds char c; 19171da177e4SLinus Torvalds if (get_user(c, s++)) 19181da177e4SLinus Torvalds return -EFAULT; 19191da177e4SLinus Torvalds if (!isspace(c)) 19201da177e4SLinus Torvalds break; 19211da177e4SLinus Torvalds left--; 19221da177e4SLinus Torvalds } 19231da177e4SLinus Torvalds } 19241da177e4SLinus Torvalds if (write && first) 19251da177e4SLinus Torvalds return -EINVAL; 19261da177e4SLinus Torvalds *lenp -= left; 19271da177e4SLinus Torvalds *ppos += *lenp; 19281da177e4SLinus Torvalds return 0; 19291da177e4SLinus Torvalds #undef TMPBUFLEN 19301da177e4SLinus Torvalds } 19311da177e4SLinus Torvalds 19321da177e4SLinus Torvalds /** 19331da177e4SLinus Torvalds * proc_doulongvec_minmax - read a vector of long integers with min/max values 19341da177e4SLinus Torvalds * @table: the sysctl table 19351da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 19361da177e4SLinus Torvalds * @filp: the file structure 19371da177e4SLinus Torvalds * @buffer: the user buffer 19381da177e4SLinus Torvalds * @lenp: the size of the user buffer 19391da177e4SLinus Torvalds * @ppos: file position 19401da177e4SLinus Torvalds * 19411da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 19421da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 19431da177e4SLinus Torvalds * 19441da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 19451da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 19461da177e4SLinus Torvalds * 19471da177e4SLinus Torvalds * Returns 0 on success. 19481da177e4SLinus Torvalds */ 19491da177e4SLinus Torvalds int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, 19501da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 19511da177e4SLinus Torvalds { 19521da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l); 19531da177e4SLinus Torvalds } 19541da177e4SLinus Torvalds 19551da177e4SLinus Torvalds /** 19561da177e4SLinus Torvalds * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 19571da177e4SLinus Torvalds * @table: the sysctl table 19581da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 19591da177e4SLinus Torvalds * @filp: the file structure 19601da177e4SLinus Torvalds * @buffer: the user buffer 19611da177e4SLinus Torvalds * @lenp: the size of the user buffer 19621da177e4SLinus Torvalds * @ppos: file position 19631da177e4SLinus Torvalds * 19641da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 19651da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. The values 19661da177e4SLinus Torvalds * are treated as milliseconds, and converted to jiffies when they are stored. 19671da177e4SLinus Torvalds * 19681da177e4SLinus Torvalds * This routine will ensure the values are within the range specified by 19691da177e4SLinus Torvalds * table->extra1 (min) and table->extra2 (max). 19701da177e4SLinus Torvalds * 19711da177e4SLinus Torvalds * Returns 0 on success. 19721da177e4SLinus Torvalds */ 19731da177e4SLinus Torvalds int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, 19741da177e4SLinus Torvalds struct file *filp, 19751da177e4SLinus Torvalds void __user *buffer, 19761da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 19771da177e4SLinus Torvalds { 19781da177e4SLinus Torvalds return do_proc_doulongvec_minmax(table, write, filp, buffer, 19791da177e4SLinus Torvalds lenp, ppos, HZ, 1000l); 19801da177e4SLinus Torvalds } 19811da177e4SLinus Torvalds 19821da177e4SLinus Torvalds 19831da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp, 19841da177e4SLinus Torvalds int *valp, 19851da177e4SLinus Torvalds int write, void *data) 19861da177e4SLinus Torvalds { 19871da177e4SLinus Torvalds if (write) { 19881da177e4SLinus Torvalds *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ); 19891da177e4SLinus Torvalds } else { 19901da177e4SLinus Torvalds int val = *valp; 19911da177e4SLinus Torvalds unsigned long lval; 19921da177e4SLinus Torvalds if (val < 0) { 19931da177e4SLinus Torvalds *negp = -1; 19941da177e4SLinus Torvalds lval = (unsigned long)-val; 19951da177e4SLinus Torvalds } else { 19961da177e4SLinus Torvalds *negp = 0; 19971da177e4SLinus Torvalds lval = (unsigned long)val; 19981da177e4SLinus Torvalds } 19991da177e4SLinus Torvalds *lvalp = lval / HZ; 20001da177e4SLinus Torvalds } 20011da177e4SLinus Torvalds return 0; 20021da177e4SLinus Torvalds } 20031da177e4SLinus Torvalds 20041da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp, 20051da177e4SLinus Torvalds int *valp, 20061da177e4SLinus Torvalds int write, void *data) 20071da177e4SLinus Torvalds { 20081da177e4SLinus Torvalds if (write) { 20091da177e4SLinus Torvalds *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); 20101da177e4SLinus Torvalds } else { 20111da177e4SLinus Torvalds int val = *valp; 20121da177e4SLinus Torvalds unsigned long lval; 20131da177e4SLinus Torvalds if (val < 0) { 20141da177e4SLinus Torvalds *negp = -1; 20151da177e4SLinus Torvalds lval = (unsigned long)-val; 20161da177e4SLinus Torvalds } else { 20171da177e4SLinus Torvalds *negp = 0; 20181da177e4SLinus Torvalds lval = (unsigned long)val; 20191da177e4SLinus Torvalds } 20201da177e4SLinus Torvalds *lvalp = jiffies_to_clock_t(lval); 20211da177e4SLinus Torvalds } 20221da177e4SLinus Torvalds return 0; 20231da177e4SLinus Torvalds } 20241da177e4SLinus Torvalds 20251da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, 20261da177e4SLinus Torvalds int *valp, 20271da177e4SLinus Torvalds int write, void *data) 20281da177e4SLinus Torvalds { 20291da177e4SLinus Torvalds if (write) { 20301da177e4SLinus Torvalds *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); 20311da177e4SLinus Torvalds } else { 20321da177e4SLinus Torvalds int val = *valp; 20331da177e4SLinus Torvalds unsigned long lval; 20341da177e4SLinus Torvalds if (val < 0) { 20351da177e4SLinus Torvalds *negp = -1; 20361da177e4SLinus Torvalds lval = (unsigned long)-val; 20371da177e4SLinus Torvalds } else { 20381da177e4SLinus Torvalds *negp = 0; 20391da177e4SLinus Torvalds lval = (unsigned long)val; 20401da177e4SLinus Torvalds } 20411da177e4SLinus Torvalds *lvalp = jiffies_to_msecs(lval); 20421da177e4SLinus Torvalds } 20431da177e4SLinus Torvalds return 0; 20441da177e4SLinus Torvalds } 20451da177e4SLinus Torvalds 20461da177e4SLinus Torvalds /** 20471da177e4SLinus Torvalds * proc_dointvec_jiffies - read a vector of integers as seconds 20481da177e4SLinus Torvalds * @table: the sysctl table 20491da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20501da177e4SLinus Torvalds * @filp: the file structure 20511da177e4SLinus Torvalds * @buffer: the user buffer 20521da177e4SLinus Torvalds * @lenp: the size of the user buffer 20531da177e4SLinus Torvalds * @ppos: file position 20541da177e4SLinus Torvalds * 20551da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 20561da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 20571da177e4SLinus Torvalds * The values read are assumed to be in seconds, and are converted into 20581da177e4SLinus Torvalds * jiffies. 20591da177e4SLinus Torvalds * 20601da177e4SLinus Torvalds * Returns 0 on success. 20611da177e4SLinus Torvalds */ 20621da177e4SLinus Torvalds int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp, 20631da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20641da177e4SLinus Torvalds { 20651da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 20661da177e4SLinus Torvalds do_proc_dointvec_jiffies_conv,NULL); 20671da177e4SLinus Torvalds } 20681da177e4SLinus Torvalds 20691da177e4SLinus Torvalds /** 20701da177e4SLinus Torvalds * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds 20711da177e4SLinus Torvalds * @table: the sysctl table 20721da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20731da177e4SLinus Torvalds * @filp: the file structure 20741da177e4SLinus Torvalds * @buffer: the user buffer 20751da177e4SLinus Torvalds * @lenp: the size of the user buffer 20761e5d5331SRandy Dunlap * @ppos: pointer to the file position 20771da177e4SLinus Torvalds * 20781da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 20791da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 20801da177e4SLinus Torvalds * The values read are assumed to be in 1/USER_HZ seconds, and 20811da177e4SLinus Torvalds * are converted into jiffies. 20821da177e4SLinus Torvalds * 20831da177e4SLinus Torvalds * Returns 0 on success. 20841da177e4SLinus Torvalds */ 20851da177e4SLinus Torvalds int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp, 20861da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 20871da177e4SLinus Torvalds { 20881da177e4SLinus Torvalds return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 20891da177e4SLinus Torvalds do_proc_dointvec_userhz_jiffies_conv,NULL); 20901da177e4SLinus Torvalds } 20911da177e4SLinus Torvalds 20921da177e4SLinus Torvalds /** 20931da177e4SLinus Torvalds * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds 20941da177e4SLinus Torvalds * @table: the sysctl table 20951da177e4SLinus Torvalds * @write: %TRUE if this is a write to the sysctl file 20961da177e4SLinus Torvalds * @filp: the file structure 20971da177e4SLinus Torvalds * @buffer: the user buffer 20981da177e4SLinus Torvalds * @lenp: the size of the user buffer 209967be2dd1SMartin Waitz * @ppos: file position 210067be2dd1SMartin Waitz * @ppos: the current position in the file 21011da177e4SLinus Torvalds * 21021da177e4SLinus Torvalds * Reads/writes up to table->maxlen/sizeof(unsigned int) integer 21031da177e4SLinus Torvalds * values from/to the user buffer, treated as an ASCII string. 21041da177e4SLinus Torvalds * The values read are assumed to be in 1/1000 seconds, and 21051da177e4SLinus Torvalds * are converted into jiffies. 21061da177e4SLinus Torvalds * 21071da177e4SLinus Torvalds * Returns 0 on success. 21081da177e4SLinus Torvalds */ 21091da177e4SLinus Torvalds int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, 21101da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21111da177e4SLinus Torvalds { 21121da177e4SLinus Torvalds return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 21131da177e4SLinus Torvalds do_proc_dointvec_ms_jiffies_conv, NULL); 21141da177e4SLinus Torvalds } 21151da177e4SLinus Torvalds 21161da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */ 21171da177e4SLinus Torvalds 21181da177e4SLinus Torvalds int proc_dostring(ctl_table *table, int write, struct file *filp, 21191da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21201da177e4SLinus Torvalds { 21211da177e4SLinus Torvalds return -ENOSYS; 21221da177e4SLinus Torvalds } 21231da177e4SLinus Torvalds 21241da177e4SLinus Torvalds static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 21251da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21261da177e4SLinus Torvalds { 21271da177e4SLinus Torvalds return -ENOSYS; 21281da177e4SLinus Torvalds } 21291da177e4SLinus Torvalds 21301da177e4SLinus Torvalds int proc_dointvec(ctl_table *table, int write, struct file *filp, 21311da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21321da177e4SLinus Torvalds { 21331da177e4SLinus Torvalds return -ENOSYS; 21341da177e4SLinus Torvalds } 21351da177e4SLinus Torvalds 21361da177e4SLinus Torvalds int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, 21371da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21381da177e4SLinus Torvalds { 21391da177e4SLinus Torvalds return -ENOSYS; 21401da177e4SLinus Torvalds } 21411da177e4SLinus Torvalds 21421da177e4SLinus Torvalds int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, 21431da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21441da177e4SLinus Torvalds { 21451da177e4SLinus Torvalds return -ENOSYS; 21461da177e4SLinus Torvalds } 21471da177e4SLinus Torvalds 21481da177e4SLinus Torvalds int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp, 21491da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21501da177e4SLinus Torvalds { 21511da177e4SLinus Torvalds return -ENOSYS; 21521da177e4SLinus Torvalds } 21531da177e4SLinus Torvalds 21541da177e4SLinus Torvalds int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp, 21551da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21561da177e4SLinus Torvalds { 21571da177e4SLinus Torvalds return -ENOSYS; 21581da177e4SLinus Torvalds } 21591da177e4SLinus Torvalds 21601da177e4SLinus Torvalds int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, 21611da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21621da177e4SLinus Torvalds { 21631da177e4SLinus Torvalds return -ENOSYS; 21641da177e4SLinus Torvalds } 21651da177e4SLinus Torvalds 21661da177e4SLinus Torvalds int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, 21671da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 21681da177e4SLinus Torvalds { 21691da177e4SLinus Torvalds return -ENOSYS; 21701da177e4SLinus Torvalds } 21711da177e4SLinus Torvalds 21721da177e4SLinus Torvalds int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, 21731da177e4SLinus Torvalds struct file *filp, 21741da177e4SLinus Torvalds void __user *buffer, 21751da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 21761da177e4SLinus Torvalds { 21771da177e4SLinus Torvalds return -ENOSYS; 21781da177e4SLinus Torvalds } 21791da177e4SLinus Torvalds 21801da177e4SLinus Torvalds 21811da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */ 21821da177e4SLinus Torvalds 21831da177e4SLinus Torvalds 21841da177e4SLinus Torvalds /* 21851da177e4SLinus Torvalds * General sysctl support routines 21861da177e4SLinus Torvalds */ 21871da177e4SLinus Torvalds 21881da177e4SLinus Torvalds /* The generic string strategy routine: */ 21891da177e4SLinus Torvalds int sysctl_string(ctl_table *table, int __user *name, int nlen, 21901da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 21911da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 21921da177e4SLinus Torvalds { 21931da177e4SLinus Torvalds if (!table->data || !table->maxlen) 21941da177e4SLinus Torvalds return -ENOTDIR; 21951da177e4SLinus Torvalds 21961da177e4SLinus Torvalds if (oldval && oldlenp) { 2197de9e007dSLinus Torvalds size_t bufsize; 2198de9e007dSLinus Torvalds if (get_user(bufsize, oldlenp)) 21991da177e4SLinus Torvalds return -EFAULT; 2200de9e007dSLinus Torvalds if (bufsize) { 2201de9e007dSLinus Torvalds size_t len = strlen(table->data), copied; 2202de9e007dSLinus Torvalds 2203de9e007dSLinus Torvalds /* This shouldn't trigger for a well-formed sysctl */ 2204de9e007dSLinus Torvalds if (len > table->maxlen) 22051da177e4SLinus Torvalds len = table->maxlen; 2206de9e007dSLinus Torvalds 2207de9e007dSLinus Torvalds /* Copy up to a max of bufsize-1 bytes of the string */ 2208de9e007dSLinus Torvalds copied = (len >= bufsize) ? bufsize - 1 : len; 2209de9e007dSLinus Torvalds 2210de9e007dSLinus Torvalds if (copy_to_user(oldval, table->data, copied) || 2211de9e007dSLinus Torvalds put_user(0, (char __user *)(oldval + copied))) 22121da177e4SLinus Torvalds return -EFAULT; 22131da177e4SLinus Torvalds if (put_user(len, oldlenp)) 22141da177e4SLinus Torvalds return -EFAULT; 22151da177e4SLinus Torvalds } 22161da177e4SLinus Torvalds } 22171da177e4SLinus Torvalds if (newval && newlen) { 2218de9e007dSLinus Torvalds size_t len = newlen; 22191da177e4SLinus Torvalds if (len > table->maxlen) 22201da177e4SLinus Torvalds len = table->maxlen; 22211da177e4SLinus Torvalds if(copy_from_user(table->data, newval, len)) 22221da177e4SLinus Torvalds return -EFAULT; 22231da177e4SLinus Torvalds if (len == table->maxlen) 22241da177e4SLinus Torvalds len--; 22251da177e4SLinus Torvalds ((char *) table->data)[len] = 0; 22261da177e4SLinus Torvalds } 222782c9df82SYi Yang return 1; 22281da177e4SLinus Torvalds } 22291da177e4SLinus Torvalds 22301da177e4SLinus Torvalds /* 22311da177e4SLinus Torvalds * This function makes sure that all of the integers in the vector 22321da177e4SLinus Torvalds * are between the minimum and maximum values given in the arrays 22331da177e4SLinus Torvalds * table->extra1 and table->extra2, respectively. 22341da177e4SLinus Torvalds */ 22351da177e4SLinus Torvalds int sysctl_intvec(ctl_table *table, int __user *name, int nlen, 22361da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 22371da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 22381da177e4SLinus Torvalds { 22391da177e4SLinus Torvalds 22401da177e4SLinus Torvalds if (newval && newlen) { 22411da177e4SLinus Torvalds int __user *vec = (int __user *) newval; 22421da177e4SLinus Torvalds int *min = (int *) table->extra1; 22431da177e4SLinus Torvalds int *max = (int *) table->extra2; 22441da177e4SLinus Torvalds size_t length; 22451da177e4SLinus Torvalds int i; 22461da177e4SLinus Torvalds 22471da177e4SLinus Torvalds if (newlen % sizeof(int) != 0) 22481da177e4SLinus Torvalds return -EINVAL; 22491da177e4SLinus Torvalds 22501da177e4SLinus Torvalds if (!table->extra1 && !table->extra2) 22511da177e4SLinus Torvalds return 0; 22521da177e4SLinus Torvalds 22531da177e4SLinus Torvalds if (newlen > table->maxlen) 22541da177e4SLinus Torvalds newlen = table->maxlen; 22551da177e4SLinus Torvalds length = newlen / sizeof(int); 22561da177e4SLinus Torvalds 22571da177e4SLinus Torvalds for (i = 0; i < length; i++) { 22581da177e4SLinus Torvalds int value; 22591da177e4SLinus Torvalds if (get_user(value, vec + i)) 22601da177e4SLinus Torvalds return -EFAULT; 22611da177e4SLinus Torvalds if (min && value < min[i]) 22621da177e4SLinus Torvalds return -EINVAL; 22631da177e4SLinus Torvalds if (max && value > max[i]) 22641da177e4SLinus Torvalds return -EINVAL; 22651da177e4SLinus Torvalds } 22661da177e4SLinus Torvalds } 22671da177e4SLinus Torvalds return 0; 22681da177e4SLinus Torvalds } 22691da177e4SLinus Torvalds 22701da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 22711da177e4SLinus Torvalds int sysctl_jiffies(ctl_table *table, int __user *name, int nlen, 22721da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 22731da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 22741da177e4SLinus Torvalds { 22751da177e4SLinus Torvalds if (oldval) { 22761da177e4SLinus Torvalds size_t olen; 22771da177e4SLinus Torvalds if (oldlenp) { 22781da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 22791da177e4SLinus Torvalds return -EFAULT; 22801da177e4SLinus Torvalds if (olen!=sizeof(int)) 22811da177e4SLinus Torvalds return -EINVAL; 22821da177e4SLinus Torvalds } 22831da177e4SLinus Torvalds if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) || 22841da177e4SLinus Torvalds (oldlenp && put_user(sizeof(int),oldlenp))) 22851da177e4SLinus Torvalds return -EFAULT; 22861da177e4SLinus Torvalds } 22871da177e4SLinus Torvalds if (newval && newlen) { 22881da177e4SLinus Torvalds int new; 22891da177e4SLinus Torvalds if (newlen != sizeof(int)) 22901da177e4SLinus Torvalds return -EINVAL; 22911da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 22921da177e4SLinus Torvalds return -EFAULT; 22931da177e4SLinus Torvalds *(int *)(table->data) = new*HZ; 22941da177e4SLinus Torvalds } 22951da177e4SLinus Torvalds return 1; 22961da177e4SLinus Torvalds } 22971da177e4SLinus Torvalds 22981da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */ 22991da177e4SLinus Torvalds int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, 23001da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 23011da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 23021da177e4SLinus Torvalds { 23031da177e4SLinus Torvalds if (oldval) { 23041da177e4SLinus Torvalds size_t olen; 23051da177e4SLinus Torvalds if (oldlenp) { 23061da177e4SLinus Torvalds if (get_user(olen, oldlenp)) 23071da177e4SLinus Torvalds return -EFAULT; 23081da177e4SLinus Torvalds if (olen!=sizeof(int)) 23091da177e4SLinus Torvalds return -EINVAL; 23101da177e4SLinus Torvalds } 23111da177e4SLinus Torvalds if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) || 23121da177e4SLinus Torvalds (oldlenp && put_user(sizeof(int),oldlenp))) 23131da177e4SLinus Torvalds return -EFAULT; 23141da177e4SLinus Torvalds } 23151da177e4SLinus Torvalds if (newval && newlen) { 23161da177e4SLinus Torvalds int new; 23171da177e4SLinus Torvalds if (newlen != sizeof(int)) 23181da177e4SLinus Torvalds return -EINVAL; 23191da177e4SLinus Torvalds if (get_user(new, (int __user *)newval)) 23201da177e4SLinus Torvalds return -EFAULT; 23211da177e4SLinus Torvalds *(int *)(table->data) = msecs_to_jiffies(new); 23221da177e4SLinus Torvalds } 23231da177e4SLinus Torvalds return 1; 23241da177e4SLinus Torvalds } 23251da177e4SLinus Torvalds 23261da177e4SLinus Torvalds #else /* CONFIG_SYSCTL */ 23271da177e4SLinus Torvalds 23281da177e4SLinus Torvalds 23291da177e4SLinus Torvalds asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 23301da177e4SLinus Torvalds { 23311da177e4SLinus Torvalds return -ENOSYS; 23321da177e4SLinus Torvalds } 23331da177e4SLinus Torvalds 23341da177e4SLinus Torvalds int sysctl_string(ctl_table *table, int __user *name, int nlen, 23351da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 23361da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 23371da177e4SLinus Torvalds { 23381da177e4SLinus Torvalds return -ENOSYS; 23391da177e4SLinus Torvalds } 23401da177e4SLinus Torvalds 23411da177e4SLinus Torvalds int sysctl_intvec(ctl_table *table, int __user *name, int nlen, 23421da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 23431da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 23441da177e4SLinus Torvalds { 23451da177e4SLinus Torvalds return -ENOSYS; 23461da177e4SLinus Torvalds } 23471da177e4SLinus Torvalds 23481da177e4SLinus Torvalds int sysctl_jiffies(ctl_table *table, int __user *name, int nlen, 23491da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 23501da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 23511da177e4SLinus Torvalds { 23521da177e4SLinus Torvalds return -ENOSYS; 23531da177e4SLinus Torvalds } 23541da177e4SLinus Torvalds 23551da177e4SLinus Torvalds int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, 23561da177e4SLinus Torvalds void __user *oldval, size_t __user *oldlenp, 23571da177e4SLinus Torvalds void __user *newval, size_t newlen, void **context) 23581da177e4SLinus Torvalds { 23591da177e4SLinus Torvalds return -ENOSYS; 23601da177e4SLinus Torvalds } 23611da177e4SLinus Torvalds 23621da177e4SLinus Torvalds int proc_dostring(ctl_table *table, int write, struct file *filp, 23631da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23641da177e4SLinus Torvalds { 23651da177e4SLinus Torvalds return -ENOSYS; 23661da177e4SLinus Torvalds } 23671da177e4SLinus Torvalds 23681da177e4SLinus Torvalds int proc_dointvec(ctl_table *table, int write, struct file *filp, 23691da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23701da177e4SLinus Torvalds { 23711da177e4SLinus Torvalds return -ENOSYS; 23721da177e4SLinus Torvalds } 23731da177e4SLinus Torvalds 23741da177e4SLinus Torvalds int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, 23751da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23761da177e4SLinus Torvalds { 23771da177e4SLinus Torvalds return -ENOSYS; 23781da177e4SLinus Torvalds } 23791da177e4SLinus Torvalds 23801da177e4SLinus Torvalds int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, 23811da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23821da177e4SLinus Torvalds { 23831da177e4SLinus Torvalds return -ENOSYS; 23841da177e4SLinus Torvalds } 23851da177e4SLinus Torvalds 23861da177e4SLinus Torvalds int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp, 23871da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23881da177e4SLinus Torvalds { 23891da177e4SLinus Torvalds return -ENOSYS; 23901da177e4SLinus Torvalds } 23911da177e4SLinus Torvalds 23921da177e4SLinus Torvalds int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp, 23931da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 23941da177e4SLinus Torvalds { 23951da177e4SLinus Torvalds return -ENOSYS; 23961da177e4SLinus Torvalds } 23971da177e4SLinus Torvalds 23981da177e4SLinus Torvalds int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, 23991da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24001da177e4SLinus Torvalds { 24011da177e4SLinus Torvalds return -ENOSYS; 24021da177e4SLinus Torvalds } 24031da177e4SLinus Torvalds 24041da177e4SLinus Torvalds int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, 24051da177e4SLinus Torvalds void __user *buffer, size_t *lenp, loff_t *ppos) 24061da177e4SLinus Torvalds { 24071da177e4SLinus Torvalds return -ENOSYS; 24081da177e4SLinus Torvalds } 24091da177e4SLinus Torvalds 24101da177e4SLinus Torvalds int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, 24111da177e4SLinus Torvalds struct file *filp, 24121da177e4SLinus Torvalds void __user *buffer, 24131da177e4SLinus Torvalds size_t *lenp, loff_t *ppos) 24141da177e4SLinus Torvalds { 24151da177e4SLinus Torvalds return -ENOSYS; 24161da177e4SLinus Torvalds } 24171da177e4SLinus Torvalds 24181da177e4SLinus Torvalds struct ctl_table_header * register_sysctl_table(ctl_table * table, 24191da177e4SLinus Torvalds int insert_at_head) 24201da177e4SLinus Torvalds { 24211da177e4SLinus Torvalds return NULL; 24221da177e4SLinus Torvalds } 24231da177e4SLinus Torvalds 24241da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * table) 24251da177e4SLinus Torvalds { 24261da177e4SLinus Torvalds } 24271da177e4SLinus Torvalds 24281da177e4SLinus Torvalds #endif /* CONFIG_SYSCTL */ 24291da177e4SLinus Torvalds 24301da177e4SLinus Torvalds /* 24311da177e4SLinus Torvalds * No sense putting this after each symbol definition, twice, 24321da177e4SLinus Torvalds * exception granted :-) 24331da177e4SLinus Torvalds */ 24341da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec); 24351da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies); 24361da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax); 24371da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies); 24381da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 24391da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring); 24401da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax); 24411da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 24421da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table); 24431da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec); 24441da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies); 24451da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies); 24461da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string); 24471da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table); 2448