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/security.h>
28 #include <linux/ctype.h>
29 #include <linux/utsname.h>
30 #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>
48 #include <linux/reboot.h>
50 #include <asm/uaccess.h>
51 #include <asm/processor.h>
55 #include <asm/stacktrace.h>
58 static int deprecated_sysctl_warning(struct __sysctl_args
*args
);
60 #if defined(CONFIG_SYSCTL)
62 /* External variables not in a header file. */
64 extern int print_fatal_signals
;
65 extern int sysctl_overcommit_memory
;
66 extern int sysctl_overcommit_ratio
;
67 extern int sysctl_panic_on_oom
;
68 extern int sysctl_oom_kill_allocating_task
;
69 extern int max_threads
;
70 extern int core_uses_pid
;
71 extern int suid_dumpable
;
72 extern char core_pattern
[];
74 extern int min_free_kbytes
;
75 extern int printk_ratelimit_jiffies
;
76 extern int printk_ratelimit_burst
;
77 extern int pid_max_min
, pid_max_max
;
78 extern int sysctl_drop_caches
;
79 extern int percpu_pagelist_fraction
;
80 extern int compat_log
;
81 extern int maps_protect
;
82 extern int sysctl_stat_interval
;
83 extern int audit_argv_kb
;
84 extern int latencytop_enabled
;
86 /* Constants used for minimum and maximum */
87 #ifdef CONFIG_DETECT_SOFTLOCKUP
89 static int sixty
= 60;
97 static int one_hundred
= 100;
99 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
100 static int maxolduid
= 65535;
101 static int minolduid
;
102 static int min_percpu_pagelist_fract
= 8;
104 static int ngroups_max
= NGROUPS_MAX
;
107 extern char modprobe_path
[];
109 #ifdef CONFIG_CHR_DEV_SG
110 extern int sg_big_buff
;
114 extern char reboot_command
[];
115 extern int stop_a_enabled
;
116 extern int scons_pwroff
;
120 extern int pwrsw_enabled
;
121 extern int unaligned_enabled
;
125 #ifdef CONFIG_MATHEMU
126 extern int sysctl_ieee_emulation_warnings
;
128 extern int sysctl_userprocess_debug
;
129 extern int spin_retry
;
132 extern int sysctl_hz_timer
;
134 #ifdef CONFIG_BSD_PROCESS_ACCT
135 extern int acct_parm
[];
139 extern int no_unaligned_warning
;
142 #ifdef CONFIG_RT_MUTEXES
143 extern int max_lock_depth
;
146 #ifdef CONFIG_SYSCTL_SYSCALL
147 static int parse_table(int __user
*, int, void __user
*, size_t __user
*,
148 void __user
*, size_t, struct ctl_table
*);
152 #ifdef CONFIG_PROC_SYSCTL
153 static int proc_do_cad_pid(struct ctl_table
*table
, int write
, struct file
*filp
,
154 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
155 static int proc_dointvec_taint(struct ctl_table
*table
, int write
, struct file
*filp
,
156 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
159 static struct ctl_table root_table
[];
160 static struct ctl_table_header root_table_header
=
161 { root_table
, LIST_HEAD_INIT(root_table_header
.ctl_entry
) };
163 static struct ctl_table kern_table
[];
164 static struct ctl_table vm_table
[];
165 static struct ctl_table fs_table
[];
166 static struct ctl_table debug_table
[];
167 static struct ctl_table dev_table
[];
168 extern struct ctl_table random_table
[];
169 #ifdef CONFIG_INOTIFY_USER
170 extern struct ctl_table inotify_table
[];
173 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
174 int sysctl_legacy_va_layout
;
177 extern int prove_locking
;
178 extern int lock_stat
;
180 /* The default sysctl tables: */
182 static struct ctl_table root_table
[] = {
184 .ctl_name
= CTL_KERN
,
185 .procname
= "kernel",
210 .ctl_name
= CTL_DEBUG
,
213 .child
= debug_table
,
222 * NOTE: do not add new entries to this table unless you have read
223 * Documentation/sysctl/ctl_unnumbered.txt
228 #ifdef CONFIG_SCHED_DEBUG
229 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
230 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
231 static int min_wakeup_granularity_ns
; /* 0 usecs */
232 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
235 static struct ctl_table kern_table
[] = {
236 #ifdef CONFIG_SCHED_DEBUG
238 .ctl_name
= CTL_UNNUMBERED
,
239 .procname
= "sched_min_granularity_ns",
240 .data
= &sysctl_sched_min_granularity
,
241 .maxlen
= sizeof(unsigned int),
243 .proc_handler
= &sched_nr_latency_handler
,
244 .strategy
= &sysctl_intvec
,
245 .extra1
= &min_sched_granularity_ns
,
246 .extra2
= &max_sched_granularity_ns
,
249 .ctl_name
= CTL_UNNUMBERED
,
250 .procname
= "sched_latency_ns",
251 .data
= &sysctl_sched_latency
,
252 .maxlen
= sizeof(unsigned int),
254 .proc_handler
= &sched_nr_latency_handler
,
255 .strategy
= &sysctl_intvec
,
256 .extra1
= &min_sched_granularity_ns
,
257 .extra2
= &max_sched_granularity_ns
,
260 .ctl_name
= CTL_UNNUMBERED
,
261 .procname
= "sched_wakeup_granularity_ns",
262 .data
= &sysctl_sched_wakeup_granularity
,
263 .maxlen
= sizeof(unsigned int),
265 .proc_handler
= &proc_dointvec_minmax
,
266 .strategy
= &sysctl_intvec
,
267 .extra1
= &min_wakeup_granularity_ns
,
268 .extra2
= &max_wakeup_granularity_ns
,
271 .ctl_name
= CTL_UNNUMBERED
,
272 .procname
= "sched_batch_wakeup_granularity_ns",
273 .data
= &sysctl_sched_batch_wakeup_granularity
,
274 .maxlen
= sizeof(unsigned int),
276 .proc_handler
= &proc_dointvec_minmax
,
277 .strategy
= &sysctl_intvec
,
278 .extra1
= &min_wakeup_granularity_ns
,
279 .extra2
= &max_wakeup_granularity_ns
,
282 .ctl_name
= CTL_UNNUMBERED
,
283 .procname
= "sched_child_runs_first",
284 .data
= &sysctl_sched_child_runs_first
,
285 .maxlen
= sizeof(unsigned int),
287 .proc_handler
= &proc_dointvec
,
290 .ctl_name
= CTL_UNNUMBERED
,
291 .procname
= "sched_features",
292 .data
= &sysctl_sched_features
,
293 .maxlen
= sizeof(unsigned int),
295 .proc_handler
= &proc_dointvec
,
298 .ctl_name
= CTL_UNNUMBERED
,
299 .procname
= "sched_migration_cost",
300 .data
= &sysctl_sched_migration_cost
,
301 .maxlen
= sizeof(unsigned int),
303 .proc_handler
= &proc_dointvec
,
306 .ctl_name
= CTL_UNNUMBERED
,
307 .procname
= "sched_nr_migrate",
308 .data
= &sysctl_sched_nr_migrate
,
309 .maxlen
= sizeof(unsigned int),
311 .proc_handler
= &proc_dointvec
,
314 .ctl_name
= CTL_UNNUMBERED
,
315 .procname
= "sched_rt_period_ms",
316 .data
= &sysctl_sched_rt_period
,
317 .maxlen
= sizeof(unsigned int),
319 .proc_handler
= &proc_dointvec
,
322 .ctl_name
= CTL_UNNUMBERED
,
323 .procname
= "sched_rt_ratio",
324 .data
= &sysctl_sched_rt_ratio
,
325 .maxlen
= sizeof(unsigned int),
327 .proc_handler
= &proc_dointvec
,
329 #if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_SMP)
331 .ctl_name
= CTL_UNNUMBERED
,
332 .procname
= "sched_min_bal_int_shares",
333 .data
= &sysctl_sched_min_bal_int_shares
,
334 .maxlen
= sizeof(unsigned int),
336 .proc_handler
= &proc_dointvec
,
339 .ctl_name
= CTL_UNNUMBERED
,
340 .procname
= "sched_max_bal_int_shares",
341 .data
= &sysctl_sched_max_bal_int_shares
,
342 .maxlen
= sizeof(unsigned int),
344 .proc_handler
= &proc_dointvec
,
349 .ctl_name
= CTL_UNNUMBERED
,
350 .procname
= "sched_compat_yield",
351 .data
= &sysctl_sched_compat_yield
,
352 .maxlen
= sizeof(unsigned int),
354 .proc_handler
= &proc_dointvec
,
356 #ifdef CONFIG_PROVE_LOCKING
358 .ctl_name
= CTL_UNNUMBERED
,
359 .procname
= "prove_locking",
360 .data
= &prove_locking
,
361 .maxlen
= sizeof(int),
363 .proc_handler
= &proc_dointvec
,
366 #ifdef CONFIG_LOCK_STAT
368 .ctl_name
= CTL_UNNUMBERED
,
369 .procname
= "lock_stat",
371 .maxlen
= sizeof(int),
373 .proc_handler
= &proc_dointvec
,
377 .ctl_name
= KERN_PANIC
,
379 .data
= &panic_timeout
,
380 .maxlen
= sizeof(int),
382 .proc_handler
= &proc_dointvec
,
385 .ctl_name
= KERN_CORE_USES_PID
,
386 .procname
= "core_uses_pid",
387 .data
= &core_uses_pid
,
388 .maxlen
= sizeof(int),
390 .proc_handler
= &proc_dointvec
,
392 #ifdef CONFIG_AUDITSYSCALL
394 .ctl_name
= CTL_UNNUMBERED
,
395 .procname
= "audit_argv_kb",
396 .data
= &audit_argv_kb
,
397 .maxlen
= sizeof(int),
399 .proc_handler
= &proc_dointvec
,
403 .ctl_name
= KERN_CORE_PATTERN
,
404 .procname
= "core_pattern",
405 .data
= core_pattern
,
406 .maxlen
= CORENAME_MAX_SIZE
,
408 .proc_handler
= &proc_dostring
,
409 .strategy
= &sysctl_string
,
411 #ifdef CONFIG_PROC_SYSCTL
413 .procname
= "tainted",
415 .maxlen
= sizeof(int),
417 .proc_handler
= &proc_dointvec_taint
,
420 #ifdef CONFIG_LATENCYTOP
422 .procname
= "latencytop",
423 .data
= &latencytop_enabled
,
424 .maxlen
= sizeof(int),
426 .proc_handler
= &proc_dointvec
,
429 #ifdef CONFIG_SECURITY_CAPABILITIES
431 .procname
= "cap-bound",
433 .maxlen
= sizeof(kernel_cap_t
),
435 .proc_handler
= &proc_dointvec_bset
,
437 #endif /* def CONFIG_SECURITY_CAPABILITIES */
438 #ifdef CONFIG_BLK_DEV_INITRD
440 .ctl_name
= KERN_REALROOTDEV
,
441 .procname
= "real-root-dev",
442 .data
= &real_root_dev
,
443 .maxlen
= sizeof(int),
445 .proc_handler
= &proc_dointvec
,
449 .ctl_name
= CTL_UNNUMBERED
,
450 .procname
= "print-fatal-signals",
451 .data
= &print_fatal_signals
,
452 .maxlen
= sizeof(int),
454 .proc_handler
= &proc_dointvec
,
458 .ctl_name
= KERN_SPARC_REBOOT
,
459 .procname
= "reboot-cmd",
460 .data
= reboot_command
,
463 .proc_handler
= &proc_dostring
,
464 .strategy
= &sysctl_string
,
467 .ctl_name
= KERN_SPARC_STOP_A
,
468 .procname
= "stop-a",
469 .data
= &stop_a_enabled
,
470 .maxlen
= sizeof (int),
472 .proc_handler
= &proc_dointvec
,
475 .ctl_name
= KERN_SPARC_SCONS_PWROFF
,
476 .procname
= "scons-poweroff",
477 .data
= &scons_pwroff
,
478 .maxlen
= sizeof (int),
480 .proc_handler
= &proc_dointvec
,
485 .ctl_name
= KERN_HPPA_PWRSW
,
486 .procname
= "soft-power",
487 .data
= &pwrsw_enabled
,
488 .maxlen
= sizeof (int),
490 .proc_handler
= &proc_dointvec
,
493 .ctl_name
= KERN_HPPA_UNALIGNED
,
494 .procname
= "unaligned-trap",
495 .data
= &unaligned_enabled
,
496 .maxlen
= sizeof (int),
498 .proc_handler
= &proc_dointvec
,
502 .ctl_name
= KERN_CTLALTDEL
,
503 .procname
= "ctrl-alt-del",
505 .maxlen
= sizeof(int),
507 .proc_handler
= &proc_dointvec
,
510 .ctl_name
= KERN_PRINTK
,
511 .procname
= "printk",
512 .data
= &console_loglevel
,
513 .maxlen
= 4*sizeof(int),
515 .proc_handler
= &proc_dointvec
,
519 .ctl_name
= KERN_MODPROBE
,
520 .procname
= "modprobe",
521 .data
= &modprobe_path
,
522 .maxlen
= KMOD_PATH_LEN
,
524 .proc_handler
= &proc_dostring
,
525 .strategy
= &sysctl_string
,
528 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
530 .ctl_name
= KERN_HOTPLUG
,
531 .procname
= "hotplug",
532 .data
= &uevent_helper
,
533 .maxlen
= UEVENT_HELPER_PATH_LEN
,
535 .proc_handler
= &proc_dostring
,
536 .strategy
= &sysctl_string
,
539 #ifdef CONFIG_CHR_DEV_SG
541 .ctl_name
= KERN_SG_BIG_BUFF
,
542 .procname
= "sg-big-buff",
543 .data
= &sg_big_buff
,
544 .maxlen
= sizeof (int),
546 .proc_handler
= &proc_dointvec
,
549 #ifdef CONFIG_BSD_PROCESS_ACCT
551 .ctl_name
= KERN_ACCT
,
554 .maxlen
= 3*sizeof(int),
556 .proc_handler
= &proc_dointvec
,
559 #ifdef CONFIG_MAGIC_SYSRQ
561 .ctl_name
= KERN_SYSRQ
,
563 .data
= &__sysrq_enabled
,
564 .maxlen
= sizeof (int),
566 .proc_handler
= &proc_dointvec
,
569 #ifdef CONFIG_PROC_SYSCTL
571 .procname
= "cad_pid",
573 .maxlen
= sizeof (int),
575 .proc_handler
= &proc_do_cad_pid
,
579 .ctl_name
= KERN_MAX_THREADS
,
580 .procname
= "threads-max",
581 .data
= &max_threads
,
582 .maxlen
= sizeof(int),
584 .proc_handler
= &proc_dointvec
,
587 .ctl_name
= KERN_RANDOM
,
588 .procname
= "random",
590 .child
= random_table
,
593 .ctl_name
= KERN_OVERFLOWUID
,
594 .procname
= "overflowuid",
595 .data
= &overflowuid
,
596 .maxlen
= sizeof(int),
598 .proc_handler
= &proc_dointvec_minmax
,
599 .strategy
= &sysctl_intvec
,
600 .extra1
= &minolduid
,
601 .extra2
= &maxolduid
,
604 .ctl_name
= KERN_OVERFLOWGID
,
605 .procname
= "overflowgid",
606 .data
= &overflowgid
,
607 .maxlen
= sizeof(int),
609 .proc_handler
= &proc_dointvec_minmax
,
610 .strategy
= &sysctl_intvec
,
611 .extra1
= &minolduid
,
612 .extra2
= &maxolduid
,
615 #ifdef CONFIG_MATHEMU
617 .ctl_name
= KERN_IEEE_EMULATION_WARNINGS
,
618 .procname
= "ieee_emulation_warnings",
619 .data
= &sysctl_ieee_emulation_warnings
,
620 .maxlen
= sizeof(int),
622 .proc_handler
= &proc_dointvec
,
625 #ifdef CONFIG_NO_IDLE_HZ
627 .ctl_name
= KERN_HZ_TIMER
,
628 .procname
= "hz_timer",
629 .data
= &sysctl_hz_timer
,
630 .maxlen
= sizeof(int),
632 .proc_handler
= &proc_dointvec
,
636 .ctl_name
= KERN_S390_USER_DEBUG_LOGGING
,
637 .procname
= "userprocess_debug",
638 .data
= &sysctl_userprocess_debug
,
639 .maxlen
= sizeof(int),
641 .proc_handler
= &proc_dointvec
,
645 .ctl_name
= KERN_PIDMAX
,
646 .procname
= "pid_max",
648 .maxlen
= sizeof (int),
650 .proc_handler
= &proc_dointvec_minmax
,
651 .strategy
= sysctl_intvec
,
652 .extra1
= &pid_max_min
,
653 .extra2
= &pid_max_max
,
656 .ctl_name
= KERN_PANIC_ON_OOPS
,
657 .procname
= "panic_on_oops",
658 .data
= &panic_on_oops
,
659 .maxlen
= sizeof(int),
661 .proc_handler
= &proc_dointvec
,
664 .ctl_name
= KERN_PRINTK_RATELIMIT
,
665 .procname
= "printk_ratelimit",
666 .data
= &printk_ratelimit_jiffies
,
667 .maxlen
= sizeof(int),
669 .proc_handler
= &proc_dointvec_jiffies
,
670 .strategy
= &sysctl_jiffies
,
673 .ctl_name
= KERN_PRINTK_RATELIMIT_BURST
,
674 .procname
= "printk_ratelimit_burst",
675 .data
= &printk_ratelimit_burst
,
676 .maxlen
= sizeof(int),
678 .proc_handler
= &proc_dointvec
,
681 .ctl_name
= KERN_NGROUPS_MAX
,
682 .procname
= "ngroups_max",
683 .data
= &ngroups_max
,
684 .maxlen
= sizeof (int),
686 .proc_handler
= &proc_dointvec
,
688 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
690 .ctl_name
= KERN_UNKNOWN_NMI_PANIC
,
691 .procname
= "unknown_nmi_panic",
692 .data
= &unknown_nmi_panic
,
693 .maxlen
= sizeof (int),
695 .proc_handler
= &proc_dointvec
,
698 .procname
= "nmi_watchdog",
699 .data
= &nmi_watchdog_enabled
,
700 .maxlen
= sizeof (int),
702 .proc_handler
= &proc_nmi_enabled
,
705 #if defined(CONFIG_X86)
707 .ctl_name
= KERN_PANIC_ON_NMI
,
708 .procname
= "panic_on_unrecovered_nmi",
709 .data
= &panic_on_unrecovered_nmi
,
710 .maxlen
= sizeof(int),
712 .proc_handler
= &proc_dointvec
,
715 .ctl_name
= KERN_BOOTLOADER_TYPE
,
716 .procname
= "bootloader_type",
717 .data
= &bootloader_type
,
718 .maxlen
= sizeof (int),
720 .proc_handler
= &proc_dointvec
,
723 .ctl_name
= CTL_UNNUMBERED
,
724 .procname
= "kstack_depth_to_print",
725 .data
= &kstack_depth_to_print
,
726 .maxlen
= sizeof(int),
728 .proc_handler
= &proc_dointvec
,
731 #if defined(CONFIG_MMU)
733 .ctl_name
= KERN_RANDOMIZE
,
734 .procname
= "randomize_va_space",
735 .data
= &randomize_va_space
,
736 .maxlen
= sizeof(int),
738 .proc_handler
= &proc_dointvec
,
741 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
743 .ctl_name
= KERN_SPIN_RETRY
,
744 .procname
= "spin_retry",
746 .maxlen
= sizeof (int),
748 .proc_handler
= &proc_dointvec
,
751 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
753 .procname
= "acpi_video_flags",
754 .data
= &acpi_realmode_flags
,
755 .maxlen
= sizeof (unsigned long),
757 .proc_handler
= &proc_doulongvec_minmax
,
762 .ctl_name
= KERN_IA64_UNALIGNED
,
763 .procname
= "ignore-unaligned-usertrap",
764 .data
= &no_unaligned_warning
,
765 .maxlen
= sizeof (int),
767 .proc_handler
= &proc_dointvec
,
770 #ifdef CONFIG_DETECT_SOFTLOCKUP
772 .ctl_name
= CTL_UNNUMBERED
,
773 .procname
= "softlockup_thresh",
774 .data
= &softlockup_thresh
,
775 .maxlen
= sizeof(unsigned long),
777 .proc_handler
= &proc_doulongvec_minmax
,
778 .strategy
= &sysctl_intvec
,
783 .ctl_name
= CTL_UNNUMBERED
,
784 .procname
= "hung_task_check_count",
785 .data
= &sysctl_hung_task_check_count
,
786 .maxlen
= sizeof(unsigned long),
788 .proc_handler
= &proc_doulongvec_minmax
,
789 .strategy
= &sysctl_intvec
,
792 .ctl_name
= CTL_UNNUMBERED
,
793 .procname
= "hung_task_timeout_secs",
794 .data
= &sysctl_hung_task_timeout_secs
,
795 .maxlen
= sizeof(unsigned long),
797 .proc_handler
= &proc_doulongvec_minmax
,
798 .strategy
= &sysctl_intvec
,
801 .ctl_name
= CTL_UNNUMBERED
,
802 .procname
= "hung_task_warnings",
803 .data
= &sysctl_hung_task_warnings
,
804 .maxlen
= sizeof(unsigned long),
806 .proc_handler
= &proc_doulongvec_minmax
,
807 .strategy
= &sysctl_intvec
,
812 .ctl_name
= KERN_COMPAT_LOG
,
813 .procname
= "compat-log",
815 .maxlen
= sizeof (int),
817 .proc_handler
= &proc_dointvec
,
820 #ifdef CONFIG_RT_MUTEXES
822 .ctl_name
= KERN_MAX_LOCK_DEPTH
,
823 .procname
= "max_lock_depth",
824 .data
= &max_lock_depth
,
825 .maxlen
= sizeof(int),
827 .proc_handler
= &proc_dointvec
,
830 #ifdef CONFIG_PROC_FS
832 .ctl_name
= CTL_UNNUMBERED
,
833 .procname
= "maps_protect",
834 .data
= &maps_protect
,
835 .maxlen
= sizeof(int),
837 .proc_handler
= &proc_dointvec
,
841 .ctl_name
= CTL_UNNUMBERED
,
842 .procname
= "poweroff_cmd",
843 .data
= &poweroff_cmd
,
844 .maxlen
= POWEROFF_CMD_PATH_LEN
,
846 .proc_handler
= &proc_dostring
,
847 .strategy
= &sysctl_string
,
850 * NOTE: do not add new entries to this table unless you have read
851 * Documentation/sysctl/ctl_unnumbered.txt
856 static struct ctl_table vm_table
[] = {
858 .ctl_name
= VM_OVERCOMMIT_MEMORY
,
859 .procname
= "overcommit_memory",
860 .data
= &sysctl_overcommit_memory
,
861 .maxlen
= sizeof(sysctl_overcommit_memory
),
863 .proc_handler
= &proc_dointvec
,
866 .ctl_name
= VM_PANIC_ON_OOM
,
867 .procname
= "panic_on_oom",
868 .data
= &sysctl_panic_on_oom
,
869 .maxlen
= sizeof(sysctl_panic_on_oom
),
871 .proc_handler
= &proc_dointvec
,
874 .ctl_name
= CTL_UNNUMBERED
,
875 .procname
= "oom_kill_allocating_task",
876 .data
= &sysctl_oom_kill_allocating_task
,
877 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
879 .proc_handler
= &proc_dointvec
,
882 .ctl_name
= VM_OVERCOMMIT_RATIO
,
883 .procname
= "overcommit_ratio",
884 .data
= &sysctl_overcommit_ratio
,
885 .maxlen
= sizeof(sysctl_overcommit_ratio
),
887 .proc_handler
= &proc_dointvec
,
890 .ctl_name
= VM_PAGE_CLUSTER
,
891 .procname
= "page-cluster",
892 .data
= &page_cluster
,
893 .maxlen
= sizeof(int),
895 .proc_handler
= &proc_dointvec
,
898 .ctl_name
= VM_DIRTY_BACKGROUND
,
899 .procname
= "dirty_background_ratio",
900 .data
= &dirty_background_ratio
,
901 .maxlen
= sizeof(dirty_background_ratio
),
903 .proc_handler
= &proc_dointvec_minmax
,
904 .strategy
= &sysctl_intvec
,
906 .extra2
= &one_hundred
,
909 .ctl_name
= VM_DIRTY_RATIO
,
910 .procname
= "dirty_ratio",
911 .data
= &vm_dirty_ratio
,
912 .maxlen
= sizeof(vm_dirty_ratio
),
914 .proc_handler
= &dirty_ratio_handler
,
915 .strategy
= &sysctl_intvec
,
917 .extra2
= &one_hundred
,
920 .procname
= "dirty_writeback_centisecs",
921 .data
= &dirty_writeback_interval
,
922 .maxlen
= sizeof(dirty_writeback_interval
),
924 .proc_handler
= &dirty_writeback_centisecs_handler
,
927 .procname
= "dirty_expire_centisecs",
928 .data
= &dirty_expire_interval
,
929 .maxlen
= sizeof(dirty_expire_interval
),
931 .proc_handler
= &proc_dointvec_userhz_jiffies
,
934 .ctl_name
= VM_NR_PDFLUSH_THREADS
,
935 .procname
= "nr_pdflush_threads",
936 .data
= &nr_pdflush_threads
,
937 .maxlen
= sizeof nr_pdflush_threads
,
938 .mode
= 0444 /* read-only*/,
939 .proc_handler
= &proc_dointvec
,
942 .ctl_name
= VM_SWAPPINESS
,
943 .procname
= "swappiness",
944 .data
= &vm_swappiness
,
945 .maxlen
= sizeof(vm_swappiness
),
947 .proc_handler
= &proc_dointvec_minmax
,
948 .strategy
= &sysctl_intvec
,
950 .extra2
= &one_hundred
,
952 #ifdef CONFIG_HUGETLB_PAGE
954 .procname
= "nr_hugepages",
955 .data
= &max_huge_pages
,
956 .maxlen
= sizeof(unsigned long),
958 .proc_handler
= &hugetlb_sysctl_handler
,
959 .extra1
= (void *)&hugetlb_zero
,
960 .extra2
= (void *)&hugetlb_infinity
,
963 .ctl_name
= VM_HUGETLB_GROUP
,
964 .procname
= "hugetlb_shm_group",
965 .data
= &sysctl_hugetlb_shm_group
,
966 .maxlen
= sizeof(gid_t
),
968 .proc_handler
= &proc_dointvec
,
971 .ctl_name
= CTL_UNNUMBERED
,
972 .procname
= "hugepages_treat_as_movable",
973 .data
= &hugepages_treat_as_movable
,
974 .maxlen
= sizeof(int),
976 .proc_handler
= &hugetlb_treat_movable_handler
,
979 .ctl_name
= CTL_UNNUMBERED
,
980 .procname
= "nr_overcommit_hugepages",
981 .data
= &nr_overcommit_huge_pages
,
982 .maxlen
= sizeof(nr_overcommit_huge_pages
),
984 .proc_handler
= &proc_doulongvec_minmax
,
988 .ctl_name
= VM_LOWMEM_RESERVE_RATIO
,
989 .procname
= "lowmem_reserve_ratio",
990 .data
= &sysctl_lowmem_reserve_ratio
,
991 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
993 .proc_handler
= &lowmem_reserve_ratio_sysctl_handler
,
994 .strategy
= &sysctl_intvec
,
997 .ctl_name
= VM_DROP_PAGECACHE
,
998 .procname
= "drop_caches",
999 .data
= &sysctl_drop_caches
,
1000 .maxlen
= sizeof(int),
1002 .proc_handler
= drop_caches_sysctl_handler
,
1003 .strategy
= &sysctl_intvec
,
1006 .ctl_name
= VM_MIN_FREE_KBYTES
,
1007 .procname
= "min_free_kbytes",
1008 .data
= &min_free_kbytes
,
1009 .maxlen
= sizeof(min_free_kbytes
),
1011 .proc_handler
= &min_free_kbytes_sysctl_handler
,
1012 .strategy
= &sysctl_intvec
,
1016 .ctl_name
= VM_PERCPU_PAGELIST_FRACTION
,
1017 .procname
= "percpu_pagelist_fraction",
1018 .data
= &percpu_pagelist_fraction
,
1019 .maxlen
= sizeof(percpu_pagelist_fraction
),
1021 .proc_handler
= &percpu_pagelist_fraction_sysctl_handler
,
1022 .strategy
= &sysctl_intvec
,
1023 .extra1
= &min_percpu_pagelist_fract
,
1027 .ctl_name
= VM_MAX_MAP_COUNT
,
1028 .procname
= "max_map_count",
1029 .data
= &sysctl_max_map_count
,
1030 .maxlen
= sizeof(sysctl_max_map_count
),
1032 .proc_handler
= &proc_dointvec
1036 .ctl_name
= VM_LAPTOP_MODE
,
1037 .procname
= "laptop_mode",
1038 .data
= &laptop_mode
,
1039 .maxlen
= sizeof(laptop_mode
),
1041 .proc_handler
= &proc_dointvec_jiffies
,
1042 .strategy
= &sysctl_jiffies
,
1045 .ctl_name
= VM_BLOCK_DUMP
,
1046 .procname
= "block_dump",
1047 .data
= &block_dump
,
1048 .maxlen
= sizeof(block_dump
),
1050 .proc_handler
= &proc_dointvec
,
1051 .strategy
= &sysctl_intvec
,
1055 .ctl_name
= VM_VFS_CACHE_PRESSURE
,
1056 .procname
= "vfs_cache_pressure",
1057 .data
= &sysctl_vfs_cache_pressure
,
1058 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1060 .proc_handler
= &proc_dointvec
,
1061 .strategy
= &sysctl_intvec
,
1064 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1066 .ctl_name
= VM_LEGACY_VA_LAYOUT
,
1067 .procname
= "legacy_va_layout",
1068 .data
= &sysctl_legacy_va_layout
,
1069 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1071 .proc_handler
= &proc_dointvec
,
1072 .strategy
= &sysctl_intvec
,
1078 .ctl_name
= VM_ZONE_RECLAIM_MODE
,
1079 .procname
= "zone_reclaim_mode",
1080 .data
= &zone_reclaim_mode
,
1081 .maxlen
= sizeof(zone_reclaim_mode
),
1083 .proc_handler
= &proc_dointvec
,
1084 .strategy
= &sysctl_intvec
,
1088 .ctl_name
= VM_MIN_UNMAPPED
,
1089 .procname
= "min_unmapped_ratio",
1090 .data
= &sysctl_min_unmapped_ratio
,
1091 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1093 .proc_handler
= &sysctl_min_unmapped_ratio_sysctl_handler
,
1094 .strategy
= &sysctl_intvec
,
1096 .extra2
= &one_hundred
,
1099 .ctl_name
= VM_MIN_SLAB
,
1100 .procname
= "min_slab_ratio",
1101 .data
= &sysctl_min_slab_ratio
,
1102 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1104 .proc_handler
= &sysctl_min_slab_ratio_sysctl_handler
,
1105 .strategy
= &sysctl_intvec
,
1107 .extra2
= &one_hundred
,
1112 .ctl_name
= CTL_UNNUMBERED
,
1113 .procname
= "stat_interval",
1114 .data
= &sysctl_stat_interval
,
1115 .maxlen
= sizeof(sysctl_stat_interval
),
1117 .proc_handler
= &proc_dointvec_jiffies
,
1118 .strategy
= &sysctl_jiffies
,
1121 #ifdef CONFIG_SECURITY
1123 .ctl_name
= CTL_UNNUMBERED
,
1124 .procname
= "mmap_min_addr",
1125 .data
= &mmap_min_addr
,
1126 .maxlen
= sizeof(unsigned long),
1128 .proc_handler
= &proc_doulongvec_minmax
,
1133 .ctl_name
= CTL_UNNUMBERED
,
1134 .procname
= "numa_zonelist_order",
1135 .data
= &numa_zonelist_order
,
1136 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1138 .proc_handler
= &numa_zonelist_order_handler
,
1139 .strategy
= &sysctl_string
,
1142 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1143 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1145 .ctl_name
= VM_VDSO_ENABLED
,
1146 .procname
= "vdso_enabled",
1147 .data
= &vdso_enabled
,
1148 .maxlen
= sizeof(vdso_enabled
),
1150 .proc_handler
= &proc_dointvec
,
1151 .strategy
= &sysctl_intvec
,
1156 * NOTE: do not add new entries to this table unless you have read
1157 * Documentation/sysctl/ctl_unnumbered.txt
1162 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1163 static struct ctl_table binfmt_misc_table
[] = {
1168 static struct ctl_table fs_table
[] = {
1170 .ctl_name
= FS_NRINODE
,
1171 .procname
= "inode-nr",
1172 .data
= &inodes_stat
,
1173 .maxlen
= 2*sizeof(int),
1175 .proc_handler
= &proc_dointvec
,
1178 .ctl_name
= FS_STATINODE
,
1179 .procname
= "inode-state",
1180 .data
= &inodes_stat
,
1181 .maxlen
= 7*sizeof(int),
1183 .proc_handler
= &proc_dointvec
,
1186 .procname
= "file-nr",
1187 .data
= &files_stat
,
1188 .maxlen
= 3*sizeof(int),
1190 .proc_handler
= &proc_nr_files
,
1193 .ctl_name
= FS_MAXFILE
,
1194 .procname
= "file-max",
1195 .data
= &files_stat
.max_files
,
1196 .maxlen
= sizeof(int),
1198 .proc_handler
= &proc_dointvec
,
1201 .ctl_name
= FS_DENTRY
,
1202 .procname
= "dentry-state",
1203 .data
= &dentry_stat
,
1204 .maxlen
= 6*sizeof(int),
1206 .proc_handler
= &proc_dointvec
,
1209 .ctl_name
= FS_OVERFLOWUID
,
1210 .procname
= "overflowuid",
1211 .data
= &fs_overflowuid
,
1212 .maxlen
= sizeof(int),
1214 .proc_handler
= &proc_dointvec_minmax
,
1215 .strategy
= &sysctl_intvec
,
1216 .extra1
= &minolduid
,
1217 .extra2
= &maxolduid
,
1220 .ctl_name
= FS_OVERFLOWGID
,
1221 .procname
= "overflowgid",
1222 .data
= &fs_overflowgid
,
1223 .maxlen
= sizeof(int),
1225 .proc_handler
= &proc_dointvec_minmax
,
1226 .strategy
= &sysctl_intvec
,
1227 .extra1
= &minolduid
,
1228 .extra2
= &maxolduid
,
1231 .ctl_name
= FS_LEASES
,
1232 .procname
= "leases-enable",
1233 .data
= &leases_enable
,
1234 .maxlen
= sizeof(int),
1236 .proc_handler
= &proc_dointvec
,
1238 #ifdef CONFIG_DNOTIFY
1240 .ctl_name
= FS_DIR_NOTIFY
,
1241 .procname
= "dir-notify-enable",
1242 .data
= &dir_notify_enable
,
1243 .maxlen
= sizeof(int),
1245 .proc_handler
= &proc_dointvec
,
1250 .ctl_name
= FS_LEASE_TIME
,
1251 .procname
= "lease-break-time",
1252 .data
= &lease_break_time
,
1253 .maxlen
= sizeof(int),
1255 .proc_handler
= &proc_dointvec_minmax
,
1256 .strategy
= &sysctl_intvec
,
1261 .procname
= "aio-nr",
1263 .maxlen
= sizeof(aio_nr
),
1265 .proc_handler
= &proc_doulongvec_minmax
,
1268 .procname
= "aio-max-nr",
1269 .data
= &aio_max_nr
,
1270 .maxlen
= sizeof(aio_max_nr
),
1272 .proc_handler
= &proc_doulongvec_minmax
,
1274 #ifdef CONFIG_INOTIFY_USER
1276 .ctl_name
= FS_INOTIFY
,
1277 .procname
= "inotify",
1279 .child
= inotify_table
,
1284 .ctl_name
= KERN_SETUID_DUMPABLE
,
1285 .procname
= "suid_dumpable",
1286 .data
= &suid_dumpable
,
1287 .maxlen
= sizeof(int),
1289 .proc_handler
= &proc_dointvec
,
1291 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1293 .ctl_name
= CTL_UNNUMBERED
,
1294 .procname
= "binfmt_misc",
1296 .child
= binfmt_misc_table
,
1300 * NOTE: do not add new entries to this table unless you have read
1301 * Documentation/sysctl/ctl_unnumbered.txt
1306 static struct ctl_table debug_table
[] = {
1307 #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1309 .ctl_name
= CTL_UNNUMBERED
,
1310 .procname
= "exception-trace",
1311 .data
= &show_unhandled_signals
,
1312 .maxlen
= sizeof(int),
1314 .proc_handler
= proc_dointvec
1320 static struct ctl_table dev_table
[] = {
1324 static DEFINE_SPINLOCK(sysctl_lock
);
1326 /* called under sysctl_lock */
1327 static int use_table(struct ctl_table_header
*p
)
1329 if (unlikely(p
->unregistering
))
1335 /* called under sysctl_lock */
1336 static void unuse_table(struct ctl_table_header
*p
)
1339 if (unlikely(p
->unregistering
))
1340 complete(p
->unregistering
);
1343 /* called under sysctl_lock, will reacquire if has to wait */
1344 static void start_unregistering(struct ctl_table_header
*p
)
1347 * if p->used is 0, nobody will ever touch that entry again;
1348 * we'll eliminate all paths to it before dropping sysctl_lock
1350 if (unlikely(p
->used
)) {
1351 struct completion wait
;
1352 init_completion(&wait
);
1353 p
->unregistering
= &wait
;
1354 spin_unlock(&sysctl_lock
);
1355 wait_for_completion(&wait
);
1356 spin_lock(&sysctl_lock
);
1359 * do not remove from the list until nobody holds it; walking the
1360 * list in do_sysctl() relies on that.
1362 list_del_init(&p
->ctl_entry
);
1365 void sysctl_head_finish(struct ctl_table_header
*head
)
1369 spin_lock(&sysctl_lock
);
1371 spin_unlock(&sysctl_lock
);
1374 struct ctl_table_header
*sysctl_head_next(struct ctl_table_header
*prev
)
1376 struct ctl_table_header
*head
;
1377 struct list_head
*tmp
;
1378 spin_lock(&sysctl_lock
);
1380 tmp
= &prev
->ctl_entry
;
1384 tmp
= &root_table_header
.ctl_entry
;
1386 head
= list_entry(tmp
, struct ctl_table_header
, ctl_entry
);
1388 if (!use_table(head
))
1390 spin_unlock(&sysctl_lock
);
1394 if (tmp
== &root_table_header
.ctl_entry
)
1397 spin_unlock(&sysctl_lock
);
1401 #ifdef CONFIG_SYSCTL_SYSCALL
1402 int do_sysctl(int __user
*name
, int nlen
, void __user
*oldval
, size_t __user
*oldlenp
,
1403 void __user
*newval
, size_t newlen
)
1405 struct ctl_table_header
*head
;
1406 int error
= -ENOTDIR
;
1408 if (nlen
<= 0 || nlen
>= CTL_MAXNAME
)
1412 if (!oldlenp
|| get_user(old_len
, oldlenp
))
1416 for (head
= sysctl_head_next(NULL
); head
;
1417 head
= sysctl_head_next(head
)) {
1418 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
1419 newval
, newlen
, head
->ctl_table
);
1420 if (error
!= -ENOTDIR
) {
1421 sysctl_head_finish(head
);
1428 asmlinkage
long sys_sysctl(struct __sysctl_args __user
*args
)
1430 struct __sysctl_args tmp
;
1433 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
1436 error
= deprecated_sysctl_warning(&tmp
);
1441 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
1442 tmp
.newval
, tmp
.newlen
);
1447 #endif /* CONFIG_SYSCTL_SYSCALL */
1450 * sysctl_perm does NOT grant the superuser all rights automatically, because
1451 * some sysctl variables are readonly even to root.
1454 static int test_perm(int mode
, int op
)
1458 else if (in_egroup_p(0))
1460 if ((mode
& op
& 0007) == op
)
1465 int sysctl_perm(struct ctl_table
*table
, int op
)
1468 error
= security_sysctl(table
, op
);
1471 return test_perm(table
->mode
, op
);
1474 #ifdef CONFIG_SYSCTL_SYSCALL
1475 static int parse_table(int __user
*name
, int nlen
,
1476 void __user
*oldval
, size_t __user
*oldlenp
,
1477 void __user
*newval
, size_t newlen
,
1478 struct ctl_table
*table
)
1484 if (get_user(n
, name
))
1486 for ( ; table
->ctl_name
|| table
->procname
; table
++) {
1487 if (!table
->ctl_name
)
1489 if (n
== table
->ctl_name
) {
1492 if (sysctl_perm(table
, 001))
1496 table
= table
->child
;
1499 error
= do_sysctl_strategy(table
, name
, nlen
,
1508 /* Perform the actual read/write of a sysctl table entry. */
1509 int do_sysctl_strategy (struct ctl_table
*table
,
1510 int __user
*name
, int nlen
,
1511 void __user
*oldval
, size_t __user
*oldlenp
,
1512 void __user
*newval
, size_t newlen
)
1520 if (sysctl_perm(table
, op
))
1523 if (table
->strategy
) {
1524 rc
= table
->strategy(table
, name
, nlen
, oldval
, oldlenp
,
1532 /* If there is no strategy routine, or if the strategy returns
1533 * zero, proceed with automatic r/w */
1534 if (table
->data
&& table
->maxlen
) {
1535 rc
= sysctl_data(table
, name
, nlen
, oldval
, oldlenp
,
1542 #endif /* CONFIG_SYSCTL_SYSCALL */
1544 static void sysctl_set_parent(struct ctl_table
*parent
, struct ctl_table
*table
)
1546 for (; table
->ctl_name
|| table
->procname
; table
++) {
1547 table
->parent
= parent
;
1549 sysctl_set_parent(table
, table
->child
);
1553 static __init
int sysctl_init(void)
1556 sysctl_set_parent(NULL
, root_table
);
1557 err
= sysctl_check_table(root_table
);
1561 core_initcall(sysctl_init
);
1564 * register_sysctl_table - register a sysctl hierarchy
1565 * @table: the top-level table structure
1567 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1568 * array. An entry with a ctl_name of 0 terminates the table.
1570 * The members of the &struct ctl_table structure are used as follows:
1572 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1573 * must be unique within that level of sysctl
1575 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1576 * enter a sysctl file
1578 * data - a pointer to data for use by proc_handler
1580 * maxlen - the maximum size in bytes of the data
1582 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1584 * child - a pointer to the child sysctl table if this entry is a directory, or
1587 * proc_handler - the text handler routine (described below)
1589 * strategy - the strategy routine (described below)
1591 * de - for internal use by the sysctl routines
1593 * extra1, extra2 - extra pointers usable by the proc handler routines
1595 * Leaf nodes in the sysctl tree will be represented by a single file
1596 * under /proc; non-leaf nodes will be represented by directories.
1598 * sysctl(2) can automatically manage read and write requests through
1599 * the sysctl table. The data and maxlen fields of the ctl_table
1600 * struct enable minimal validation of the values being written to be
1601 * performed, and the mode field allows minimal authentication.
1603 * More sophisticated management can be enabled by the provision of a
1604 * strategy routine with the table entry. This will be called before
1605 * any automatic read or write of the data is performed.
1607 * The strategy routine may return
1609 * < 0 - Error occurred (error is passed to user process)
1611 * 0 - OK - proceed with automatic read or write.
1613 * > 0 - OK - read or write has been done by the strategy routine, so
1614 * return immediately.
1616 * There must be a proc_handler routine for any terminal nodes
1617 * mirrored under /proc/sys (non-terminals are handled by a built-in
1618 * directory handler). Several default handlers are available to
1619 * cover common cases -
1621 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1622 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1623 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1625 * It is the handler's job to read the input buffer from user memory
1626 * and process it. The handler should return 0 on success.
1628 * This routine returns %NULL on a failure to register, and a pointer
1629 * to the table header on success.
1631 struct ctl_table_header
*register_sysctl_table(struct ctl_table
* table
)
1633 struct ctl_table_header
*tmp
;
1634 tmp
= kmalloc(sizeof(struct ctl_table_header
), GFP_KERNEL
);
1637 tmp
->ctl_table
= table
;
1638 INIT_LIST_HEAD(&tmp
->ctl_entry
);
1640 tmp
->unregistering
= NULL
;
1641 sysctl_set_parent(NULL
, table
);
1642 if (sysctl_check_table(tmp
->ctl_table
)) {
1646 spin_lock(&sysctl_lock
);
1647 list_add_tail(&tmp
->ctl_entry
, &root_table_header
.ctl_entry
);
1648 spin_unlock(&sysctl_lock
);
1653 * unregister_sysctl_table - unregister a sysctl table hierarchy
1654 * @header: the header returned from register_sysctl_table
1656 * Unregisters the sysctl table and all children. proc entries may not
1657 * actually be removed until they are no longer used by anyone.
1659 void unregister_sysctl_table(struct ctl_table_header
* header
)
1666 spin_lock(&sysctl_lock
);
1667 start_unregistering(header
);
1668 spin_unlock(&sysctl_lock
);
1672 #else /* !CONFIG_SYSCTL */
1673 struct ctl_table_header
*register_sysctl_table(struct ctl_table
* table
)
1678 void unregister_sysctl_table(struct ctl_table_header
* table
)
1682 #endif /* CONFIG_SYSCTL */
1688 #ifdef CONFIG_PROC_SYSCTL
1690 static int _proc_do_string(void* data
, int maxlen
, int write
,
1691 struct file
*filp
, void __user
*buffer
,
1692 size_t *lenp
, loff_t
*ppos
)
1698 if (!data
|| !maxlen
|| !*lenp
) {
1706 while (len
< *lenp
) {
1707 if (get_user(c
, p
++))
1709 if (c
== 0 || c
== '\n')
1715 if(copy_from_user(data
, buffer
, len
))
1717 ((char *) data
)[len
] = 0;
1735 if(copy_to_user(buffer
, data
, len
))
1738 if(put_user('\n', ((char __user
*) buffer
) + len
))
1749 * proc_dostring - read a string sysctl
1750 * @table: the sysctl table
1751 * @write: %TRUE if this is a write to the sysctl file
1752 * @filp: the file structure
1753 * @buffer: the user buffer
1754 * @lenp: the size of the user buffer
1755 * @ppos: file position
1757 * Reads/writes a string from/to the user buffer. If the kernel
1758 * buffer provided is not large enough to hold the string, the
1759 * string is truncated. The copied string is %NULL-terminated.
1760 * If the string is being read by the user process, it is copied
1761 * and a newline '\n' is added. It is truncated if the buffer is
1764 * Returns 0 on success.
1766 int proc_dostring(struct ctl_table
*table
, int write
, struct file
*filp
,
1767 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1769 return _proc_do_string(table
->data
, table
->maxlen
, write
, filp
,
1770 buffer
, lenp
, ppos
);
1774 static int do_proc_dointvec_conv(int *negp
, unsigned long *lvalp
,
1776 int write
, void *data
)
1779 *valp
= *negp
? -*lvalp
: *lvalp
;
1784 *lvalp
= (unsigned long)-val
;
1787 *lvalp
= (unsigned long)val
;
1793 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
1794 int write
, struct file
*filp
, void __user
*buffer
,
1795 size_t *lenp
, loff_t
*ppos
,
1796 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
1797 int write
, void *data
),
1800 #define TMPBUFLEN 21
1801 int *i
, vleft
, first
=1, neg
, val
;
1805 char buf
[TMPBUFLEN
], *p
;
1806 char __user
*s
= buffer
;
1808 if (!tbl_data
|| !table
->maxlen
|| !*lenp
||
1809 (*ppos
&& !write
)) {
1814 i
= (int *) tbl_data
;
1815 vleft
= table
->maxlen
/ sizeof(*i
);
1819 conv
= do_proc_dointvec_conv
;
1821 for (; left
&& vleft
--; i
++, first
=0) {
1836 if (len
> sizeof(buf
) - 1)
1837 len
= sizeof(buf
) - 1;
1838 if (copy_from_user(buf
, s
, len
))
1842 if (*p
== '-' && left
> 1) {
1846 if (*p
< '0' || *p
> '9')
1849 lval
= simple_strtoul(p
, &p
, 0);
1852 if ((len
< left
) && *p
&& !isspace(*p
))
1859 if (conv(&neg
, &lval
, i
, 1, data
))
1866 if (conv(&neg
, &lval
, i
, 0, data
))
1869 sprintf(p
, "%s%lu", neg
? "-" : "", lval
);
1873 if(copy_to_user(s
, buf
, len
))
1880 if (!write
&& !first
&& left
) {
1881 if(put_user('\n', s
))
1888 if (get_user(c
, s
++))
1903 static int do_proc_dointvec(struct ctl_table
*table
, int write
, struct file
*filp
,
1904 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
1905 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
1906 int write
, void *data
),
1909 return __do_proc_dointvec(table
->data
, table
, write
, filp
,
1910 buffer
, lenp
, ppos
, conv
, data
);
1914 * proc_dointvec - read a vector of integers
1915 * @table: the sysctl table
1916 * @write: %TRUE if this is a write to the sysctl file
1917 * @filp: the file structure
1918 * @buffer: the user buffer
1919 * @lenp: the size of the user buffer
1920 * @ppos: file position
1922 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1923 * values from/to the user buffer, treated as an ASCII string.
1925 * Returns 0 on success.
1927 int proc_dointvec(struct ctl_table
*table
, int write
, struct file
*filp
,
1928 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1930 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1938 static int do_proc_dointvec_bset_conv(int *negp
, unsigned long *lvalp
,
1940 int write
, void *data
)
1942 int op
= *(int *)data
;
1944 int val
= *negp
? -*lvalp
: *lvalp
;
1946 case OP_SET
: *valp
= val
; break;
1947 case OP_AND
: *valp
&= val
; break;
1948 case OP_OR
: *valp
|= val
; break;
1954 *lvalp
= (unsigned long)-val
;
1957 *lvalp
= (unsigned long)val
;
1963 #ifdef CONFIG_SECURITY_CAPABILITIES
1965 * init may raise the set.
1968 int proc_dointvec_bset(struct ctl_table
*table
, int write
, struct file
*filp
,
1969 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1973 if (write
&& !capable(CAP_SYS_MODULE
)) {
1977 op
= is_global_init(current
) ? OP_SET
: OP_AND
;
1978 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1979 do_proc_dointvec_bset_conv
,&op
);
1981 #endif /* def CONFIG_SECURITY_CAPABILITIES */
1984 * Taint values can only be increased
1986 static int proc_dointvec_taint(struct ctl_table
*table
, int write
, struct file
*filp
,
1987 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1991 if (write
&& !capable(CAP_SYS_ADMIN
))
1995 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
1996 do_proc_dointvec_bset_conv
,&op
);
1999 struct do_proc_dointvec_minmax_conv_param
{
2004 static int do_proc_dointvec_minmax_conv(int *negp
, unsigned long *lvalp
,
2006 int write
, void *data
)
2008 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2010 int val
= *negp
? -*lvalp
: *lvalp
;
2011 if ((param
->min
&& *param
->min
> val
) ||
2012 (param
->max
&& *param
->max
< val
))
2019 *lvalp
= (unsigned long)-val
;
2022 *lvalp
= (unsigned long)val
;
2029 * proc_dointvec_minmax - read a vector of integers with min/max values
2030 * @table: the sysctl table
2031 * @write: %TRUE if this is a write to the sysctl file
2032 * @filp: the file structure
2033 * @buffer: the user buffer
2034 * @lenp: the size of the user buffer
2035 * @ppos: file position
2037 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2038 * values from/to the user buffer, treated as an ASCII string.
2040 * This routine will ensure the values are within the range specified by
2041 * table->extra1 (min) and table->extra2 (max).
2043 * Returns 0 on success.
2045 int proc_dointvec_minmax(struct ctl_table
*table
, int write
, struct file
*filp
,
2046 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2048 struct do_proc_dointvec_minmax_conv_param param
= {
2049 .min
= (int *) table
->extra1
,
2050 .max
= (int *) table
->extra2
,
2052 return do_proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
,
2053 do_proc_dointvec_minmax_conv
, ¶m
);
2056 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2058 void __user
*buffer
,
2059 size_t *lenp
, loff_t
*ppos
,
2060 unsigned long convmul
,
2061 unsigned long convdiv
)
2063 #define TMPBUFLEN 21
2064 unsigned long *i
, *min
, *max
, val
;
2065 int vleft
, first
=1, neg
;
2067 char buf
[TMPBUFLEN
], *p
;
2068 char __user
*s
= buffer
;
2070 if (!data
|| !table
->maxlen
|| !*lenp
||
2071 (*ppos
&& !write
)) {
2076 i
= (unsigned long *) data
;
2077 min
= (unsigned long *) table
->extra1
;
2078 max
= (unsigned long *) table
->extra2
;
2079 vleft
= table
->maxlen
/ sizeof(unsigned long);
2082 for (; left
&& vleft
--; i
++, min
++, max
++, first
=0) {
2097 if (len
> TMPBUFLEN
-1)
2099 if (copy_from_user(buf
, s
, len
))
2103 if (*p
== '-' && left
> 1) {
2107 if (*p
< '0' || *p
> '9')
2109 val
= simple_strtoul(p
, &p
, 0) * convmul
/ convdiv
;
2111 if ((len
< left
) && *p
&& !isspace(*p
))
2120 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2127 sprintf(p
, "%lu", convdiv
* (*i
) / convmul
);
2131 if(copy_to_user(s
, buf
, len
))
2138 if (!write
&& !first
&& left
) {
2139 if(put_user('\n', s
))
2146 if (get_user(c
, s
++))
2161 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2163 void __user
*buffer
,
2164 size_t *lenp
, loff_t
*ppos
,
2165 unsigned long convmul
,
2166 unsigned long convdiv
)
2168 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2169 filp
, buffer
, lenp
, ppos
, convmul
, convdiv
);
2173 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2174 * @table: the sysctl table
2175 * @write: %TRUE if this is a write to the sysctl file
2176 * @filp: the file structure
2177 * @buffer: the user buffer
2178 * @lenp: the size of the user buffer
2179 * @ppos: file position
2181 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2182 * values from/to the user buffer, treated as an ASCII string.
2184 * This routine will ensure the values are within the range specified by
2185 * table->extra1 (min) and table->extra2 (max).
2187 * Returns 0 on success.
2189 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
, struct file
*filp
,
2190 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2192 return do_proc_doulongvec_minmax(table
, write
, filp
, buffer
, lenp
, ppos
, 1l, 1l);
2196 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2197 * @table: the sysctl table
2198 * @write: %TRUE if this is a write to the sysctl file
2199 * @filp: the file structure
2200 * @buffer: the user buffer
2201 * @lenp: the size of the user buffer
2202 * @ppos: file position
2204 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2205 * values from/to the user buffer, treated as an ASCII string. The values
2206 * are treated as milliseconds, and converted to jiffies when they are stored.
2208 * This routine will ensure the values are within the range specified by
2209 * table->extra1 (min) and table->extra2 (max).
2211 * Returns 0 on success.
2213 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2215 void __user
*buffer
,
2216 size_t *lenp
, loff_t
*ppos
)
2218 return do_proc_doulongvec_minmax(table
, write
, filp
, buffer
,
2219 lenp
, ppos
, HZ
, 1000l);
2223 static int do_proc_dointvec_jiffies_conv(int *negp
, unsigned long *lvalp
,
2225 int write
, void *data
)
2228 if (*lvalp
> LONG_MAX
/ HZ
)
2230 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2236 lval
= (unsigned long)-val
;
2239 lval
= (unsigned long)val
;
2246 static int do_proc_dointvec_userhz_jiffies_conv(int *negp
, unsigned long *lvalp
,
2248 int write
, void *data
)
2251 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2253 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2259 lval
= (unsigned long)-val
;
2262 lval
= (unsigned long)val
;
2264 *lvalp
= jiffies_to_clock_t(lval
);
2269 static int do_proc_dointvec_ms_jiffies_conv(int *negp
, unsigned long *lvalp
,
2271 int write
, void *data
)
2274 *valp
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2280 lval
= (unsigned long)-val
;
2283 lval
= (unsigned long)val
;
2285 *lvalp
= jiffies_to_msecs(lval
);
2291 * proc_dointvec_jiffies - read a vector of integers as seconds
2292 * @table: the sysctl table
2293 * @write: %TRUE if this is a write to the sysctl file
2294 * @filp: the file structure
2295 * @buffer: the user buffer
2296 * @lenp: the size of the user buffer
2297 * @ppos: file position
2299 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2300 * values from/to the user buffer, treated as an ASCII string.
2301 * The values read are assumed to be in seconds, and are converted into
2304 * Returns 0 on success.
2306 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
, struct file
*filp
,
2307 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2309 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2310 do_proc_dointvec_jiffies_conv
,NULL
);
2314 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2315 * @table: the sysctl table
2316 * @write: %TRUE if this is a write to the sysctl file
2317 * @filp: the file structure
2318 * @buffer: the user buffer
2319 * @lenp: the size of the user buffer
2320 * @ppos: pointer to the file position
2322 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2323 * values from/to the user buffer, treated as an ASCII string.
2324 * The values read are assumed to be in 1/USER_HZ seconds, and
2325 * are converted into jiffies.
2327 * Returns 0 on success.
2329 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
, struct file
*filp
,
2330 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2332 return do_proc_dointvec(table
,write
,filp
,buffer
,lenp
,ppos
,
2333 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2337 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2338 * @table: the sysctl table
2339 * @write: %TRUE if this is a write to the sysctl file
2340 * @filp: the file structure
2341 * @buffer: the user buffer
2342 * @lenp: the size of the user buffer
2343 * @ppos: file position
2344 * @ppos: the current position in the file
2346 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2347 * values from/to the user buffer, treated as an ASCII string.
2348 * The values read are assumed to be in 1/1000 seconds, and
2349 * are converted into jiffies.
2351 * Returns 0 on success.
2353 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
, struct file
*filp
,
2354 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2356 return do_proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
,
2357 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2360 static int proc_do_cad_pid(struct ctl_table
*table
, int write
, struct file
*filp
,
2361 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2363 struct pid
*new_pid
;
2367 tmp
= pid_nr_ns(cad_pid
, current
->nsproxy
->pid_ns
);
2369 r
= __do_proc_dointvec(&tmp
, table
, write
, filp
, buffer
,
2370 lenp
, ppos
, NULL
, NULL
);
2374 new_pid
= find_get_pid(tmp
);
2378 put_pid(xchg(&cad_pid
, new_pid
));
2382 #else /* CONFIG_PROC_FS */
2384 int proc_dostring(struct ctl_table
*table
, int write
, struct file
*filp
,
2385 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2390 int proc_dointvec(struct ctl_table
*table
, int write
, struct file
*filp
,
2391 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2396 int proc_dointvec_bset(struct ctl_table
*table
, int write
, struct file
*filp
,
2397 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2402 int proc_dointvec_minmax(struct ctl_table
*table
, int write
, struct file
*filp
,
2403 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2408 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
, struct file
*filp
,
2409 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2414 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
, struct file
*filp
,
2415 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2420 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
, struct file
*filp
,
2421 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2426 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
, struct file
*filp
,
2427 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2432 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2434 void __user
*buffer
,
2435 size_t *lenp
, loff_t
*ppos
)
2441 #endif /* CONFIG_PROC_FS */
2444 #ifdef CONFIG_SYSCTL_SYSCALL
2446 * General sysctl support routines
2449 /* The generic sysctl data routine (used if no strategy routine supplied) */
2450 int sysctl_data(struct ctl_table
*table
, int __user
*name
, int nlen
,
2451 void __user
*oldval
, size_t __user
*oldlenp
,
2452 void __user
*newval
, size_t newlen
)
2456 /* Get out of I don't have a variable */
2457 if (!table
->data
|| !table
->maxlen
)
2460 if (oldval
&& oldlenp
) {
2461 if (get_user(len
, oldlenp
))
2464 if (len
> table
->maxlen
)
2465 len
= table
->maxlen
;
2466 if (copy_to_user(oldval
, table
->data
, len
))
2468 if (put_user(len
, oldlenp
))
2473 if (newval
&& newlen
) {
2474 if (newlen
> table
->maxlen
)
2475 newlen
= table
->maxlen
;
2477 if (copy_from_user(table
->data
, newval
, newlen
))
2483 /* The generic string strategy routine: */
2484 int sysctl_string(struct ctl_table
*table
, int __user
*name
, int nlen
,
2485 void __user
*oldval
, size_t __user
*oldlenp
,
2486 void __user
*newval
, size_t newlen
)
2488 if (!table
->data
|| !table
->maxlen
)
2491 if (oldval
&& oldlenp
) {
2493 if (get_user(bufsize
, oldlenp
))
2496 size_t len
= strlen(table
->data
), copied
;
2498 /* This shouldn't trigger for a well-formed sysctl */
2499 if (len
> table
->maxlen
)
2500 len
= table
->maxlen
;
2502 /* Copy up to a max of bufsize-1 bytes of the string */
2503 copied
= (len
>= bufsize
) ? bufsize
- 1 : len
;
2505 if (copy_to_user(oldval
, table
->data
, copied
) ||
2506 put_user(0, (char __user
*)(oldval
+ copied
)))
2508 if (put_user(len
, oldlenp
))
2512 if (newval
&& newlen
) {
2513 size_t len
= newlen
;
2514 if (len
> table
->maxlen
)
2515 len
= table
->maxlen
;
2516 if(copy_from_user(table
->data
, newval
, len
))
2518 if (len
== table
->maxlen
)
2520 ((char *) table
->data
)[len
] = 0;
2526 * This function makes sure that all of the integers in the vector
2527 * are between the minimum and maximum values given in the arrays
2528 * table->extra1 and table->extra2, respectively.
2530 int sysctl_intvec(struct ctl_table
*table
, int __user
*name
, int nlen
,
2531 void __user
*oldval
, size_t __user
*oldlenp
,
2532 void __user
*newval
, size_t newlen
)
2535 if (newval
&& newlen
) {
2536 int __user
*vec
= (int __user
*) newval
;
2537 int *min
= (int *) table
->extra1
;
2538 int *max
= (int *) table
->extra2
;
2542 if (newlen
% sizeof(int) != 0)
2545 if (!table
->extra1
&& !table
->extra2
)
2548 if (newlen
> table
->maxlen
)
2549 newlen
= table
->maxlen
;
2550 length
= newlen
/ sizeof(int);
2552 for (i
= 0; i
< length
; i
++) {
2554 if (get_user(value
, vec
+ i
))
2556 if (min
&& value
< min
[i
])
2558 if (max
&& value
> max
[i
])
2565 /* Strategy function to convert jiffies to seconds */
2566 int sysctl_jiffies(struct ctl_table
*table
, int __user
*name
, int nlen
,
2567 void __user
*oldval
, size_t __user
*oldlenp
,
2568 void __user
*newval
, size_t newlen
)
2570 if (oldval
&& oldlenp
) {
2573 if (get_user(olen
, oldlenp
))
2578 if (olen
< sizeof(int))
2581 val
= *(int *)(table
->data
) / HZ
;
2582 if (put_user(val
, (int __user
*)oldval
))
2584 if (put_user(sizeof(int), oldlenp
))
2588 if (newval
&& newlen
) {
2590 if (newlen
!= sizeof(int))
2592 if (get_user(new, (int __user
*)newval
))
2594 *(int *)(table
->data
) = new*HZ
;
2599 /* Strategy function to convert jiffies to seconds */
2600 int sysctl_ms_jiffies(struct ctl_table
*table
, int __user
*name
, int nlen
,
2601 void __user
*oldval
, size_t __user
*oldlenp
,
2602 void __user
*newval
, size_t newlen
)
2604 if (oldval
&& oldlenp
) {
2607 if (get_user(olen
, oldlenp
))
2612 if (olen
< sizeof(int))
2615 val
= jiffies_to_msecs(*(int *)(table
->data
));
2616 if (put_user(val
, (int __user
*)oldval
))
2618 if (put_user(sizeof(int), oldlenp
))
2622 if (newval
&& newlen
) {
2624 if (newlen
!= sizeof(int))
2626 if (get_user(new, (int __user
*)newval
))
2628 *(int *)(table
->data
) = msecs_to_jiffies(new);
2635 #else /* CONFIG_SYSCTL_SYSCALL */
2638 asmlinkage
long sys_sysctl(struct __sysctl_args __user
*args
)
2640 struct __sysctl_args tmp
;
2643 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
2646 error
= deprecated_sysctl_warning(&tmp
);
2648 /* If no error reading the parameters then just -ENOSYS ... */
2655 int sysctl_data(struct ctl_table
*table
, int __user
*name
, int nlen
,
2656 void __user
*oldval
, size_t __user
*oldlenp
,
2657 void __user
*newval
, size_t newlen
)
2662 int sysctl_string(struct ctl_table
*table
, int __user
*name
, int nlen
,
2663 void __user
*oldval
, size_t __user
*oldlenp
,
2664 void __user
*newval
, size_t newlen
)
2669 int sysctl_intvec(struct ctl_table
*table
, int __user
*name
, int nlen
,
2670 void __user
*oldval
, size_t __user
*oldlenp
,
2671 void __user
*newval
, size_t newlen
)
2676 int sysctl_jiffies(struct ctl_table
*table
, int __user
*name
, int nlen
,
2677 void __user
*oldval
, size_t __user
*oldlenp
,
2678 void __user
*newval
, size_t newlen
)
2683 int sysctl_ms_jiffies(struct ctl_table
*table
, int __user
*name
, int nlen
,
2684 void __user
*oldval
, size_t __user
*oldlenp
,
2685 void __user
*newval
, size_t newlen
)
2690 #endif /* CONFIG_SYSCTL_SYSCALL */
2692 static int deprecated_sysctl_warning(struct __sysctl_args
*args
)
2694 static int msg_count
;
2695 int name
[CTL_MAXNAME
];
2698 /* Check args->nlen. */
2699 if (args
->nlen
< 0 || args
->nlen
> CTL_MAXNAME
)
2702 /* Read in the sysctl name for better debug message logging */
2703 for (i
= 0; i
< args
->nlen
; i
++)
2704 if (get_user(name
[i
], args
->name
+ i
))
2707 /* Ignore accesses to kernel.version */
2708 if ((args
->nlen
== 2) && (name
[0] == CTL_KERN
) && (name
[1] == KERN_VERSION
))
2711 if (msg_count
< 5) {
2714 "warning: process `%s' used the deprecated sysctl "
2715 "system call with ", current
->comm
);
2716 for (i
= 0; i
< args
->nlen
; i
++)
2717 printk("%d.", name
[i
]);
2724 * No sense putting this after each symbol definition, twice,
2725 * exception granted :-)
2727 EXPORT_SYMBOL(proc_dointvec
);
2728 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2729 EXPORT_SYMBOL(proc_dointvec_minmax
);
2730 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2731 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2732 EXPORT_SYMBOL(proc_dostring
);
2733 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2734 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);
2735 EXPORT_SYMBOL(register_sysctl_table
);
2736 EXPORT_SYMBOL(sysctl_intvec
);
2737 EXPORT_SYMBOL(sysctl_jiffies
);
2738 EXPORT_SYMBOL(sysctl_ms_jiffies
);
2739 EXPORT_SYMBOL(sysctl_string
);
2740 EXPORT_SYMBOL(sysctl_data
);
2741 EXPORT_SYMBOL(unregister_sysctl_table
);