diff options
Diffstat (limited to 'kernel/sysctl.c')
| -rw-r--r-- | kernel/sysctl.c | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 4ab11879aeb4..87174ef59161 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/security.h> | 30 | #include <linux/security.h> |
| 31 | #include <linux/ctype.h> | 31 | #include <linux/ctype.h> |
| 32 | #include <linux/kmemcheck.h> | 32 | #include <linux/kmemcheck.h> |
| 33 | #include <linux/kmemleak.h> | ||
| 33 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
| 34 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| 35 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
| @@ -174,6 +175,11 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write, | |||
| 174 | void __user *buffer, size_t *lenp, loff_t *ppos); | 175 | void __user *buffer, size_t *lenp, loff_t *ppos); |
| 175 | #endif | 176 | #endif |
| 176 | 177 | ||
| 178 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, | ||
| 179 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
| 180 | static int proc_dostring_coredump(struct ctl_table *table, int write, | ||
| 181 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
| 182 | |||
| 177 | #ifdef CONFIG_MAGIC_SYSRQ | 183 | #ifdef CONFIG_MAGIC_SYSRQ |
| 178 | /* Note: sysrq code uses it's own private copy */ | 184 | /* Note: sysrq code uses it's own private copy */ |
| 179 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; | 185 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; |
| @@ -410,7 +416,7 @@ static struct ctl_table kern_table[] = { | |||
| 410 | .data = core_pattern, | 416 | .data = core_pattern, |
| 411 | .maxlen = CORENAME_MAX_SIZE, | 417 | .maxlen = CORENAME_MAX_SIZE, |
| 412 | .mode = 0644, | 418 | .mode = 0644, |
| 413 | .proc_handler = proc_dostring, | 419 | .proc_handler = proc_dostring_coredump, |
| 414 | }, | 420 | }, |
| 415 | { | 421 | { |
| 416 | .procname = "core_pipe_limit", | 422 | .procname = "core_pipe_limit", |
| @@ -1095,11 +1101,9 @@ static struct ctl_table vm_table[] = { | |||
| 1095 | .extra1 = &zero, | 1101 | .extra1 = &zero, |
| 1096 | }, | 1102 | }, |
| 1097 | { | 1103 | { |
| 1098 | .procname = "nr_pdflush_threads", | 1104 | .procname = "nr_pdflush_threads", |
| 1099 | .data = &nr_pdflush_threads, | 1105 | .mode = 0444 /* read-only */, |
| 1100 | .maxlen = sizeof nr_pdflush_threads, | 1106 | .proc_handler = pdflush_proc_obsolete, |
| 1101 | .mode = 0444 /* read-only*/, | ||
| 1102 | .proc_handler = proc_dointvec, | ||
| 1103 | }, | 1107 | }, |
| 1104 | { | 1108 | { |
| 1105 | .procname = "swappiness", | 1109 | .procname = "swappiness", |
| @@ -1494,11 +1498,29 @@ static struct ctl_table fs_table[] = { | |||
| 1494 | #endif | 1498 | #endif |
| 1495 | #endif | 1499 | #endif |
| 1496 | { | 1500 | { |
| 1501 | .procname = "protected_symlinks", | ||
| 1502 | .data = &sysctl_protected_symlinks, | ||
| 1503 | .maxlen = sizeof(int), | ||
| 1504 | .mode = 0600, | ||
| 1505 | .proc_handler = proc_dointvec_minmax, | ||
| 1506 | .extra1 = &zero, | ||
| 1507 | .extra2 = &one, | ||
| 1508 | }, | ||
| 1509 | { | ||
| 1510 | .procname = "protected_hardlinks", | ||
| 1511 | .data = &sysctl_protected_hardlinks, | ||
| 1512 | .maxlen = sizeof(int), | ||
| 1513 | .mode = 0600, | ||
| 1514 | .proc_handler = proc_dointvec_minmax, | ||
| 1515 | .extra1 = &zero, | ||
| 1516 | .extra2 = &one, | ||
| 1517 | }, | ||
| 1518 | { | ||
| 1497 | .procname = "suid_dumpable", | 1519 | .procname = "suid_dumpable", |
| 1498 | .data = &suid_dumpable, | 1520 | .data = &suid_dumpable, |
| 1499 | .maxlen = sizeof(int), | 1521 | .maxlen = sizeof(int), |
| 1500 | .mode = 0644, | 1522 | .mode = 0644, |
| 1501 | .proc_handler = proc_dointvec_minmax, | 1523 | .proc_handler = proc_dointvec_minmax_coredump, |
| 1502 | .extra1 = &zero, | 1524 | .extra1 = &zero, |
| 1503 | .extra2 = &two, | 1525 | .extra2 = &two, |
| 1504 | }, | 1526 | }, |
| @@ -1551,7 +1573,10 @@ static struct ctl_table dev_table[] = { | |||
| 1551 | 1573 | ||
| 1552 | int __init sysctl_init(void) | 1574 | int __init sysctl_init(void) |
| 1553 | { | 1575 | { |
| 1554 | register_sysctl_table(sysctl_base_table); | 1576 | struct ctl_table_header *hdr; |
| 1577 | |||
| 1578 | hdr = register_sysctl_table(sysctl_base_table); | ||
| 1579 | kmemleak_not_leak(hdr); | ||
| 1555 | return 0; | 1580 | return 0; |
| 1556 | } | 1581 | } |
| 1557 | 1582 | ||
| @@ -2009,6 +2034,34 @@ int proc_dointvec_minmax(struct ctl_table *table, int write, | |||
| 2009 | do_proc_dointvec_minmax_conv, ¶m); | 2034 | do_proc_dointvec_minmax_conv, ¶m); |
| 2010 | } | 2035 | } |
| 2011 | 2036 | ||
| 2037 | static void validate_coredump_safety(void) | ||
| 2038 | { | ||
| 2039 | if (suid_dumpable == SUID_DUMPABLE_SAFE && | ||
| 2040 | core_pattern[0] != '/' && core_pattern[0] != '|') { | ||
| 2041 | printk(KERN_WARNING "Unsafe core_pattern used with "\ | ||
| 2042 | "suid_dumpable=2. Pipe handler or fully qualified "\ | ||
| 2043 | "core dump path required.\n"); | ||
| 2044 | } | ||
| 2045 | } | ||
| 2046 | |||
| 2047 | static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write, | ||
| 2048 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2049 | { | ||
| 2050 | int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
| 2051 | if (!error) | ||
| 2052 | validate_coredump_safety(); | ||
| 2053 | return error; | ||
| 2054 | } | ||
| 2055 | |||
| 2056 | static int proc_dostring_coredump(struct ctl_table *table, int write, | ||
| 2057 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2058 | { | ||
| 2059 | int error = proc_dostring(table, write, buffer, lenp, ppos); | ||
| 2060 | if (!error) | ||
| 2061 | validate_coredump_safety(); | ||
| 2062 | return error; | ||
| 2063 | } | ||
| 2064 | |||
| 2012 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, | 2065 | static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, |
| 2013 | void __user *buffer, | 2066 | void __user *buffer, |
| 2014 | size_t *lenp, loff_t *ppos, | 2067 | size_t *lenp, loff_t *ppos, |
