21 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/sysctl.h>
26 #include <linux/bitmap.h>
27 #include <linux/signal.h>
31 #include <linux/ctype.h>
36 #include <linux/kernel.h>
38 #include <linux/net.h>
53 #include <linux/nfs_fs.h>
55 #include <linux/reboot.h>
57 #include <linux/perf_event.h>
60 #include <linux/oom.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
65 #include <asm/uaccess.h>
66 #include <asm/processor.h>
70 #include <asm/stacktrace.h>
74 #include <asm/setup.h>
76 #ifdef CONFIG_BSD_PROCESS_ACCT
77 #include <linux/acct.h>
79 #ifdef CONFIG_RT_MUTEXES
82 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
85 #ifdef CONFIG_CHR_DEV_SG
89 #ifdef CONFIG_LOCKUP_DETECTOR
94 #if defined(CONFIG_SYSCTL)
101 #ifdef CONFIG_COREDUMP
122 #ifdef CONFIG_LOCKUP_DETECTOR
123 static int sixty = 60;
124 static int neg_one = -1;
131 static unsigned long one_ul = 1;
132 static int one_hundred = 100;
134 static int ten_thousand = 10000;
138 static unsigned long dirty_bytes_min = 2 *
PAGE_SIZE;
141 static int maxolduid = 65535;
142 static int minolduid;
143 static int min_percpu_pagelist_fract = 8;
148 #ifdef CONFIG_INOTIFY_USER
149 #include <linux/inotify.h>
154 #ifdef CONFIG_SPARC64
159 extern int pwrsw_enabled;
160 extern int unaligned_enabled;
168 #ifdef CONFIG_PROC_SYSCTL
170 void __user *
buffer,
size_t *lenp, loff_t *ppos);
172 void __user *
buffer,
size_t *lenp, loff_t *ppos);
177 void __user *
buffer,
size_t *lenp, loff_t *ppos);
181 void __user *
buffer,
size_t *lenp, loff_t *ppos);
182 #ifdef CONFIG_COREDUMP
184 void __user *
buffer,
size_t *lenp, loff_t *ppos);
187 #ifdef CONFIG_MAGIC_SYSRQ
192 void __user *
buffer,
size_t *lenp,
219 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
225 static struct ctl_table sysctl_base_table[] = {
244 .child = debug_table,
254 #ifdef CONFIG_SCHED_DEBUG
255 static int min_sched_granularity_ns = 100000;
257 static int min_wakeup_granularity_ns;
263 #ifdef CONFIG_COMPACTION
264 static int min_extfrag_threshold;
265 static int max_extfrag_threshold = 1000;
270 .
procname =
"sched_child_runs_first",
272 .maxlen =
sizeof(
unsigned int),
276 #ifdef CONFIG_SCHED_DEBUG
278 .procname =
"sched_min_granularity_ns",
280 .maxlen =
sizeof(
unsigned int),
283 .
extra1 = &min_sched_granularity_ns,
284 .
extra2 = &max_sched_granularity_ns,
287 .procname =
"sched_latency_ns",
289 .maxlen =
sizeof(
unsigned int),
292 .
extra1 = &min_sched_granularity_ns,
293 .
extra2 = &max_sched_granularity_ns,
296 .procname =
"sched_wakeup_granularity_ns",
298 .maxlen =
sizeof(
unsigned int),
301 .
extra1 = &min_wakeup_granularity_ns,
302 .
extra2 = &max_wakeup_granularity_ns,
305 .procname =
"sched_tunable_scaling",
310 .
extra1 = &min_sched_tunable_scaling,
311 .
extra2 = &max_sched_tunable_scaling,
314 .procname =
"sched_migration_cost_ns",
316 .maxlen =
sizeof(
unsigned int),
321 .procname =
"sched_nr_migrate",
323 .maxlen =
sizeof(
unsigned int),
328 .procname =
"sched_time_avg_ms",
330 .maxlen =
sizeof(
unsigned int),
335 .procname =
"sched_shares_window_ns",
337 .maxlen =
sizeof(
unsigned int),
342 .procname =
"timer_migration",
344 .maxlen =
sizeof(
unsigned int),
352 .procname =
"sched_rt_period_us",
354 .maxlen =
sizeof(
unsigned int),
359 .procname =
"sched_rt_runtime_us",
361 .maxlen =
sizeof(
int),
365 #ifdef CONFIG_SCHED_AUTOGROUP
367 .procname =
"sched_autogroup_enabled",
368 .data = &sysctl_sched_autogroup_enabled,
369 .maxlen =
sizeof(
unsigned int),
376 #ifdef CONFIG_CFS_BANDWIDTH
378 .procname =
"sched_cfs_bandwidth_slice_us",
379 .data = &sysctl_sched_cfs_bandwidth_slice,
380 .maxlen =
sizeof(
unsigned int),
386 #ifdef CONFIG_PROVE_LOCKING
388 .procname =
"prove_locking",
390 .maxlen =
sizeof(
int),
395 #ifdef CONFIG_LOCK_STAT
397 .procname =
"lock_stat",
399 .maxlen =
sizeof(
int),
407 .maxlen =
sizeof(
int),
411 #ifdef CONFIG_COREDUMP
413 .procname =
"core_uses_pid",
415 .maxlen =
sizeof(
int),
420 .procname =
"core_pattern",
424 .proc_handler = proc_dostring_coredump,
427 .procname =
"core_pipe_limit",
429 .maxlen =
sizeof(
unsigned int),
434 #ifdef CONFIG_PROC_SYSCTL
436 .procname =
"tainted",
437 .maxlen =
sizeof(
long),
442 #ifdef CONFIG_LATENCYTOP
444 .procname =
"latencytop",
446 .maxlen =
sizeof(
int),
451 #ifdef CONFIG_BLK_DEV_INITRD
453 .procname =
"real-root-dev",
455 .maxlen =
sizeof(
int),
461 .procname =
"print-fatal-signals",
463 .maxlen =
sizeof(
int),
469 .procname =
"reboot-cmd",
476 .procname =
"stop-a",
478 .maxlen =
sizeof (
int),
483 .procname =
"scons-poweroff",
485 .maxlen =
sizeof (
int),
490 #ifdef CONFIG_SPARC64
492 .procname =
"tsb-ratio",
494 .maxlen =
sizeof (
int),
501 .procname =
"soft-power",
502 .data = &pwrsw_enabled,
503 .maxlen =
sizeof (
int),
508 .procname =
"unaligned-trap",
509 .data = &unaligned_enabled,
510 .maxlen =
sizeof (
int),
516 .procname =
"ctrl-alt-del",
518 .maxlen =
sizeof(
int),
522 #ifdef CONFIG_FUNCTION_TRACER
524 .procname =
"ftrace_enabled",
525 .data = &ftrace_enabled,
526 .maxlen =
sizeof(
int),
531 #ifdef CONFIG_STACK_TRACER
533 .procname =
"stack_tracer_enabled",
535 .maxlen =
sizeof(
int),
540 #ifdef CONFIG_TRACING
542 .procname =
"ftrace_dump_on_oops",
544 .maxlen =
sizeof(
int),
549 #ifdef CONFIG_MODULES
551 .procname =
"modprobe",
552 .data = &modprobe_path,
558 .procname =
"modules_disabled",
560 .maxlen =
sizeof(
int),
568 #ifdef CONFIG_HOTPLUG
570 .procname =
"hotplug",
577 #ifdef CONFIG_CHR_DEV_SG
579 .procname =
"sg-big-buff",
581 .maxlen =
sizeof (
int),
586 #ifdef CONFIG_BSD_PROCESS_ACCT
590 .maxlen = 3*
sizeof(
int),
595 #ifdef CONFIG_MAGIC_SYSRQ
598 .data = &__sysrq_enabled,
599 .maxlen =
sizeof (
int),
604 #ifdef CONFIG_PROC_SYSCTL
606 .procname =
"cad_pid",
608 .maxlen =
sizeof (
int),
614 .procname =
"threads-max",
616 .maxlen =
sizeof(
int),
621 .procname =
"random",
623 .child = random_table,
626 .procname =
"usermodehelper",
631 .procname =
"overflowuid",
633 .maxlen =
sizeof(
int),
640 .procname =
"overflowgid",
642 .maxlen =
sizeof(
int),
649 #ifdef CONFIG_MATHEMU
651 .procname =
"ieee_emulation_warnings",
653 .maxlen =
sizeof(
int),
659 .procname =
"userprocess_debug",
661 .maxlen =
sizeof(
int),
667 .procname =
"pid_max",
669 .maxlen =
sizeof (
int),
676 .procname =
"panic_on_oops",
678 .maxlen =
sizeof(
int),
682 #
if defined CONFIG_PRINTK
684 .procname =
"printk",
686 .maxlen = 4*
sizeof(
int),
691 .procname =
"printk_ratelimit",
693 .maxlen =
sizeof(
int),
698 .procname =
"printk_ratelimit_burst",
700 .maxlen =
sizeof(
int),
705 .procname =
"printk_delay",
706 .data = &printk_delay_msec,
707 .maxlen =
sizeof(
int),
714 .procname =
"dmesg_restrict",
715 .data = &dmesg_restrict,
716 .maxlen =
sizeof(
int),
723 .procname =
"kptr_restrict",
724 .data = &kptr_restrict,
725 .maxlen =
sizeof(
int),
733 .procname =
"ngroups_max",
734 .data = &ngroups_max,
735 .maxlen =
sizeof (
int),
740 .procname =
"cap_last_cap",
741 .data = (
void *)&cap_last_cap,
746 #if defined(CONFIG_LOCKUP_DETECTOR)
748 .procname =
"watchdog",
750 .maxlen =
sizeof (
int),
757 .procname =
"watchdog_thresh",
759 .maxlen =
sizeof(
int),
766 .procname =
"softlockup_panic",
768 .maxlen =
sizeof(
int),
775 .procname =
"nmi_watchdog",
777 .maxlen =
sizeof (
int),
784 #
if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
786 .procname =
"unknown_nmi_panic",
788 .maxlen =
sizeof (
int),
793 #
if defined(CONFIG_X86)
795 .procname =
"panic_on_unrecovered_nmi",
797 .maxlen =
sizeof(
int),
802 .procname =
"panic_on_io_nmi",
804 .maxlen =
sizeof(
int),
808 #ifdef CONFIG_DEBUG_STACKOVERFLOW
810 .procname =
"panic_on_stackoverflow",
812 .maxlen =
sizeof(
int),
818 .procname =
"bootloader_type",
820 .maxlen =
sizeof (
int),
825 .procname =
"bootloader_version",
827 .maxlen =
sizeof (
int),
832 .procname =
"kstack_depth_to_print",
834 .maxlen =
sizeof(
int),
839 .procname =
"io_delay_type",
840 .data = &io_delay_type,
841 .maxlen =
sizeof(
int),
846 #
if defined(CONFIG_MMU)
848 .procname =
"randomize_va_space",
849 .data = &randomize_va_space,
850 .maxlen =
sizeof(
int),
855 #
if defined(CONFIG_S390) && defined(
CONFIG_SMP)
857 .procname =
"spin_retry",
859 .maxlen =
sizeof (
int),
864 #
if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
866 .procname =
"acpi_video_flags",
868 .maxlen =
sizeof (
unsigned long),
875 .procname =
"ignore-unaligned-usertrap",
877 .maxlen =
sizeof (
int),
882 .procname =
"unaligned-dump-stack",
884 .maxlen =
sizeof (
int),
889 #ifdef CONFIG_DETECT_HUNG_TASK
891 .procname =
"hung_task_panic",
893 .maxlen =
sizeof(
int),
900 .procname =
"hung_task_check_count",
902 .maxlen =
sizeof(
unsigned long),
907 .procname =
"hung_task_timeout_secs",
909 .maxlen =
sizeof(
unsigned long),
914 .procname =
"hung_task_warnings",
916 .maxlen =
sizeof(
unsigned long),
923 .procname =
"compat-log",
925 .maxlen =
sizeof (
int),
930 #ifdef CONFIG_RT_MUTEXES
932 .procname =
"max_lock_depth",
934 .maxlen =
sizeof(
int),
940 .procname =
"poweroff_cmd",
953 #ifdef CONFIG_RCU_TORTURE_TEST
957 .maxlen =
sizeof(
int),
962 #ifdef CONFIG_PERF_EVENTS
970 .procname =
"perf_event_paranoid",
971 .data = &sysctl_perf_event_paranoid,
972 .maxlen =
sizeof(sysctl_perf_event_paranoid),
977 .procname =
"perf_event_mlock_kb",
978 .data = &sysctl_perf_event_mlock,
979 .maxlen =
sizeof(sysctl_perf_event_mlock),
984 .procname =
"perf_event_max_sample_rate",
985 .data = &sysctl_perf_event_sample_rate,
986 .maxlen =
sizeof(sysctl_perf_event_sample_rate),
991 #ifdef CONFIG_KMEMCHECK
993 .procname =
"kmemcheck",
995 .maxlen =
sizeof(
int),
1002 .procname =
"blk_iopoll",
1004 .maxlen =
sizeof(
int),
1023 .procname =
"panic_on_oom",
1032 .procname =
"oom_kill_allocating_task",
1039 .procname =
"oom_dump_tasks",
1046 .procname =
"overcommit_ratio",
1053 .procname =
"page-cluster",
1055 .maxlen =
sizeof(
int),
1061 .procname =
"dirty_background_ratio",
1070 .procname =
"dirty_background_bytes",
1078 .procname =
"dirty_ratio",
1087 .procname =
"dirty_bytes",
1092 .
extra1 = &dirty_bytes_min,
1095 .procname =
"dirty_writeback_centisecs",
1102 .procname =
"dirty_expire_centisecs",
1110 .procname =
"nr_pdflush_threads",
1115 .procname =
"swappiness",
1123 #ifdef CONFIG_HUGETLB_PAGE
1125 .procname =
"nr_hugepages",
1127 .maxlen =
sizeof(
unsigned long),
1135 .procname =
"nr_hugepages_mempolicy",
1137 .maxlen =
sizeof(
unsigned long),
1145 .procname =
"hugetlb_shm_group",
1147 .maxlen =
sizeof(
gid_t),
1152 .procname =
"hugepages_treat_as_movable",
1154 .maxlen =
sizeof(
int),
1159 .procname =
"nr_overcommit_hugepages",
1161 .maxlen =
sizeof(
unsigned long),
1169 .procname =
"lowmem_reserve_ratio",
1176 .procname =
"drop_caches",
1178 .maxlen =
sizeof(
int),
1184 #ifdef CONFIG_COMPACTION
1186 .procname =
"compact_memory",
1187 .data = &sysctl_compact_memory,
1188 .maxlen =
sizeof(
int),
1193 .procname =
"extfrag_threshold",
1194 .data = &sysctl_extfrag_threshold,
1195 .maxlen =
sizeof(
int),
1198 .
extra1 = &min_extfrag_threshold,
1199 .
extra2 = &max_extfrag_threshold,
1204 .procname =
"min_free_kbytes",
1212 .procname =
"percpu_pagelist_fraction",
1217 .
extra1 = &min_percpu_pagelist_fract,
1221 .procname =
"max_map_count",
1230 .procname =
"nr_trim_pages",
1239 .procname =
"laptop_mode",
1246 .procname =
"block_dump",
1254 .procname =
"vfs_cache_pressure",
1263 .procname =
"legacy_va_layout",
1264 .data = &sysctl_legacy_va_layout,
1265 .maxlen =
sizeof(sysctl_legacy_va_layout),
1273 .procname =
"zone_reclaim_mode",
1274 .data = &zone_reclaim_mode,
1275 .maxlen =
sizeof(zone_reclaim_mode),
1281 .procname =
"min_unmapped_ratio",
1282 .data = &sysctl_min_unmapped_ratio,
1283 .maxlen =
sizeof(sysctl_min_unmapped_ratio),
1290 .procname =
"min_slab_ratio",
1291 .data = &sysctl_min_slab_ratio,
1292 .maxlen =
sizeof(sysctl_min_slab_ratio),
1301 .procname =
"stat_interval",
1310 .procname =
"mmap_min_addr",
1312 .maxlen =
sizeof(
unsigned long),
1319 .procname =
"numa_zonelist_order",
1326 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1327 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1329 .procname =
"vdso_enabled",
1337 #ifdef CONFIG_HIGHMEM
1339 .procname =
"highmem_is_dirtyable",
1349 .procname =
"scan_unevictable_pages",
1355 #ifdef CONFIG_MEMORY_FAILURE
1357 .procname =
"memory_failure_early_kill",
1358 .data = &sysctl_memory_failure_early_kill,
1359 .maxlen =
sizeof(sysctl_memory_failure_early_kill),
1366 .procname =
"memory_failure_recovery",
1367 .data = &sysctl_memory_failure_recovery,
1368 .maxlen =
sizeof(sysctl_memory_failure_recovery),
1378 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1379 static struct ctl_table binfmt_misc_table[] = {
1388 .maxlen = 2*
sizeof(
int),
1393 .procname =
"inode-state",
1395 .maxlen = 7*
sizeof(
int),
1400 .procname =
"file-nr",
1407 .procname =
"file-max",
1414 .procname =
"nr_open",
1416 .maxlen =
sizeof(
int),
1423 .procname =
"dentry-state",
1425 .maxlen = 6*
sizeof(
int),
1430 .procname =
"overflowuid",
1432 .maxlen =
sizeof(
int),
1439 .procname =
"overflowgid",
1441 .maxlen =
sizeof(
int),
1447 #ifdef CONFIG_FILE_LOCKING
1449 .procname =
"leases-enable",
1451 .maxlen =
sizeof(
int),
1456 #ifdef CONFIG_DNOTIFY
1458 .procname =
"dir-notify-enable",
1459 .data = &dir_notify_enable,
1460 .maxlen =
sizeof(
int),
1466 #ifdef CONFIG_FILE_LOCKING
1468 .procname =
"lease-break-time",
1470 .maxlen =
sizeof(
int),
1477 .procname =
"aio-nr",
1479 .maxlen =
sizeof(
aio_nr),
1484 .procname =
"aio-max-nr",
1491 #ifdef CONFIG_INOTIFY_USER
1493 .procname =
"inotify",
1500 .procname =
"epoll",
1507 .procname =
"protected_symlinks",
1509 .maxlen =
sizeof(
int),
1516 .procname =
"protected_hardlinks",
1518 .maxlen =
sizeof(
int),
1525 .procname =
"suid_dumpable",
1527 .maxlen =
sizeof(
int),
1533 #
if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1535 .procname =
"binfmt_misc",
1537 .child = binfmt_misc_table,
1543 .maxlen =
sizeof(
int),
1551 static struct ctl_table debug_table[] = {
1552 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1556 .maxlen =
sizeof(
int),
1561 #
if defined(CONFIG_OPTPROBES)
1563 .procname =
"kprobes-optimization",
1564 .data = &sysctl_kprobes_optimization,
1565 .maxlen =
sizeof(
int),
1579 int __init sysctl_init(
void)
1594 #ifdef CONFIG_PROC_SYSCTL
1596 static int _proc_do_string(
void*
data,
int maxlen,
int write,
1597 void __user *buffer,
1598 size_t *lenp, loff_t *ppos)
1604 if (!data || !maxlen || !*lenp) {
1612 while (len < *lenp) {
1615 if (c == 0 || c ==
'\n')
1623 ((
char *) data)[len] = 0;
1644 if(
put_user(
'\n', ((
char __user *) buffer) + len))
1672 void __user *buffer,
size_t *lenp, loff_t *ppos)
1674 return _proc_do_string(table->
data, table->
maxlen, write,
1675 buffer, lenp, ppos);
1678 static size_t proc_skip_spaces(
char **
buf)
1687 static void proc_skip_char(
char **
buf,
size_t *
size,
const char v)
1697 #define TMPBUFLEN 22
1714 static int proc_get_long(
char **buf,
size_t *size,
1715 unsigned long *
val,
bool *
neg,
1716 const char *perm_tr,
unsigned perm_tr_len,
char *
tr)
1732 if (*p ==
'-' && *size > 1) {
1750 if (len < *size && perm_tr_len && !
memchr(perm_tr, *p, perm_tr_len))
1753 if (tr && (len < *size))
1773 static int proc_put_long(
void __user **buf,
size_t *size,
unsigned long val,
1779 sprintf(p,
"%s%lu", neg ?
"-" :
"", val);
1791 static int proc_put_char(
void __user **buf,
size_t *size,
char c)
1797 (*size)--, (*buffer)++;
1803 static int do_proc_dointvec_conv(
bool *negp,
unsigned long *lvalp,
1805 int write,
void *data)
1808 *valp = *negp ? -*lvalp : *lvalp;
1813 *lvalp = (
unsigned long)-val;
1816 *lvalp = (
unsigned long)val;
1822 static const char proc_wspace_sep[] = {
' ',
'\t',
'\n' };
1824 static int __do_proc_dointvec(
void *tbl_data,
struct ctl_table *table,
1825 int write,
void __user *buffer,
1826 size_t *lenp, loff_t *ppos,
1827 int (*
conv)(
bool *negp,
unsigned long *lvalp,
int *valp,
1828 int write,
void *data),
1832 unsigned long page = 0;
1836 if (!tbl_data || !table->
maxlen || !*lenp || (*ppos && !write)) {
1841 i = (
int *) tbl_data;
1842 vleft = table->
maxlen /
sizeof(*i);
1846 conv = do_proc_dointvec_conv;
1852 kbuf = (
char *) page;
1862 for (; left && vleft--; i++, first=0) {
1867 left -= proc_skip_spaces(&kbuf);
1871 err = proc_get_long(&kbuf, &left, &lval, &neg,
1873 sizeof(proc_wspace_sep),
NULL);
1876 if (
conv(&neg, &lval, i, 1, data)) {
1881 if (
conv(&neg, &lval, i, 0, data)) {
1886 err = proc_put_char(&buffer, &left,
'\t');
1889 err = proc_put_long(&buffer, &left, lval, neg);
1895 if (!write && !first && left && !
err)
1896 err = proc_put_char(&buffer, &left,
'\n');
1897 if (write && !
err && left)
1898 left -= proc_skip_spaces(&kbuf);
1910 static int do_proc_dointvec(
struct ctl_table *table,
int write,
1911 void __user *buffer,
size_t *lenp, loff_t *ppos,
1912 int (*
conv)(
bool *negp,
unsigned long *lvalp,
int *valp,
1913 int write,
void *data),
1916 return __do_proc_dointvec(table->
data, table, write,
1917 buffer, lenp, ppos,
conv, data);
1934 void __user *buffer,
size_t *lenp, loff_t *ppos)
1936 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1944 static int proc_taint(
struct ctl_table *table,
int write,
1945 void __user *buffer,
size_t *lenp, loff_t *ppos)
1966 for (i = 0; i < BITS_PER_LONG && tmptaint >>
i; i++) {
1967 if ((tmptaint >> i) & 1)
1975 #ifdef CONFIG_PRINTK
1976 static int proc_dointvec_minmax_sysadmin(
struct ctl_table *table,
int write,
1977 void __user *buffer,
size_t *lenp, loff_t *ppos)
1986 struct do_proc_dointvec_minmax_conv_param {
1991 static int do_proc_dointvec_minmax_conv(
bool *negp,
unsigned long *lvalp,
1993 int write,
void *data)
1995 struct do_proc_dointvec_minmax_conv_param *
param =
data;
1997 int val = *negp ? -*lvalp : *lvalp;
1998 if ((param->min && *param->min > val) ||
1999 (param->max && *param->max < val))
2006 *lvalp = (
unsigned long)-val;
2009 *lvalp = (
unsigned long)val;
2032 void __user *buffer,
size_t *lenp, loff_t *ppos)
2034 struct do_proc_dointvec_minmax_conv_param param = {
2035 .min = (
int *) table->
extra1,
2036 .max = (
int *) table->
extra2,
2038 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2039 do_proc_dointvec_minmax_conv, ¶m);
2042 static void validate_coredump_safety(
void)
2044 #ifdef CONFIG_COREDUMP
2048 "suid_dumpable=2. Pipe handler or fully qualified "\
2049 "core dump path required.\n");
2054 static int proc_dointvec_minmax_coredump(
struct ctl_table *table,
int write,
2055 void __user *buffer,
size_t *lenp, loff_t *ppos)
2059 validate_coredump_safety();
2063 #ifdef CONFIG_COREDUMP
2064 static int proc_dostring_coredump(
struct ctl_table *table,
int write,
2065 void __user *buffer,
size_t *lenp, loff_t *ppos)
2067 int error =
proc_dostring(table, write, buffer, lenp, ppos);
2069 validate_coredump_safety();
2074 static int __do_proc_doulongvec_minmax(
void *data,
struct ctl_table *table,
int write,
2075 void __user *buffer,
2076 size_t *lenp, loff_t *ppos,
2077 unsigned long convmul,
2078 unsigned long convdiv)
2081 int vleft, first = 1, err = 0;
2082 unsigned long page = 0;
2086 if (!data || !table->
maxlen || !*lenp || (*ppos && !write)) {
2091 i = (
unsigned long *) data;
2092 min = (
unsigned long *) table->
extra1;
2093 max = (
unsigned long *) table->
extra2;
2094 vleft = table->
maxlen /
sizeof(
unsigned long);
2101 kbuf = (
char *) page;
2111 for (; left && vleft--; i++, first = 0) {
2117 left -= proc_skip_spaces(&kbuf);
2119 err = proc_get_long(&kbuf, &left, &val, &neg,
2121 sizeof(proc_wspace_sep),
NULL);
2126 if ((min && val < *min) || (max && val > *max))
2130 val = convdiv * (*i) / convmul;
2132 err = proc_put_char(&buffer, &left,
'\t');
2133 err = proc_put_long(&buffer, &left, val,
false);
2139 if (!write && !first && left && !err)
2140 err = proc_put_char(&buffer, &left,
'\n');
2142 left -= proc_skip_spaces(&kbuf);
2154 static int do_proc_doulongvec_minmax(
struct ctl_table *table,
int write,
2155 void __user *buffer,
2156 size_t *lenp, loff_t *ppos,
2157 unsigned long convmul,
2158 unsigned long convdiv)
2160 return __do_proc_doulongvec_minmax(table->
data, table, write,
2161 buffer, lenp, ppos, convmul, convdiv);
2181 void __user *buffer,
size_t *lenp, loff_t *ppos)
2183 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1
l, 1
l);
2204 void __user *buffer,
2205 size_t *lenp, loff_t *ppos)
2207 return do_proc_doulongvec_minmax(table, write, buffer,
2208 lenp, ppos,
HZ, 1000
l);
2212 static int do_proc_dointvec_jiffies_conv(
bool *negp,
unsigned long *lvalp,
2214 int write,
void *data)
2219 *valp = *negp ? -(*lvalp*
HZ) : (*lvalp*
HZ);
2225 lval = (
unsigned long)-val;
2228 lval = (
unsigned long)val;
2235 static int do_proc_dointvec_userhz_jiffies_conv(
bool *negp,
unsigned long *lvalp,
2237 int write,
void *data)
2248 lval = (
unsigned long)-val;
2251 lval = (
unsigned long)val;
2258 static int do_proc_dointvec_ms_jiffies_conv(
bool *negp,
unsigned long *lvalp,
2260 int write,
void *data)
2269 lval = (
unsigned long)-val;
2272 lval = (
unsigned long)val;
2295 void __user *buffer,
size_t *lenp, loff_t *ppos)
2297 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2298 do_proc_dointvec_jiffies_conv,
NULL);
2317 void __user *buffer,
size_t *lenp, loff_t *ppos)
2319 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2320 do_proc_dointvec_userhz_jiffies_conv,
NULL);
2340 void __user *buffer,
size_t *lenp, loff_t *ppos)
2342 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2343 do_proc_dointvec_ms_jiffies_conv,
NULL);
2346 static int proc_do_cad_pid(
struct ctl_table *table,
int write,
2347 void __user *buffer,
size_t *lenp, loff_t *ppos)
2349 struct pid *new_pid;
2355 r = __do_proc_dointvec(&tmp, table, write, buffer,
2386 void __user *buffer,
size_t *lenp, loff_t *ppos)
2390 size_t left = *lenp;
2391 unsigned long bitmap_len = table->
maxlen;
2392 unsigned long *
bitmap = (
unsigned long *) table->
data;
2393 unsigned long *tmp_bitmap =
NULL;
2394 char tr_a[] = {
'-',
',',
'\n' }, tr_b[] = {
',',
'\n', 0 },
c;
2396 if (!bitmap_len || !left || (*ppos && !write)) {
2402 unsigned long page = 0;
2409 kbuf = (
char *) page;
2418 tmp_bitmap = kzalloc(
BITS_TO_LONGS(bitmap_len) *
sizeof(
unsigned long),
2424 proc_skip_char(&kbuf, &left,
'\n');
2425 while (!err && left) {
2426 unsigned long val_a, val_b;
2429 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2433 if (val_a >= bitmap_len || neg) {
2445 err = proc_get_long(&kbuf, &left, &val_b,
2446 &neg, tr_b,
sizeof(tr_b),
2450 if (val_b >= bitmap_len || neg ||
2461 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
2463 proc_skip_char(&kbuf, &left,
'\n');
2467 unsigned long bit_a, bit_b = 0;
2471 if (bit_a >= bitmap_len)
2477 err = proc_put_char(&buffer, &left,
',');
2481 err = proc_put_long(&buffer, &left, bit_a,
false);
2484 if (bit_a != bit_b) {
2485 err = proc_put_char(&buffer, &left,
'-');
2488 err = proc_put_long(&buffer, &left, bit_b,
false);
2496 err = proc_put_char(&buffer, &left,
'\n');
2504 bitmap_copy(
bitmap, tmp_bitmap, bitmap_len);
2519 void __user *buffer,
size_t *lenp, loff_t *ppos)
2525 void __user *buffer,
size_t *lenp, loff_t *ppos)
2531 void __user *buffer,
size_t *lenp, loff_t *ppos)
2537 void __user *buffer,
size_t *lenp, loff_t *ppos)
2543 void __user *buffer,
size_t *lenp, loff_t *ppos)
2549 void __user *buffer,
size_t *lenp, loff_t *ppos)
2555 void __user *buffer,
size_t *lenp, loff_t *ppos)
2561 void __user *buffer,
2562 size_t *lenp, loff_t *ppos)