aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2006-09-16 05:50:22 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-09-25 05:25:26 -0400
commit51635ad282ead58b9d164f07e1fb62a9456b427c (patch)
treea7d9fb162d09aaf02da3dee89520b10c07d92c8b
parentbf11d26cb96fe8221ef056eedab692e91634cc65 (diff)
[ARM] 3813/1: prevent >= 4G /dev/mem mmap()
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>
-rw-r--r--arch/arm/mm/mmap.c22
-rw-r--r--include/asm-arm/io.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 29e54807c5bc..b0b5f4694070 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -114,3 +114,25 @@ full_search:
114 } 114 }
115} 115}
116 116
117
118/*
119 * You really shouldn't be using read() or write() on /dev/mem. This
120 * might go away in the future.
121 */
122int valid_phys_addr_range(unsigned long addr, size_t size)
123{
124 if (addr + size > __pa(high_memory))
125 return 0;
126
127 return 1;
128}
129
130/*
131 * We don't use supersection mappings for mmap() on /dev/mem, which
132 * means that we can't map the memory area above the 4G barrier into
133 * userspace.
134 */
135int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
136{
137 return !(pfn + (size >> PAGE_SHIFT) > 0x00100000);
138}
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index bf7b9dea30f1..8076a85c3675 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -280,6 +280,10 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
280#define BIOVEC_MERGEABLE(vec1, vec2) \ 280#define BIOVEC_MERGEABLE(vec1, vec2) \
281 ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) 281 ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
282 282
283#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
284extern int valid_phys_addr_range(unsigned long addr, size_t size);
285extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
286
283/* 287/*
284 * Convert a physical pointer to a virtual kernel pointer for /dev/mem 288 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
285 * access 289 * access