PM: allow for usage_count > 0 in pm_runtime_get()
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / security / min_addr.c
blobfc43c9d37084599056680e55c5e8c38491b117ba
1 #include <linux/init.h>
2 #include <linux/mm.h>
3 #include <linux/security.h>
4 #include <linux/sysctl.h>
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 */
13 * Update mmap_min_addr = max(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR)
15 static void update_mmap_min_addr(void)
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
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
31 int mmap_min_addr_handler(struct ctl_table *table, int write,
32 void __user *buffer, size_t *lenp, loff_t *ppos)
34 int ret;
36 if (!capable(CAP_SYS_RAWIO))
37 return -EPERM;
39 ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
41 update_mmap_min_addr();
43 return ret;
46 int __init init_mmap_min_addr(void)
48 update_mmap_min_addr();
50 return 0;
52 pure_initcall(init_mmap_min_addr);