diff options
author | Eric Paris <eparis@redhat.com> | 2009-07-31 12:54:11 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2009-08-17 01:09:11 -0400 |
commit | 788084aba2ab7348257597496befcbccabdc98a3 (patch) | |
tree | 2da42d746d67b16ef705229a1b5a3528ec19c725 /security/min_addr.c | |
parent | 8cf948e744e0218af604c32edecde10006dc8e9e (diff) |
Security/SELinux: seperate lsm specific mmap_min_addr
Currently SELinux enforcement of controls on the ability to map low memory
is determined by the mmap_min_addr tunable. This patch causes SELinux to
ignore the tunable and instead use a seperate Kconfig option specific to how
much space the LSM should protect.
The tunable will now only control the need for CAP_SYS_RAWIO and SELinux
permissions will always protect the amount of low memory designated by
CONFIG_LSM_MMAP_MIN_ADDR.
This allows users who need to disable the mmap_min_addr controls (usual reason
being they run WINE as a non-root user) to do so and still have SELinux
controls preventing confined domains (like a web server) from being able to
map some area of low memory.
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/min_addr.c')
-rw-r--r-- | security/min_addr.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/security/min_addr.c b/security/min_addr.c new file mode 100644 index 000000000000..14cc7b3b8d03 --- /dev/null +++ b/security/min_addr.c | |||
@@ -0,0 +1,49 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <linux/mm.h> | ||
3 | #include <linux/security.h> | ||
4 | #include <linux/sysctl.h> | ||
5 | |||
6 | /* amount of vm to protect from userspace access by both DAC and the LSM*/ | ||
7 | unsigned long mmap_min_addr; | ||
8 | /* amount of vm to protect from userspace using CAP_SYS_RAWIO (DAC) */ | ||
9 | unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR; | ||
10 | /* amount of vm to protect from userspace using the LSM = CONFIG_LSM_MMAP_MIN_ADDR */ | ||
11 | |||
12 | /* | ||
13 | * Update mmap_min_addr = max(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR) | ||
14 | */ | ||
15 | static void update_mmap_min_addr(void) | ||
16 | { | ||
17 | #ifdef CONFIG_LSM_MMAP_MIN_ADDR | ||
18 | if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR) | ||
19 | mmap_min_addr = dac_mmap_min_addr; | ||
20 | else | ||
21 | mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR; | ||
22 | #else | ||
23 | mmap_min_addr = dac_mmap_min_addr; | ||
24 | #endif | ||
25 | } | ||
26 | |||
27 | /* | ||
28 | * sysctl handler which just sets dac_mmap_min_addr = the new value and then | ||
29 | * calls update_mmap_min_addr() so non MAP_FIXED hints get rounded properly | ||
30 | */ | ||
31 | int mmap_min_addr_handler(struct ctl_table *table, int write, struct file *filp, | ||
32 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
33 | { | ||
34 | int ret; | ||
35 | |||
36 | ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos); | ||
37 | |||
38 | update_mmap_min_addr(); | ||
39 | |||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | int __init init_mmap_min_addr(void) | ||
44 | { | ||
45 | update_mmap_min_addr(); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | pure_initcall(init_mmap_min_addr); | ||