diff options
author | Nicolas Pitre <nico@fluxnic.net> | 2010-09-23 02:34:36 +0400 |
---|---|---|
committer | Nicolas Pitre <nicolas.pitre@linaro.org> | 2010-10-02 06:31:34 +0400 |
commit | 087aaffcdf9c91667c93923fbc05fa8fb6bc7d3a (patch) | |
tree | ec94d9fd07baa4802ff0a3a2811ef3c3e1c7f3f3 /arch/arm/mm/mmap.c | |
parent | 7c63984b86f96c71c541132c74c4b56fe2a13e1a (diff) | |
download | linux-087aaffcdf9c91667c93923fbc05fa8fb6bc7d3a.tar.xz |
ARM: implement CONFIG_STRICT_DEVMEM by disabling access to RAM via /dev/mem
There are very few legitimate use cases, if any, for directly accessing
system RAM through /dev/mem. So let's mimic what they do on x86 and
forbid it when CONFIG_STRICT_DEVMEM is turned on.
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/mm/mmap.c')
-rw-r--r-- | arch/arm/mm/mmap.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index 4f5b39687df5..b0a98305055c 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -144,3 +144,25 @@ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { return !(pfn + (size >> PAGE_SHIFT) > 0x00100000); } + +#ifdef CONFIG_STRICT_DEVMEM + +#include <linux/ioport.h> + +/* + * devmem_is_allowed() checks to see if /dev/mem access to a certain + * address is valid. The argument is a physical page number. + * We mimic x86 here by disallowing access to system RAM as well as + * device-exclusive MMIO regions. This effectively disable read()/write() + * on /dev/mem. + */ +int devmem_is_allowed(unsigned long pfn) +{ + if (iomem_is_exclusive(pfn << PAGE_SHIFT)) + return 0; + if (!page_is_ram(pfn)) + return 1; + return 0; +} + +#endif |