]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] 3813/1: prevent >= 4G /dev/mem mmap()
authorLennert Buytenhek <buytenh@wantstofly.org>
Sat, 16 Sep 2006 09:50:22 +0000 (10:50 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 25 Sep 2006 09:25:26 +0000 (10:25 +0100)
Prevent userland from mapping in physical address regions >= 4G by
checking for that in valid_mmap_phys_addr_range().

Unfortunately, we cannot override valid_mmap_phys_addr_range() without
also overriding valid_phys_addr_range(), so copy drivers/char/mem.c's
version of valid_phys_addr_range() over to arch/arm/mm/mmap.c as well.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mm/mmap.c
include/asm-arm/io.h

index 29e54807c5bc6a1a0e010495aad34b9fd60346f2..b0b5f46940705431a468efb6681a7636e40e988e 100644 (file)
@@ -114,3 +114,25 @@ full_search:
        }
 }
 
+
+/*
+ * You really shouldn't be using read() or write() on /dev/mem.  This
+ * might go away in the future.
+ */
+int valid_phys_addr_range(unsigned long addr, size_t size)
+{
+       if (addr + size > __pa(high_memory))
+               return 0;
+
+       return 1;
+}
+
+/*
+ * We don't use supersection mappings for mmap() on /dev/mem, which
+ * means that we can't map the memory area above the 4G barrier into
+ * userspace.
+ */
+int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
+{
+       return !(pfn + (size >> PAGE_SHIFT) > 0x00100000);
+}
index bf7b9dea30f1f9b0ae7f16dfbc1cd752e5c5327c..8076a85c367541479c6e6aaa4dd54e358cb3ba6f 100644 (file)
@@ -280,6 +280,10 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
 #define BIOVEC_MERGEABLE(vec1, vec2)   \
        ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
 
+#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
+extern int valid_phys_addr_range(unsigned long addr, size_t size);
+extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
+
 /*
  * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  * access