2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/module.h>
23 #include <linux/swap.h>
24 #include <linux/slab.h>
25 #include <linux/sysctl.h>
26 #include <linux/proc_fs.h>
27 #include <linux/capability.h>
28 #include <linux/ctype.h>
29 #include <linux/utsname.h>
30 #include <linux/capability.h>
31 #include <linux/smp_lock.h>
32 #include <linux/init.h>
33 #include <linux/kernel.h>
34 #include <linux/kobject.h>
35 #include <linux/net.h>
36 #include <linux/sysrq.h>
37 #include <linux/highuid.h>
38 #include <linux/writeback.h>
39 #include <linux/hugetlb.h>
40 #include <linux/security.h>
41 #include <linux/initrd.h>
42 #include <linux/times.h>
43 #include <linux/limits.h>
44 #include <linux/dcache.h>
45 #include <linux/syscalls.h>
46 #include <linux/nfs_fs.h>
47 #include <linux/acpi.h>
49 #include <asm/uaccess.h>
50 #include <asm/processor.h>
52 extern int proc_nr_files(ctl_table
*table
, int write
, struct file
*filp
,
53 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
57 #include <asm/stacktrace.h>
60 #if defined(CONFIG_SYSCTL)
62 /* External variables not in a header file. */
64 extern int sysctl_overcommit_memory
;
65 extern int sysctl_overcommit_ratio
;
66 extern int sysctl_panic_on_oom
;
67 extern int max_threads
;
68 extern int core_uses_pid
;
69 extern int suid_dumpable
;
70 extern char core_pattern
[];
72 extern int min_free_kbytes
;
73 extern int printk_ratelimit_jiffies
;
74 extern int printk_ratelimit_burst
;
75 extern int pid_max_min
, pid_max_max
;
76 extern int sysctl_drop_caches
;
77 extern int percpu_pagelist_fraction
;
78 extern int compat_log
;
80 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
81 static int maxolduid
= 65535;
83 static int min_percpu_pagelist_fract
= 8;
85 static int ngroups_max
= NGROUPS_MAX
;
88 extern char modprobe_path
[];
90 #ifdef CONFIG_CHR_DEV_SG
91 extern int sg_big_buff
;
94 static int proc_ipc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
95 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
96 static int proc_ipc_doulongvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
97 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
101 extern char reboot_command
[];
102 extern int stop_a_enabled
;
103 extern int scons_pwroff
;
107 extern int pwrsw_enabled
;
108 extern int unaligned_enabled
;
112 #ifdef CONFIG_MATHEMU
113 extern int sysctl_ieee_emulation_warnings
;
115 extern int sysctl_userprocess_debug
;
116 extern int spin_retry
;
119 extern int sysctl_hz_timer
;
121 #ifdef CONFIG_BSD_PROCESS_ACCT
122 extern int acct_parm
[];
126 extern int no_unaligned_warning
;
129 #ifdef CONFIG_RT_MUTEXES
130 extern int max_lock_depth
;
133 #ifdef CONFIG_SYSCTL_SYSCALL
134 static int parse_table(int __user
*, int, void __user
*, size_t __user
*,
135 void __user
*, size_t, ctl_table
*);
138 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
139 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
141 static int sysctl_uts_string(ctl_table
*table
, int __user
*name
, int nlen
,
142 void __user
*oldval
, size_t __user
*oldlenp
,
143 void __user
*newval
, size_t newlen
);
145 #ifdef CONFIG_SYSVIPC
146 static int sysctl_ipc_data(ctl_table
*table
, int __user
*name
, int nlen
,
147 void __user
*oldval
, size_t __user
*oldlenp
,
148 void __user
*newval
, size_t newlen
);
151 #ifdef CONFIG_PROC_SYSCTL
152 static int proc_do_cad_pid(ctl_table
*table
, int write
, struct file
*filp
,
153 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
154 static int proc_dointvec_taint(ctl_table
*table
, int write
, struct file
*filp
,
155 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
158 static ctl_table root_table
[];
159 static struct ctl_table_header root_table_header
=
160 { root_table
, LIST_HEAD_INIT(root_table_header
.ctl_entry
) };
162 static ctl_table kern_table
[];
163 static ctl_table vm_table
[];
164 static ctl_table fs_table
[];
165 static ctl_table debug_table
[];
166 static ctl_table dev_table
[];
167 extern ctl_table random_table
[];
168 #ifdef CONFIG_UNIX98_PTYS
169 extern ctl_table pty_table
[];
171 #ifdef CONFIG_INOTIFY_USER
172 extern ctl_table inotify_table
[];
175 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
176 int sysctl_legacy_va_layout
;
180 static void *get_uts(ctl_table
*table
, int write
)
182 char *which
= table
->data
;
184 struct uts_namespace
*uts_ns
= current
->nsproxy
->uts_ns
;
185 which
= (which
- (char *)&init_uts_ns
) + (char *)uts_ns
;
190 down_write(&uts_sem
);
194 static void put_uts(ctl_table
*table
, int write
, void *which
)
202 #ifdef CONFIG_SYSVIPC
203 static void *get_ipc(ctl_table
*table
, int write
)
205 char *which
= table
->data
;
206 struct ipc_namespace
*ipc_ns
= current
->nsproxy
->ipc_ns
;
207 which
= (which
- (char *)&init_ipc_ns
) + (char *)ipc_ns
;
211 #define get_ipc(T,W) ((T)->data)
214 /* /proc declarations: */
216 #ifdef CONFIG_PROC_SYSCTL
218 static ssize_t
proc_readsys(struct file
*, char __user
*, size_t, loff_t
*);
219 static ssize_t
proc_writesys(struct file
*, const char __user
*, size_t, loff_t
*);
220 static int proc_opensys(struct inode
*, struct file
*);
222 const struct file_operations proc_sys_file_operations
= {
223 .open
= proc_opensys
,
224 .read
= proc_readsys
,
225 .write
= proc_writesys
,
228 extern struct proc_dir_entry
*proc_sys_root
;
230 static void register_proc_table(ctl_table
*, struct proc_dir_entry
*, void *);
231 static void unregister_proc_table(ctl_table
*, struct proc_dir_entry
*);
234 /* The default sysctl tables: */
236 static ctl_table root_table
[] = {
238 .ctl_name
= CTL_KERN
,
239 .procname
= "kernel",
264 .ctl_name
= CTL_DEBUG
,
267 .child
= debug_table
,
279 static ctl_table kern_table
[] = {
281 .ctl_name
= KERN_OSTYPE
,
282 .procname
= "ostype",
283 .data
= init_uts_ns
.name
.sysname
,
284 .maxlen
= sizeof(init_uts_ns
.name
.sysname
),
286 .proc_handler
= &proc_do_uts_string
,
287 .strategy
= &sysctl_uts_string
,
290 .ctl_name
= KERN_OSRELEASE
,
291 .procname
= "osrelease",
292 .data
= init_uts_ns
.name
.release
,
293 .maxlen
= sizeof(init_uts_ns
.name
.release
),
295 .proc_handler
= &proc_do_uts_string
,
296 .strategy
= &sysctl_uts_string
,
299 .ctl_name
= KERN_VERSION
,
300 .procname
= "version",
301 .data
= init_uts_ns
.name
.version
,
302 .maxlen
= sizeof(init_uts_ns
.name
.version
),
304 .proc_handler
= &proc_do_uts_string
,
305 .strategy
= &sysctl_uts_string
,
308 .ctl_name
= KERN_NODENAME
,
309 .procname
= "hostname",
310 .data
= init_uts_ns
.name
.nodename
,
311 .maxlen
= sizeof(init_uts_ns
.name
.nodename
),
313 .proc_handler
= &proc_do_uts_string
,
314 .strategy
= &sysctl_uts_string
,
317 .ctl_name
= KERN_DOMAINNAME
,
318 .procname
= "domainname",
319 .data
= init_uts_ns
.name
.domainname
,
320 .maxlen
= sizeof(init_uts_ns
.name
.domainname
),
322 .proc_handler
= &proc_do_uts_string
,
323 .strategy
= &sysctl_uts_string
,
326 .ctl_name
= KERN_PANIC
,
328 .data
= &panic_timeout
,
329 .maxlen
= sizeof(int),
331 .proc_handler
= &proc_dointvec
,
334 .ctl_name
= KERN_CORE_USES_PID
,
335 .procname
= "core_uses_pid",
336 .data
= &core_uses_pid
,
337 .maxlen
= sizeof(int),
339 .proc_handler
= &proc_dointvec
,
342 .ctl_name
= KERN_CORE_PATTERN
,
343 .procname
= "core_pattern",
344 .data
= core_pattern
,
347 .proc_handler
= &proc_dostring
,
348 .strategy
= &sysctl_string
,
350 #ifdef CONFIG_PROC_SYSCTL
352 .ctl_name
= KERN_TAINTED
,
353 .procname
= "tainted",
355 .maxlen
= sizeof(int),
357 .proc_handler
= &proc_dointvec_taint
,
361 .ctl_name
= KERN_CAP_BSET
,
362 .procname
= "cap-bound",
364 .maxlen
= sizeof(kernel_cap_t
),
366 .proc_handler
= &proc_dointvec_bset
,
368 #ifdef CONFIG_BLK_DEV_INITRD
370 .ctl_name
= KERN_REALROOTDEV
,
371 .procname
= "real-root-dev",
372 .data
= &real_root_dev
,
373 .maxlen
= sizeof(int),
375 .proc_handler
= &proc_dointvec
,
380 .ctl_name
= KERN_SPARC_REBOOT
,
381 .procname
= "reboot-cmd",
382 .data
= reboot_command
,
385 .proc_handler
= &proc_dostring
,
386 .strategy
= &sysctl_string
,
389 .ctl_name
= KERN_SPARC_STOP_A
,
390 .procname
= "stop-a",
391 .data
= &stop_a_enabled
,
392 .maxlen
= sizeof (int),
394 .proc_handler
= &proc_dointvec
,
397 .ctl_name
= KERN_SPARC_SCONS_PWROFF
,
398 .procname
= "scons-poweroff",
399 .data
= &scons_pwroff
,
400 .maxlen
= sizeof (int),
402 .proc_handler
= &proc_dointvec
,
407 .ctl_name
= KERN_HPPA_PWRSW
,
408 .procname
= "soft-power",
409 .data
= &pwrsw_enabled
,
410 .maxlen
= sizeof (int),
412 .proc_handler
= &proc_dointvec
,
415 .ctl_name
= KERN_HPPA_UNALIGNED
,
416 .procname
= "unaligned-trap",
417 .data
= &unaligned_enabled
,
418 .maxlen
= sizeof (int),
420 .proc_handler
= &proc_dointvec
,
424 .ctl_name
= KERN_CTLALTDEL
,
425 .procname
= "ctrl-alt-del",
427 .maxlen
= sizeof(int),
429 .proc_handler
= &proc_dointvec
,
432 .ctl_name
= KERN_PRINTK
,
433 .procname
= "printk",
434 .data
= &console_loglevel
,
435 .maxlen
= 4*sizeof(int),
437 .proc_handler
= &proc_dointvec
,
441 .ctl_name
= KERN_MODPROBE
,
442 .procname
= "modprobe",
443 .data
= &modprobe_path
,
444 .maxlen
= KMOD_PATH_LEN
,
446 .proc_handler
= &proc_dostring
,
447 .strategy
= &sysctl_string
,
450 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
452 .ctl_name
= KERN_HOTPLUG
,
453 .procname
= "hotplug",
454 .data
= &uevent_helper
,
455 .maxlen
= UEVENT_HELPER_PATH_LEN
,
457 .proc_handler
= &proc_dostring
,
458 .strategy
= &sysctl_string
,
461 #ifdef CONFIG_CHR_DEV_SG
463 .ctl_name
= KERN_SG_BIG_BUFF
,
464 .procname
= "sg-big-buff",
465 .data
= &sg_big_buff
,
466 .maxlen
= sizeof (int),
468 .proc_handler
= &proc_dointvec
,
471 #ifdef CONFIG_BSD_PROCESS_ACCT
473 .ctl_name
= KERN_ACCT
,
476 .maxlen
= 3*sizeof(int),
478 .proc_handler
= &proc_dointvec
,
481 #ifdef CONFIG_SYSVIPC
483 .ctl_name
= KERN_SHMMAX
,
484 .procname
= "shmmax",
485 .data
= &init_ipc_ns
.shm_ctlmax
,
486 .maxlen
= sizeof (init_ipc_ns
.shm_ctlmax
),
488 .proc_handler
= &proc_ipc_doulongvec_minmax
,
489 .strategy
= sysctl_ipc_data
,
492 .ctl_name
= KERN_SHMALL
,
493 .procname
= "shmall",
494 .data
= &init_ipc_ns
.shm_ctlall
,
495 .maxlen
= sizeof (init_ipc_ns
.shm_ctlall
),
497 .proc_handler
= &proc_ipc_doulongvec_minmax
,
498 .strategy
= sysctl_ipc_data
,
501 .ctl_name
= KERN_SHMMNI
,
502 .procname
= "shmmni",
503 .data
= &init_ipc_ns
.shm_ctlmni
,
504 .maxlen
= sizeof (init_ipc_ns
.shm_ctlmni
),
506 .proc_handler
= &proc_ipc_dointvec
,
507 .strategy
= sysctl_ipc_data
,
510 .ctl_name
= KERN_MSGMAX
,
511 .procname
= "msgmax",
512 .data
= &init_ipc_ns
.msg_ctlmax
,
513 .maxlen
= sizeof (init_ipc_ns
.msg_ctlmax
),
515 .proc_handler
= &proc_ipc_dointvec
,
516 .strategy
= sysctl_ipc_data
,
519 .ctl_name
= KERN_MSGMNI
,
520 .procname
= "msgmni",
521 .data
= &init_ipc_ns
.msg_ctlmni
,
522 .maxlen
= sizeof (init_ipc_ns
.msg_ctlmni
),
524 .proc_handler
= &proc_ipc_dointvec
,
525 .strategy
= sysctl_ipc_data
,
528 .ctl_name
= KERN_MSGMNB
,
529 .procname
= "msgmnb",
530 .data
= &init_ipc_ns
.msg_ctlmnb
,
531 .maxlen
= sizeof (init_ipc_ns
.msg_ctlmnb
),
533 .proc_handler
= &proc_ipc_dointvec
,
534 .strategy
= sysctl_ipc_data
,
537 .ctl_name
= KERN_SEM
,
539 .data
= &init_ipc_ns
.sem_ctls
,
540 .maxlen
= 4*sizeof (int),
542 .proc_handler
= &proc_ipc_dointvec
,
543 .strategy
= sysctl_ipc_data
,
546 #ifdef CONFIG_MAGIC_SYSRQ
548 .ctl_name
= KERN_SYSRQ
,
550 .data
= &__sysrq_enabled
,
551 .maxlen
= sizeof (int),
553 .proc_handler
= &proc_dointvec
,
556 #ifdef CONFIG_PROC_SYSCTL
558 .ctl_name
= KERN_CADPID
,
559 .procname
= "cad_pid",
561 .maxlen
= sizeof (int),
563 .proc_handler
= &proc_do_cad_pid
,
567 .ctl_name
= KERN_MAX_THREADS
,
568 .procname
= "threads-max",
569 .data
= &max_threads
,
570 .maxlen
= sizeof(int),
572 .proc_handler
= &proc_dointvec
,
575 .ctl_name
= KERN_RANDOM
,
576 .procname
= "random",
578 .child
= random_table
,
580 #ifdef CONFIG_UNIX98_PTYS
582 .ctl_name
= KERN_PTY
,
589 .ctl_name
= KERN_OVERFLOWUID
,
590 .procname
= "overflowuid",
591 .data
= &overflowuid
,
592 .maxlen
= sizeof(int),
594 .proc_handler
= &proc_dointvec_minmax
,
595 .strategy
= &sysctl_intvec
,
596 .extra1
= &minolduid
,
597 .extra2
= &maxolduid
,
600 .ctl_name
= KERN_OVERFLOWGID
,
601 .procname
= "overflowgid",
602 .data
= &overflowgid
,
603 .maxlen
= sizeof(int),
605 .proc_handler
= &proc_dointvec_minmax
,
606 .strategy
= &sysctl_intvec
,
607 .extra1
= &minolduid
,
608 .extra2
= &maxolduid
,
611 #ifdef CONFIG_MATHEMU
613 .ctl_name
= KERN_IEEE_EMULATION_WARNINGS
,
614 .procname
= "ieee_emulation_warnings",
615 .data
= &sysctl_ieee_emulation_warnings
,
616 .maxlen
= sizeof(int),
618 .proc_handler
= &proc_dointvec
,
621 #ifdef CONFIG_NO_IDLE_HZ
623 .ctl_name
= KERN_HZ_TIMER
,
624 .procname
= "hz_timer",
625 .data
= &sysctl_hz_timer
,
626 .maxlen
= sizeof(int),
628 .proc_handler
= &proc_dointvec
,
632 .ctl_name
= KERN_S390_USER_DEBUG_LOGGING
,
633 .procname
= "userprocess_debug",
634 .data
= &sysctl_userprocess_debug
,
635 .maxlen
= sizeof(int),
637 .proc_handler
= &proc_dointvec
,
641 .ctl_name
= KERN_PIDMAX
,
642 .procname
= "pid_max",
644 .maxlen
= sizeof (int),
646 .proc_handler
= &proc_dointvec_minmax
,
647 .strategy
= sysctl_intvec
,
648 .extra1
= &pid_max_min
,
649 .extra2
= &pid_max_max
,
652 .ctl_name
= KERN_PANIC_ON_OOPS
,
653 .procname
= "panic_on_oops",
654 .data
= &panic_on_oops
,
655 .maxlen
= sizeof(int),
657 .proc_handler
= &proc_dointvec
,
660 .ctl_name
= KERN_PRINTK_RATELIMIT
,
661 .procname
= "printk_ratelimit",
662 .data
= &printk_ratelimit_jiffies
,
663 .maxlen
= sizeof(int),
665 .proc_handler
= &proc_dointvec_jiffies
,
666 .strategy
= &sysctl_jiffies
,
669 .ctl_name
= KERN_PRINTK_RATELIMIT_BURST
,
670 .procname
= "printk_ratelimit_burst",
671 .data
= &printk_ratelimit_burst
,
672 .maxlen
= sizeof(int),
674 .proc_handler
= &proc_dointvec
,
677 .ctl_name
= KERN_NGROUPS_MAX
,
678 .procname
= "ngroups_max",
679 .data
= &ngroups_max
,
680 .maxlen
= sizeof (int),
682 .proc_handler
= &proc_dointvec
,
684 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
686 .ctl_name
= KERN_UNKNOWN_NMI_PANIC
,
687 .procname
= "unknown_nmi_panic",
688 .data
= &unknown_nmi_panic
,
689 .maxlen
= sizeof (int),
691 .proc_handler
= &proc_dointvec
,
694 .ctl_name
= KERN_NMI_WATCHDOG
,
695 .procname
= "nmi_watchdog",
696 .data
= &nmi_watchdog_enabled
,
697 .maxlen
= sizeof (int),
699 .proc_handler
= &proc_nmi_enabled
,
702 #if defined(CONFIG_X86)
704 .ctl_name
= KERN_PANIC_ON_NMI
,
705 .procname
= "panic_on_unrecovered_nmi",
706 .data
= &panic_on_unrecovered_nmi
,
707 .maxlen
= sizeof(int),
709 .proc_handler
= &proc_dointvec
,
712 .ctl_name
= KERN_BOOTLOADER_TYPE
,
713 .procname
= "bootloader_type",
714 .data
= &bootloader_type
,
715 .maxlen
= sizeof (int),
717 .proc_handler
= &proc_dointvec
,
720 .ctl_name
= CTL_UNNUMBERED
,
721 .procname
= "kstack_depth_to_print",
722 .data
= &kstack_depth_to_print
,
723 .maxlen
= sizeof(int),
725 .proc_handler
= &proc_dointvec
,
728 #if defined(CONFIG_MMU)
730 .ctl_name
= KERN_RANDOMIZE
,
731 .procname
= "randomize_va_space",
732 .data
= &randomize_va_space
,
733 .maxlen
= sizeof(int),
735 .proc_handler
= &proc_dointvec
,
738 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
740 .ctl_name
= KERN_SPIN_RETRY
,
741 .procname
= "spin_retry",
743 .maxlen
= sizeof (int),
745 .proc_handler
= &proc_dointvec
,
748 #ifdef CONFIG_ACPI_SLEEP
750 .ctl_name
= KERN_ACPI_VIDEO_FLAGS
,
751 .procname
= "acpi_video_flags",
752 .data
= &acpi_video_flags
,
753 .maxlen
= sizeof (unsigned long),
755 .proc_handler
= &proc_doulongvec_minmax
,
760 .ctl_name
= KERN_IA64_UNALIGNED
,
761 .procname
= "ignore-unaligned-usertrap",
762 .data
= &no_unaligned_warning
,
763 .maxlen
= sizeof (int),
765 .proc_handler
= &proc_dointvec
,
770 .ctl_name
= KERN_COMPAT_LOG
,
771 .procname
= "compat-log",
773 .maxlen
= sizeof (int),
775 .proc_handler
= &proc_dointvec
,
778 #ifdef CONFIG_RT_MUTEXES
780 .ctl_name
= KERN_MAX_LOCK_DEPTH
,
781 .procname
= "max_lock_depth",
782 .data
= &max_lock_depth
,
783 .maxlen
= sizeof(int),
785 .proc_handler
= &proc_dointvec
,
792 /* Constants for minimum and maximum testing in vm_table.
793 We use these as one-element integer vectors. */
795 static int one_hundred
= 100;
798 static ctl_table vm_table
[] = {
800 .ctl_name
= VM_OVERCOMMIT_MEMORY
,
801 .procname
= "overcommit_memory",
802 .data
= &sysctl_overcommit_memory
,
803 .maxlen
= sizeof(sysctl_overcommit_memory
),
805 .proc_handler
= &proc_dointvec
,
808 .ctl_name
= VM_PANIC_ON_OOM
,
809 .procname
= "panic_on_oom",
810 .data
= &sysctl_panic_on_oom
,
811 .maxlen
= sizeof(sysctl_panic_on_oom
),
813 .proc_handler
= &proc_dointvec
,
816 .ctl_name
= VM_OVERCOMMIT_RATIO
,
817 .procname
= "overcommit_ratio",
818 .data
= &sysctl_overcommit_ratio
,
819 .maxlen
= sizeof(sysctl_overcommit_ratio
),
821 .proc_handler
= &proc_dointvec
,
824 .ctl_name
= VM_PAGE_CLUSTER
,
825 .procname
= "page-cluster",
826 .data
= &page_cluster
,
827 .maxlen
= sizeof(int),
829 .proc_handler
= &proc_dointvec
,
832 .ctl_name
= VM_DIRTY_BACKGROUND
,
833 .procname
= "dirty_background_ratio",
834 .data
= &dirty_background_ratio
,
835 .maxlen
= sizeof(dirty_background_ratio
),
837 .proc_handler
= &proc_dointvec_minmax
,
838 .strategy
= &sysctl_intvec
,
840 .extra2
= &one_hundred
,
843 .ctl_name
= VM_DIRTY_RATIO
,
844 .procname
= "dirty_ratio",
845 .data
= &vm_dirty_ratio
,
846 .maxlen
= sizeof(vm_dirty_ratio
),
848 .proc_handler
= &proc_dointvec_minmax
,
849 .strategy
= &sysctl_intvec
,
851 .extra2
= &one_hundred
,
854 .ctl_name
= VM_DIRTY_WB_CS
,
855 .procname
= "dirty_writeback_centisecs",
856 .data
= &dirty_writeback_interval
,
857 .maxlen
= sizeof(dirty_writeback_interval
),
859 .proc_handler
= &dirty_writeback_centisecs_handler
,
862 .ctl_name
= VM_DIRTY_EXPIRE_CS
,
863 .procname
= "dirty_expire_centisecs",
864 .data
= &dirty_expire_interval
,
865 .maxlen
= sizeof(dirty_expire_interval
),
867 .proc_handler
= &proc_dointvec_userhz_jiffies
,
870 .ctl_name
= VM_NR_PDFLUSH_THREADS
,
871 .procname
= "nr_pdflush_threads",
872 .data
= &nr_pdflush_threads
,
873 .maxlen
= sizeof nr_pdflush_threads
,
874 .mode
= 0444 /* read-only*/,
875 .proc_handler
= &proc_dointvec
,
878 .ctl_name
= VM_SWAPPINESS
,
879 .procname
= "swappiness",
880 .data
= &vm_swappiness
,
881 .maxlen
= sizeof(vm_swappiness
),
883 .proc_handler
= &proc_dointvec_minmax
,
884 .strategy
= &sysctl_intvec
,
886 .extra2
= &one_hundred
,
888 #ifdef CONFIG_HUGETLB_PAGE
890 .ctl_name
= VM_HUGETLB_PAGES
,
891 .procname
= "nr_hugepages",
892 .data
= &max_huge_pages
,
893 .maxlen
= sizeof(unsigned long),
895 .proc_handler
= &hugetlb_sysctl_handler
,
896 .extra1
= (void *)&hugetlb_zero
,
897 .extra2
= (void *)&hugetlb_infinity
,
900 .ctl_name
= VM_HUGETLB_GROUP
,
901 .procname
= "hugetlb_shm_group",
902 .data
= &sysctl_hugetlb_shm_group
,
903 .maxlen
= sizeof(gid_t
),
905 .proc_handler
= &proc_dointvec
,
909 .ctl_name
= VM_LOWMEM_RESERVE_RATIO
,
910 .procname
= "lowmem_reserve_ratio",
911 .data
= &sysctl_lowmem_reserve_ratio
,
912 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
914 .proc_handler
= &lowmem_reserve_ratio_sysctl_handler
,
915 .strategy
= &sysctl_intvec
,
918 .ctl_name
= VM_DROP_PAGECACHE
,
919 .procname
= "drop_caches",
920 .data
= &sysctl_drop_caches
,
921 .maxlen
= sizeof(int),
923 .proc_handler
= drop_caches_sysctl_handler
,
924 .strategy
= &sysctl_intvec
,
927 .ctl_name
= VM_MIN_FREE_KBYTES
,
928 .procname
= "min_free_kbytes",
929 .data
= &min_free_kbytes
,
930 .maxlen
= sizeof(min_free_kbytes
),
932 .proc_handler
= &min_free_kbytes_sysctl_handler
,
933 .strategy
= &sysctl_intvec
,
937 .ctl_name
= VM_PERCPU_PAGELIST_FRACTION
,
938 .procname
= "percpu_pagelist_fraction",
939 .data
= &percpu_pagelist_fraction
,
940 .maxlen
= sizeof(percpu_pagelist_fraction
),
942 .proc_handler
= &percpu_pagelist_fraction_sysctl_handler
,
943 .strategy
= &sysctl_intvec
,
944 .extra1
= &min_percpu_pagelist_fract
,
948 .ctl_name
= VM_MAX_MAP_COUNT
,
949 .procname
= "max_map_count",
950 .data
= &sysctl_max_map_count
,
951 .maxlen
= sizeof(sysctl_max_map_count
),
953 .proc_handler
= &proc_dointvec
957 .ctl_name
= VM_LAPTOP_MODE
,
958 .procname
= "laptop_mode",
959 .data
= &laptop_mode
,
960 .maxlen
= sizeof(laptop_mode
),
962 .proc_handler
= &proc_dointvec_jiffies
,
963 .strategy
= &sysctl_jiffies
,
966 .ctl_name
= VM_BLOCK_DUMP
,
967 .procname
= "block_dump",
969 .maxlen
= sizeof(block_dump
),
971 .proc_handler
= &proc_dointvec
,
972 .strategy
= &sysctl_intvec
,
976 .ctl_name
= VM_VFS_CACHE_PRESSURE
,
977 .procname
= "vfs_cache_pressure",
978 .data
= &sysctl_vfs_cache_pressure
,
979 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
981 .proc_handler
= &proc_dointvec
,
982 .strategy
= &sysctl_intvec
,
985 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
987 .ctl_name
= VM_LEGACY_VA_LAYOUT
,
988 .procname
= "legacy_va_layout",
989 .data
= &sysctl_legacy_va_layout
,
990 .maxlen
= sizeof(sysctl_legacy_va_layout
),
992 .proc_handler
= &proc_dointvec
,
993 .strategy
= &sysctl_intvec
,
999 .ctl_name
= VM_ZONE_RECLAIM_MODE
,
1000 .procname
= "zone_reclaim_mode",
1001 .data
= &zone_reclaim_mode
,
1002 .maxlen
= sizeof(zone_reclaim_mode
),
1004 .proc_handler
= &proc_dointvec
,
1005 .strategy
= &sysctl_intvec
,
1009 .ctl_name
= VM_MIN_UNMAPPED
,
1010 .procname
= "min_unmapped_ratio",
1011 .data
= &sysctl_min_unmapped_ratio
,
1012 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1014 .proc_handler
= &sysctl_min_unmapped_ratio_sysctl_handler
,
1015 .strategy
= &sysctl_intvec
,
1017 .extra2
= &one_hundred
,
1020 .ctl_name
= VM_MIN_SLAB
,
1021 .procname
= "min_slab_ratio",
1022 .data
= &sysctl_min_slab_ratio
,
1023 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1025 .proc_handler
= &sysctl_min_slab_ratio_sysctl_handler
,
1026 .strategy
= &sysctl_intvec
,
1028 .extra2
= &one_hundred
,
1031 #ifdef CONFIG_X86_32
1033 .ctl_name
= VM_VDSO_ENABLED
,
1034 .procname
= "vdso_enabled",
1035 .data
= &vdso_enabled
,
1036 .maxlen
= sizeof(vdso_enabled
),
1038 .proc_handler
= &proc_dointvec
,
1039 .strategy
= &sysctl_intvec
,
1046 static ctl_table fs_table
[] = {
1048 .ctl_name
= FS_NRINODE
,
1049 .procname
= "inode-nr",
1050 .data
= &inodes_stat
,
1051 .maxlen
= 2*sizeof(int),
1053 .proc_handler
= &proc_dointvec
,
1056 .ctl_name
= FS_STATINODE
,
1057 .procname
= "inode-state",
1058 .data
= &inodes_stat
,
1059 .maxlen
= 7*sizeof(int),
1061 .proc_handler
= &proc_dointvec
,
1064 .ctl_name
= FS_NRFILE
,
1065 .procname
= "file-nr",
1066 .data
= &files_stat
,
1067 .maxlen
= 3*sizeof(int),
1069 .proc_handler
= &proc_nr_files
,
1072 .ctl_name
= FS_MAXFILE
,
1073 .procname
= "file-max",
1074 .data
= &files_stat
.max_files
,
1075 .maxlen
= sizeof(int),
1077 .proc_handler
= &proc_dointvec
,
1080 .ctl_name
= FS_DENTRY
,
1081 .procname
= "dentry-state",
1082 .data
= &dentry_stat
,
1083 .maxlen
= 6*sizeof(int),
1085 .proc_handler
= &proc_dointvec
,
1088 .ctl_name
= FS_OVERFLOWUID
,
1089 .procname
= "overflowuid",
1090 .data
= &fs_overflowuid
,
1091 .maxlen
= sizeof(int),
1093 .proc_handler
= &proc_dointvec_minmax
,
1094 .strategy
= &sysctl_intvec
,
1095 .extra1
= &minolduid
,
1096 .extra2
= &maxolduid
,
1099 .ctl_name
= FS_OVERFLOWGID
,
1100 .procname
= "overflowgid",
1101 .data
= &fs_overflowgid
,
1102 .maxlen
= sizeof(int),
1104 .proc_handler
= &proc_dointvec_minmax
,
1105 .strategy
= &sysctl_intvec
,
1106 .extra1
= &minolduid
,
1107 .extra2
= &maxolduid
,
1110 .ctl_name
= FS_LEASES
,
1111 .procname
= "leases-enable",
1112 .data
= &leases_enable
,
1113 .maxlen
= sizeof(int),
1115 .proc_handler
= &proc_dointvec
,
1117 #ifdef CONFIG_DNOTIFY
1119 .ctl_name
= FS_DIR_NOTIFY
,
1120 .procname
= "dir-notify-enable",
1121 .data
= &dir_notify_enable
,
1122 .maxlen
= sizeof(int),
1124 .proc_handler
= &proc_dointvec
,
1129 .ctl_name
= FS_LEASE_TIME
,
1130 .procname
= "lease-break-time",
1131 .data
= &lease_break_time
,
1132 .maxlen
= sizeof(int),
1134 .proc_handler
= &proc_dointvec
,
1137 .ctl_name
= FS_AIO_NR
,
1138 .procname
= "aio-nr",
1140 .maxlen
= sizeof(aio_nr
),
1142 .proc_handler
= &proc_doulongvec_minmax
,
1145 .ctl_name
= FS_AIO_MAX_NR
,
1146 .procname
= "aio-max-nr",
1147 .data
= &aio_max_nr
,
1148 .maxlen
= sizeof(aio_max_nr
),
1150 .proc_handler
= &proc_doulongvec_minmax
,
1152 #ifdef CONFIG_INOTIFY_USER
1154 .ctl_name
= FS_INOTIFY
,
1155 .procname
= "inotify",
1157 .child
= inotify_table
,
1162 .ctl_name
= KERN_SETUID_DUMPABLE
,
1163 .procname
= "suid_dumpable",
1164 .data
= &suid_dumpable
,
1165 .maxlen
= sizeof(int),
1167 .proc_handler
= &proc_dointvec
,
1172 static ctl_table debug_table
[] = {
1176 static ctl_table dev_table
[] = {
1180 static DEFINE_SPINLOCK(sysctl_lock
);
1182 /* called under sysctl_lock */
1183 static int use_table(struct ctl_table_header
*p
)
1185 if (unlikely(p
->unregistering
))
1191 /* called under sysctl_lock */
1192 static void unuse_table(struct ctl_table_header
*p
)
1195 if (unlikely(p
->unregistering
))
1196 complete(p
->unregistering
);
1199 /* called under sysctl_lock, will reacquire if has to wait */
1200 static void start_unregistering(struct ctl_table_header
*p
)
1203 * if p->used is 0, nobody will ever touch that entry again;
1204 * we'll eliminate all paths to it before dropping sysctl_lock
1206 if (unlikely(p
->used
)) {
1207 struct completion wait
;
1208 init_completion(&wait
);
1209 p
->unregistering
= &wait
;
1210 spin_unlock(&sysctl_lock
);
1211 wait_for_completion(&wait
);
1212 spin_lock(&sysctl_lock
);
1215 * do not remove from the list until nobody holds it; walking the
1216 * list in do_sysctl() relies on that.
1218 list_del_init(&p
->ctl_entry
);
1221 void __init
sysctl_init(void)
1223 #ifdef CONFIG_PROC_SYSCTL
1224 register_proc_table(root_table
, proc_sys_root
, &root_table_header
);
1228 #ifdef CONFIG_SYSCTL_SYSCALL
1229 int do_sysctl(int __user
*name
, int nlen
, void __user
*oldval
, size_t __user
*oldlenp
,
1230 void __user
*newval
, size_t newlen
)
1232 struct list_head
*tmp
;
1233 int error
= -ENOTDIR
;
1235 if (nlen
<= 0 || nlen
>= CTL_MAXNAME
)
1239 if (!oldlenp
|| get_user(old_len
, oldlenp
))
1242 spin_lock(&sysctl_lock
);
1243 tmp
= &root_table_header
.ctl_entry
;
1245 struct ctl_table_header
*head
=
1246 list_entry(tmp
, struct ctl_table_header
, ctl_entry
);
1248 if (!use_table(head
))
1251 spin_unlock(&sysctl_lock
);
1253 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
1254 newval
, newlen
, head
->ctl_table
);
1256 spin_lock(&sysctl_lock
);
1258 if (error
!= -ENOTDIR
)
1260 } while ((tmp
= tmp
->next
) != &root_table_header
.ctl_entry
);
1261 spin_unlock(&sysctl_lock
);
1265 asmlinkage
long sys_sysctl(struct __sysctl_args __user
*args
)
1267 struct __sysctl_args tmp
;
1270 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
1274 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
1275 tmp
.newval
, tmp
.newlen
);
1279 #endif /* CONFIG_SYSCTL_SYSCALL */
1282 * ctl_perm does NOT grant the superuser all rights automatically, because
1283 * some sysctl variables are readonly even to root.
1286 static int test_perm(int mode
, int op
)
1290 else if (in_egroup_p(0))
1292 if ((mode
& op
& 0007) == op
)
1297 static inline int ctl_perm(ctl_table
*table
, int op
)
1300 error
= security_sysctl(table
, op
);
1303 return test_perm(table
->mode
, op
);
1306 #ifdef CONFIG_SYSCTL_SYSCALL
1307 static int parse_table(int __user
*name
, int nlen
,
1308 void __user
*oldval
, size_t __user
*oldlenp
,
1309 void __user
*newval
, size_t newlen
,
1316 if (get_user(n
, name
))
1318 for ( ; table
->ctl_name
|| table
->procname
; table
++) {
1319 if (!table
->ctl_name
)
1321 if (n
== table
->ctl_name
|| table
->ctl_name
== CTL_ANY
) {
1324 if (ctl_perm(table
, 001))
1326 if (table
->strategy
) {
1327 error
= table
->strategy(
1336 table
= table
->child
;
1339 error
= do_sysctl_strategy(table
, name
, nlen
,
1348 /* Perform the actual read/write of a sysctl table entry. */
1349 int do_sysctl_strategy (ctl_table
*table
,
1350 int __user
*name
, int nlen
,
1351 void __user
*oldval
, size_t __user
*oldlenp
,
1352 void __user
*newval
, size_t newlen
)
1361 if (ctl_perm(table
, op
))
1364 if (table
->strategy
) {
1365 rc
= table
->strategy(table
, name
, nlen
, oldval
, oldlenp
,
1373 /* If there is no strategy routine, or if the strategy returns
1374 * zero, proceed with automatic r/w */
1375 if (table
->data
&& table
->maxlen
) {
1376 if (oldval
&& oldlenp
) {
1377 if (get_user(len
, oldlenp
))
1380 if (len
> table
->maxlen
)
1381 len
= table
->maxlen
;
1382 if(copy_to_user(oldval
, table
->data
, len
))
1384 if(put_user(len
, oldlenp
))
1388 if (newval
&& newlen
) {
1390 if (len
> table
->maxlen
)
1391 len
= table
->maxlen
;
1392 if(copy_from_user(table
->data
, newval
, len
))
1398 #endif /* CONFIG_SYSCTL_SYSCALL */
1401 * register_sysctl_table - register a sysctl hierarchy
1402 * @table: the top-level table structure
1403 * @insert_at_head: whether the entry should be inserted in front or at the end
1405 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1406 * array. An entry with a ctl_name of 0 terminates the table.
1408 * The members of the &ctl_table structure are used as follows:
1410 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1411 * must be unique within that level of sysctl
1413 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1414 * enter a sysctl file
1416 * data - a pointer to data for use by proc_handler
1418 * maxlen - the maximum size in bytes of the data
1420 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1422 * child - a pointer to the child sysctl table if this entry is a directory, or
1425 * proc_handler - the text handler routine (described below)
1427 * strategy - the strategy routine (described below)
1429 * de - for internal use by the sysctl routines
1431 * extra1, extra2 - extra pointers usable by the proc handler routines
1433 * Leaf nodes in the sysctl tree will be represented by a single file
1434 * under /proc; non-leaf nodes will be represented by directories.
1436 * sysctl(2) can automatically manage read and write requests through
1437 * the sysctl table. The data and maxlen fields of the ctl_table
1438 * struct enable minimal validation of the values being written to be
1439 * performed, and the mode field allows minimal authentication.
1441 * More sophisticated management can be enabled by the provision of a
1442 * strategy routine with the table entry. This will be called before
1443 * any automatic read or write of the data is performed.
1445 * The strategy routine may return
1447 * < 0 - Error occurred (error is passed to user process)
1449 * 0 - OK - proceed with automatic read or write.
1451 * > 0 - OK - read or write has been done by the strategy routine, so
1452 * return immediately.
1454 * There must be a proc_handler routine for any terminal nodes
1455 * mirrored under /proc/sys (non-terminals are handled by a built-in
1456 * directory handler). Several default handlers are available to
1457 * cover common cases -
1459 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1460 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1461 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1463 * It is the handler's job to read the input buffer from user memory
1464 * and process it. The handler should return 0 on success.
1466 * This routine returns %NULL on a failure to register, and a pointer
1467 * to the table header on success.
1469 struct ctl_table_header
*register_sysctl_table(ctl_table
* table
,
1472 struct ctl_table_header
*tmp
;
1473 tmp
= kmalloc(sizeof(struct ctl_table_header
), GFP_KERNEL
);
1476 tmp
->ctl_table
= table
;
1477 INIT_LIST_HEAD(&tmp
->ctl_entry
);
1479 tmp
->unregistering
= NULL
;
1480 spin_lock(&sysctl_lock
);
1482 list_add(&tmp
->ctl_entry
, &root_table_header
.ctl_entry
);
1484 list_add_tail(&tmp
->ctl_entry
, &root_table_header
.ctl_entry
);
1485 spin_unlock(&sysctl_lock
);
1486 #ifdef CONFIG_PROC_SYSCTL
1487 register_proc_table(table
, proc_sys_root
, tmp
);
1493 * unregister_sysctl_table - unregister a sysctl table hierarchy
1494 * @header: the header returned from register_sysctl_table
1496 * Unregisters the sysctl table and all children. proc entries may not
1497 * actually be removed until they are no longer used by anyone.
1499 void unregister_sysctl_table(struct ctl_table_header
* header
)
1502 spin_lock(&sysctl_lock
);
1503 start_unregistering(header
);
1504 #ifdef CONFIG_PROC_SYSCTL
1505 unregister_proc_table(header
->ctl_table
, proc_sys_root
);
1507 spin_unlock(&sysctl_lock
);
1511 #else /* !CONFIG_SYSCTL */
1512 struct ctl_table_header
* register_sysctl_table(ctl_table
* table
,
1518 void unregister_sysctl_table(struct ctl_table_header
* table
)
1522 #endif /* CONFIG_SYSCTL */
1528 #ifdef CONFIG_PROC_SYSCTL
1530 /* Scan the sysctl entries in table and add them all into /proc */
1531 static void register_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
, void *set
)
1533 struct proc_dir_entry
*de
;
1537 for (; table
->ctl_name
|| table
->procname
; table
++) {
1538 /* Can't do anything without a proc name. */
1539 if (!table
->procname
)
1541 /* Maybe we can't do anything with it... */
1542 if (!table
->proc_handler
&& !table
->child
) {
1543 printk(KERN_WARNING
"SYSCTL: Can't register %s\n",
1548 len
= strlen(table
->procname
);
1552 if (table
->proc_handler
)
1556 for (de
= root
->subdir
; de
; de
= de
->next
) {
1557 if (proc_match(len
, table
->procname
, de
))
1560 /* If the subdir exists already, de is non-NULL */
1564 de
= create_proc_entry(table
->procname
, mode
, root
);
1568 de
->data
= (void *) table
;
1569 if (table
->proc_handler
)
1570 de
->proc_fops
= &proc_sys_file_operations
;
1573 if (de
->mode
& S_IFDIR
)
1574 register_proc_table(table
->child
, de
, set
);
1579 * Unregister a /proc sysctl table and any subdirectories.
1581 static void unregister_proc_table(ctl_table
* table
, struct proc_dir_entry
*root
)
1583 struct proc_dir_entry
*de
;
1584 for (; table
->ctl_name
|| table
->procname
; table
++) {
1585 if (!(de
= table
->de
))
1587 if (de
->mode
& S_IFDIR
) {
1588 if (!table
->child
) {
1589 printk (KERN_ALERT
"Help - malformed sysctl tree on free\n");
1592 unregister_proc_table(table
->child
, de
);
1594 /* Don't unregister directories which still have entries.. */
1600 * In any case, mark the entry as goner; we'll keep it
1601 * around if it's busy, but we'll know to do nothing with
1602 * its fields. We are under sysctl_lock here.
1606 /* Don't unregister proc entries that are still being used.. */
1607 if (atomic_read(&de
->count
))
1611 remove_proc_entry(table
->procname
, root
);
1615 static ssize_t
do_rw_proc(int write
, struct file
* file
, char __user
* buf
,
1616 size_t count
, loff_t
*ppos
)
1619 struct proc_dir_entry
*de
= PDE(file
->f_path
.dentry
->d_inode
);
1620 struct ctl_table
*table
;
1622 ssize_t error
= -ENOTDIR
;
1624 spin_lock(&sysctl_lock
);
1625 if (de
&& de
->data
&& use_table(de
->set
)) {
1627 * at that point we know that sysctl was not unregistered
1628 * and won't be until we finish
1630 spin_unlock(&sysctl_lock
);
1631 table
= (struct ctl_table
*) de
->data
;
1632 if (!table
|| !table
->proc_handler
)
1635 op
= (write
? 002 : 004);
1636 if (ctl_perm(table
, op
))
1639 /* careful: calling conventions are nasty here */
1641 error
= (*table
->proc_handler
)(table
, write
, file
,
1646 spin_lock(&sysctl_lock
);
1647 unuse_table(de
->set
);
1649 spin_unlock(&sysctl_lock
);
1653 static int proc_opensys(struct inode
*inode
, struct file
*file
)
1655 if (file
->f_mode
& FMODE_WRITE
) {
1657 * sysctl entries that are not writable,
1658 * are _NOT_ writable, capabilities or not.
1660 if (!(inode
->i_mode
& S_IWUSR
))
1667 static ssize_t
proc_readsys(struct file
* file
, char __user
* buf
,
1668 size_t count
, loff_t
*ppos
)
1670 return do_rw_proc(0, file
, buf
, count
, ppos
);
1673 static ssize_t
proc_writesys(struct file
* file
, const char __user
* buf
,
1674 size_t count
, loff_t
*ppos
)
1676 return do_rw_proc(1, file
, (char __user
*) buf
, count
, ppos
);
1679 static int _proc_do_string(void* data
, int maxlen
, int write
,
1680 struct file
*filp
, void __user
*buffer
,
1681 size_t *lenp
, loff_t
*ppos
)
1687 if (!data
|| !maxlen
|| !*lenp
) {
1695 while (len
< *lenp
) {
1696 if (get_user(c
, p
++))
1698 if (c
== 0 || c
== '\n')
1704 if(copy_from_user(data
, buffer
, len
))
1706 ((char *) data
)[len
] = 0;
1724 if(copy_to_user(buffer
, data
, len
))
1727 if(put_user('\n', ((char __user
*) buffer
) + len
))
1738 * proc_dostring - read a string sysctl
1739 * @table: the sysctl table
1740 * @write: %TRUE if this is a write to the sysctl file
1741 * @filp: the file structure
1742 * @buffer: the user buffer
1743 * @lenp: the size of the user buffer
1744 * @ppos: file position
1746 * Reads/writes a string from/to the user buffer. If the kernel
1747 * buffer provided is not large enough to hold the string, the
1748 * string is truncated. The copied string is %NULL-terminated.
1749 * If the string is being read by the user process, it is copied
1750 * and a newline '\n' is added. It is truncated if the buffer is
1753 * Returns 0 on success.
1755 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
1756 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1758 return _proc_do_string(table
->data
, table
->maxlen
, write
, filp
,
1759 buffer
, lenp
, ppos
);
1763 * Special case of dostring for the UTS structure. This has locks
1764 * to observe. Should this be in kernel/sys.c ????
1767 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
1768 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1772 which
= get_uts(table
, write
);
1773 r
= _proc_do_string(which
, table
->maxlen
,write
,filp
,buffer
,lenp
, ppos
);
1774 put_uts(table
, write
, which
);
1778 static int do_proc_dointvec_conv(int *negp
, unsigned long *lvalp
,
1780 int write
, void *data
)
1783 *valp
= *negp
? -*lvalp
: *lvalp
;
1788 *lvalp
= (unsigned long)-val
;
1791 *lvalp
= (unsigned long)val
;
1797 static int __do_proc_dointvec(void *tbl_data
, ctl_table
*table
,
1798 int write
, struct file
*filp
, void __user
*buffer
,
1799 size_t *lenp
, loff_t
*ppos
,
1800 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
1801 int write
, void *data
),
1804 #define TMPBUFLEN 21
1805 int *i
, vleft
, first
=1, neg
, val
;
1809 char buf
[TMPBUFLEN
], *p
;
1810 char __user
*s
= buffer
;
1812 if (!tbl_data
|| !table
->maxlen
|| !*lenp
||
1813 (*ppos
&& !write
)) {
1818 i
= (int *) tbl_data
;
1819 vleft
= table
->maxlen
/ sizeof(*i
);
1823 conv
= do_proc_dointvec_conv
;
1825 for (; left
&& vleft
--; i
++, first
=0) {
1840 if (len
> sizeof(buf
) - 1)
1841 len
= sizeof(buf
) - 1;
1842 if (copy_from_user(buf
, s
, len
))
1846 if (*p
== '-' && left
> 1) {
1850 if (*p
< '0' || *p
> '9')
1853 lval
= simple_strtoul(p
, &p
, 0);
1856 if ((len
< left
) && *p
&& !isspace(*p
))
1863 if (conv(&neg
, &lval
, i
, 1, data
))
1870 if (conv(&neg
, &lval
, i
, 0, data
))
1873 sprintf(p
, "%s%lu", neg
? "-" : "", lval
);
1877 if(copy_to_user(s
, buf
, len
))
1884 if (!write
&& !first
&& left
) {
1885 if(put_user('\n', s
))
1892 if (get_user(c
, s
++))
1907 static int do_proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
1908 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
1909 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
1910 int write
, void *data
),
1913 return __do_proc_dointvec(table
->data
, table
, write
, filp
,
1914 buffer
, lenp
, ppos
, conv
, data
);
1918 * proc_dointvec - read a vector of integers
1919 * @table: the sysctl table
1920 * @write: %TRUE if this is a write to the sysctl file
1921 * @filp: the file structure
1922 * @buffer: the user buffer
1923 * @lenp: the size of the user buffer
1924 * @ppos: file position
1926 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1927 * values from/to the user buffer, treated as an ASCII string.
1929 * Returns 0 on success.
1931 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
1932 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1934 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1942 static int do_proc_dointvec_bset_conv(int *negp
, unsigned long *lvalp
,
1944 int write
, void *data
)
1946 int op
= *(int *)data
;
1948 int val
= *negp
? -*lvalp
: *lvalp
;
1950 case OP_SET
: *valp
= val
; break;
1951 case OP_AND
: *valp
&= val
; break;
1952 case OP_OR
: *valp
|= val
; break;
1958 *lvalp
= (unsigned long)-val
;
1961 *lvalp
= (unsigned long)val
;
1968 * init may raise the set.
1971 int proc_dointvec_bset(ctl_table
*table
, int write
, struct file
*filp
,
1972 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1976 if (write
&& !capable(CAP_SYS_MODULE
)) {
1980 op
= is_init(current
) ? OP_SET
: OP_AND
;
1981 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1982 do_proc_dointvec_bset_conv
,&op
);
1986 * Taint values can only be increased
1988 static int proc_dointvec_taint(ctl_table
*table
, int write
, struct file
*filp
,
1989 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1993 if (!capable(CAP_SYS_ADMIN
))
1997 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1998 do_proc_dointvec_bset_conv
,&op
);
2001 struct do_proc_dointvec_minmax_conv_param
{
2006 static int do_proc_dointvec_minmax_conv(int *negp
, unsigned long *lvalp
,
2008 int write
, void *data
)
2010 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2012 int val
= *negp
? -*lvalp
: *lvalp
;
2013 if ((param
->min
&& *param
->min
> val
) ||
2014 (param
->max
&& *param
->max
< val
))
2021 *lvalp
= (unsigned long)-val
;
2024 *lvalp
= (unsigned long)val
;
2031 * proc_dointvec_minmax - read a vector of integers with min/max values
2032 * @table: the sysctl table
2033 * @write: %TRUE if this is a write to the sysctl file
2034 * @filp: the file structure
2035 * @buffer: the user buffer
2036 * @lenp: the size of the user buffer
2037 * @ppos: file position
2039 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2040 * values from/to the user buffer, treated as an ASCII string.
2042 * This routine will ensure the values are within the range specified by
2043 * table->extra1 (min) and table->extra2 (max).
2045 * Returns 0 on success.
2047 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2048 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2050 struct do_proc_dointvec_minmax_conv_param param
= {
2051 .min
= (int *) table
->extra1
,
2052 .max
= (int *) table
->extra2
,
2054 return do_proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
,
2055 do_proc_dointvec_minmax_conv
, ¶m
);
2058 static int __do_proc_doulongvec_minmax(void *data
, ctl_table
*table
, int write
,
2060 void __user
*buffer
,
2061 size_t *lenp
, loff_t
*ppos
,
2062 unsigned long convmul
,
2063 unsigned long convdiv
)
2065 #define TMPBUFLEN 21
2066 unsigned long *i
, *min
, *max
, val
;
2067 int vleft
, first
=1, neg
;
2069 char buf
[TMPBUFLEN
], *p
;
2070 char __user
*s
= buffer
;
2072 if (!data
|| !table
->maxlen
|| !*lenp
||
2073 (*ppos
&& !write
)) {
2078 i
= (unsigned long *) data
;
2079 min
= (unsigned long *) table
->extra1
;
2080 max
= (unsigned long *) table
->extra2
;
2081 vleft
= table
->maxlen
/ sizeof(unsigned long);
2084 for (; left
&& vleft
--; i
++, min
++, max
++, first
=0) {
2099 if (len
> TMPBUFLEN
-1)
2101 if (copy_from_user(buf
, s
, len
))
2105 if (*p
== '-' && left
> 1) {
2109 if (*p
< '0' || *p
> '9')
2111 val
= simple_strtoul(p
, &p
, 0) * convmul
/ convdiv
;
2113 if ((len
< left
) && *p
&& !isspace(*p
))
2122 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2129 sprintf(p
, "%lu", convdiv
* (*i
) / convmul
);
2133 if(copy_to_user(s
, buf
, len
))
2140 if (!write
&& !first
&& left
) {
2141 if(put_user('\n', s
))
2148 if (get_user(c
, s
++))
2163 static int do_proc_doulongvec_minmax(ctl_table
*table
, int write
,
2165 void __user
*buffer
,
2166 size_t *lenp
, loff_t
*ppos
,
2167 unsigned long convmul
,
2168 unsigned long convdiv
)
2170 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2171 filp
, buffer
, lenp
, ppos
, convmul
, convdiv
);
2175 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2176 * @table: the sysctl table
2177 * @write: %TRUE if this is a write to the sysctl file
2178 * @filp: the file structure
2179 * @buffer: the user buffer
2180 * @lenp: the size of the user buffer
2181 * @ppos: file position
2183 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2184 * values from/to the user buffer, treated as an ASCII string.
2186 * This routine will ensure the values are within the range specified by
2187 * table->extra1 (min) and table->extra2 (max).
2189 * Returns 0 on success.
2191 int proc_doulongvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2192 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2194 return do_proc_doulongvec_minmax(table
, write
, filp
, buffer
, lenp
, ppos
, 1l, 1l);
2198 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2199 * @table: the sysctl table
2200 * @write: %TRUE if this is a write to the sysctl file
2201 * @filp: the file structure
2202 * @buffer: the user buffer
2203 * @lenp: the size of the user buffer
2204 * @ppos: file position
2206 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2207 * values from/to the user buffer, treated as an ASCII string. The values
2208 * are treated as milliseconds, and converted to jiffies when they are stored.
2210 * This routine will ensure the values are within the range specified by
2211 * table->extra1 (min) and table->extra2 (max).
2213 * Returns 0 on success.
2215 int proc_doulongvec_ms_jiffies_minmax(ctl_table
*table
, int write
,
2217 void __user
*buffer
,
2218 size_t *lenp
, loff_t
*ppos
)
2220 return do_proc_doulongvec_minmax(table
, write
, filp
, buffer
,
2221 lenp
, ppos
, HZ
, 1000l);
2225 static int do_proc_dointvec_jiffies_conv(int *negp
, unsigned long *lvalp
,
2227 int write
, void *data
)
2230 if (*lvalp
> LONG_MAX
/ HZ
)
2232 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2238 lval
= (unsigned long)-val
;
2241 lval
= (unsigned long)val
;
2248 static int do_proc_dointvec_userhz_jiffies_conv(int *negp
, unsigned long *lvalp
,
2250 int write
, void *data
)
2253 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2255 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2261 lval
= (unsigned long)-val
;
2264 lval
= (unsigned long)val
;
2266 *lvalp
= jiffies_to_clock_t(lval
);
2271 static int do_proc_dointvec_ms_jiffies_conv(int *negp
, unsigned long *lvalp
,
2273 int write
, void *data
)
2276 *valp
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2282 lval
= (unsigned long)-val
;
2285 lval
= (unsigned long)val
;
2287 *lvalp
= jiffies_to_msecs(lval
);
2293 * proc_dointvec_jiffies - read a vector of integers as seconds
2294 * @table: the sysctl table
2295 * @write: %TRUE if this is a write to the sysctl file
2296 * @filp: the file structure
2297 * @buffer: the user buffer
2298 * @lenp: the size of the user buffer
2299 * @ppos: file position
2301 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2302 * values from/to the user buffer, treated as an ASCII string.
2303 * The values read are assumed to be in seconds, and are converted into
2306 * Returns 0 on success.
2308 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2309 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2311 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2312 do_proc_dointvec_jiffies_conv
,NULL
);
2316 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2317 * @table: the sysctl table
2318 * @write: %TRUE if this is a write to the sysctl file
2319 * @filp: the file structure
2320 * @buffer: the user buffer
2321 * @lenp: the size of the user buffer
2322 * @ppos: pointer to the file position
2324 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2325 * values from/to the user buffer, treated as an ASCII string.
2326 * The values read are assumed to be in 1/USER_HZ seconds, and
2327 * are converted into jiffies.
2329 * Returns 0 on success.
2331 int proc_dointvec_userhz_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2332 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2334 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2335 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2339 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2340 * @table: the sysctl table
2341 * @write: %TRUE if this is a write to the sysctl file
2342 * @filp: the file structure
2343 * @buffer: the user buffer
2344 * @lenp: the size of the user buffer
2345 * @ppos: file position
2346 * @ppos: the current position in the file
2348 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2349 * values from/to the user buffer, treated as an ASCII string.
2350 * The values read are assumed to be in 1/1000 seconds, and
2351 * are converted into jiffies.
2353 * Returns 0 on success.
2355 int proc_dointvec_ms_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2356 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2358 return do_proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
,
2359 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2362 #ifdef CONFIG_SYSVIPC
2363 static int proc_ipc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
2364 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2367 which
= get_ipc(table
, write
);
2368 return __do_proc_dointvec(which
, table
, write
, filp
, buffer
,
2369 lenp
, ppos
, NULL
, NULL
);
2372 static int proc_ipc_doulongvec_minmax(ctl_table
*table
, int write
,
2373 struct file
*filp
, void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2376 which
= get_ipc(table
, write
);
2377 return __do_proc_doulongvec_minmax(which
, table
, write
, filp
, buffer
,
2378 lenp
, ppos
, 1l, 1l);
2383 static int proc_do_cad_pid(ctl_table
*table
, int write
, struct file
*filp
,
2384 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2386 struct pid
*new_pid
;
2390 tmp
= pid_nr(cad_pid
);
2392 r
= __do_proc_dointvec(&tmp
, table
, write
, filp
, buffer
,
2393 lenp
, ppos
, NULL
, NULL
);
2397 new_pid
= find_get_pid(tmp
);
2401 put_pid(xchg(&cad_pid
, new_pid
));
2405 #else /* CONFIG_PROC_FS */
2407 int proc_dostring(ctl_table
*table
, int write
, struct file
*filp
,
2408 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2413 static int proc_do_uts_string(ctl_table
*table
, int write
, struct file
*filp
,
2414 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2419 #ifdef CONFIG_SYSVIPC
2420 static int proc_do_ipc_string(ctl_table
*table
, int write
, struct file
*filp
,
2421 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2425 static int proc_ipc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
2426 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2430 static int proc_ipc_doulongvec_minmax(ctl_table
*table
, int write
,
2431 struct file
*filp
, void __user
*buffer
,
2432 size_t *lenp
, loff_t
*ppos
)
2438 int proc_dointvec(ctl_table
*table
, int write
, struct file
*filp
,
2439 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2444 int proc_dointvec_bset(ctl_table
*table
, int write
, struct file
*filp
,
2445 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2450 int proc_dointvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2451 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2456 int proc_dointvec_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2457 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2462 int proc_dointvec_userhz_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2463 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2468 int proc_dointvec_ms_jiffies(ctl_table
*table
, int write
, struct file
*filp
,
2469 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2474 int proc_doulongvec_minmax(ctl_table
*table
, int write
, struct file
*filp
,
2475 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2480 int proc_doulongvec_ms_jiffies_minmax(ctl_table
*table
, int write
,
2482 void __user
*buffer
,
2483 size_t *lenp
, loff_t
*ppos
)
2489 #endif /* CONFIG_PROC_FS */
2492 #ifdef CONFIG_SYSCTL_SYSCALL
2494 * General sysctl support routines
2497 /* The generic string strategy routine: */
2498 int sysctl_string(ctl_table
*table
, int __user
*name
, int nlen
,
2499 void __user
*oldval
, size_t __user
*oldlenp
,
2500 void __user
*newval
, size_t newlen
)
2502 if (!table
->data
|| !table
->maxlen
)
2505 if (oldval
&& oldlenp
) {
2507 if (get_user(bufsize
, oldlenp
))
2510 size_t len
= strlen(table
->data
), copied
;
2512 /* This shouldn't trigger for a well-formed sysctl */
2513 if (len
> table
->maxlen
)
2514 len
= table
->maxlen
;
2516 /* Copy up to a max of bufsize-1 bytes of the string */
2517 copied
= (len
>= bufsize
) ? bufsize
- 1 : len
;
2519 if (copy_to_user(oldval
, table
->data
, copied
) ||
2520 put_user(0, (char __user
*)(oldval
+ copied
)))
2522 if (put_user(len
, oldlenp
))
2526 if (newval
&& newlen
) {
2527 size_t len
= newlen
;
2528 if (len
> table
->maxlen
)
2529 len
= table
->maxlen
;
2530 if(copy_from_user(table
->data
, newval
, len
))
2532 if (len
== table
->maxlen
)
2534 ((char *) table
->data
)[len
] = 0;
2540 * This function makes sure that all of the integers in the vector
2541 * are between the minimum and maximum values given in the arrays
2542 * table->extra1 and table->extra2, respectively.
2544 int sysctl_intvec(ctl_table
*table
, int __user
*name
, int nlen
,
2545 void __user
*oldval
, size_t __user
*oldlenp
,
2546 void __user
*newval
, size_t newlen
)
2549 if (newval
&& newlen
) {
2550 int __user
*vec
= (int __user
*) newval
;
2551 int *min
= (int *) table
->extra1
;
2552 int *max
= (int *) table
->extra2
;
2556 if (newlen
% sizeof(int) != 0)
2559 if (!table
->extra1
&& !table
->extra2
)
2562 if (newlen
> table
->maxlen
)
2563 newlen
= table
->maxlen
;
2564 length
= newlen
/ sizeof(int);
2566 for (i
= 0; i
< length
; i
++) {
2568 if (get_user(value
, vec
+ i
))
2570 if (min
&& value
< min
[i
])
2572 if (max
&& value
> max
[i
])
2579 /* Strategy function to convert jiffies to seconds */
2580 int sysctl_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2581 void __user
*oldval
, size_t __user
*oldlenp
,
2582 void __user
*newval
, size_t newlen
)
2584 if (oldval
&& oldlenp
) {
2587 if (get_user(olen
, oldlenp
))
2592 if (olen
< sizeof(int))
2595 val
= *(int *)(table
->data
) / HZ
;
2596 if (put_user(val
, (int __user
*)oldval
))
2598 if (put_user(sizeof(int), oldlenp
))
2602 if (newval
&& newlen
) {
2604 if (newlen
!= sizeof(int))
2606 if (get_user(new, (int __user
*)newval
))
2608 *(int *)(table
->data
) = new*HZ
;
2613 /* Strategy function to convert jiffies to seconds */
2614 int sysctl_ms_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2615 void __user
*oldval
, size_t __user
*oldlenp
,
2616 void __user
*newval
, size_t newlen
)
2618 if (oldval
&& oldlenp
) {
2621 if (get_user(olen
, oldlenp
))
2626 if (olen
< sizeof(int))
2629 val
= jiffies_to_msecs(*(int *)(table
->data
));
2630 if (put_user(val
, (int __user
*)oldval
))
2632 if (put_user(sizeof(int), oldlenp
))
2636 if (newval
&& newlen
) {
2638 if (newlen
!= sizeof(int))
2640 if (get_user(new, (int __user
*)newval
))
2642 *(int *)(table
->data
) = msecs_to_jiffies(new);
2648 /* The generic string strategy routine: */
2649 static int sysctl_uts_string(ctl_table
*table
, int __user
*name
, int nlen
,
2650 void __user
*oldval
, size_t __user
*oldlenp
,
2651 void __user
*newval
, size_t newlen
)
2653 struct ctl_table uts_table
;
2655 write
= newval
&& newlen
;
2656 memcpy(&uts_table
, table
, sizeof(uts_table
));
2657 uts_table
.data
= get_uts(table
, write
);
2658 r
= sysctl_string(&uts_table
, name
, nlen
,
2659 oldval
, oldlenp
, newval
, newlen
);
2660 put_uts(table
, write
, uts_table
.data
);
2664 #ifdef CONFIG_SYSVIPC
2665 /* The generic sysctl ipc data routine. */
2666 static int sysctl_ipc_data(ctl_table
*table
, int __user
*name
, int nlen
,
2667 void __user
*oldval
, size_t __user
*oldlenp
,
2668 void __user
*newval
, size_t newlen
)
2673 /* Get out of I don't have a variable */
2674 if (!table
->data
|| !table
->maxlen
)
2677 data
= get_ipc(table
, 1);
2681 if (oldval
&& oldlenp
) {
2682 if (get_user(len
, oldlenp
))
2685 if (len
> table
->maxlen
)
2686 len
= table
->maxlen
;
2687 if (copy_to_user(oldval
, data
, len
))
2689 if (put_user(len
, oldlenp
))
2694 if (newval
&& newlen
) {
2695 if (newlen
> table
->maxlen
)
2696 newlen
= table
->maxlen
;
2698 if (copy_from_user(data
, newval
, newlen
))
2705 #else /* CONFIG_SYSCTL_SYSCALL */
2708 asmlinkage
long sys_sysctl(struct __sysctl_args __user
*args
)
2710 static int msg_count
;
2711 struct __sysctl_args tmp
;
2712 int name
[CTL_MAXNAME
];
2715 /* Read in the sysctl name for better debug message logging */
2716 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
2718 if (tmp
.nlen
<= 0 || tmp
.nlen
>= CTL_MAXNAME
)
2720 for (i
= 0; i
< tmp
.nlen
; i
++)
2721 if (get_user(name
[i
], tmp
.name
+ i
))
2724 /* Ignore accesses to kernel.version */
2725 if ((tmp
.nlen
== 2) && (name
[0] == CTL_KERN
) && (name
[1] == KERN_VERSION
))
2728 if (msg_count
< 5) {
2731 "warning: process `%s' used the removed sysctl "
2732 "system call with ", current
->comm
);
2733 for (i
= 0; i
< tmp
.nlen
; i
++)
2734 printk("%d.", name
[i
]);
2741 int sysctl_string(ctl_table
*table
, int __user
*name
, int nlen
,
2742 void __user
*oldval
, size_t __user
*oldlenp
,
2743 void __user
*newval
, size_t newlen
)
2748 int sysctl_intvec(ctl_table
*table
, int __user
*name
, int nlen
,
2749 void __user
*oldval
, size_t __user
*oldlenp
,
2750 void __user
*newval
, size_t newlen
)
2755 int sysctl_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2756 void __user
*oldval
, size_t __user
*oldlenp
,
2757 void __user
*newval
, size_t newlen
)
2762 int sysctl_ms_jiffies(ctl_table
*table
, int __user
*name
, int nlen
,
2763 void __user
*oldval
, size_t __user
*oldlenp
,
2764 void __user
*newval
, size_t newlen
)
2769 static int sysctl_uts_string(ctl_table
*table
, int __user
*name
, int nlen
,
2770 void __user
*oldval
, size_t __user
*oldlenp
,
2771 void __user
*newval
, size_t newlen
)
2775 #ifdef CONFIG_SYSVIPC
2776 static int sysctl_ipc_data(ctl_table
*table
, int __user
*name
, int nlen
,
2777 void __user
*oldval
, size_t __user
*oldlenp
,
2778 void __user
*newval
, size_t newlen
)
2783 #endif /* CONFIG_SYSCTL_SYSCALL */
2786 * No sense putting this after each symbol definition, twice,
2787 * exception granted :-)
2789 EXPORT_SYMBOL(proc_dointvec
);
2790 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2791 EXPORT_SYMBOL(proc_dointvec_minmax
);
2792 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2793 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2794 EXPORT_SYMBOL(proc_dostring
);
2795 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2796 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);
2797 EXPORT_SYMBOL(register_sysctl_table
);
2798 EXPORT_SYMBOL(sysctl_intvec
);
2799 EXPORT_SYMBOL(sysctl_jiffies
);
2800 EXPORT_SYMBOL(sysctl_ms_jiffies
);
2801 EXPORT_SYMBOL(sysctl_string
);
2802 EXPORT_SYMBOL(unregister_sysctl_table
);