Commit 9585116b authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Linus Torvalds
Browse files

i386: fix iounmap's use of vm_struct's size field

get_vm_area always returns an area with an adjacent guard page.  That guard
page is included in vm_struct.size.  iounmap uses vm_struct.size to
determine how much address space needs to have change_page_attr applied to
it, which will BUG if applied to the guard page.

This patch adds a helper function - get_vm_area_size() in linux/vmalloc.h -
to return the actual size of a vm area, and uses it to make iounmap do the
right thing.  There are probably other places which should be using

Thanks to Dave Young <> for debugging the

[ Andi, it wasn't clear to me whether x86_64 needs the same fix. ]
Signed-off-by: default avatarJeremy Fitzhardinge <>
Cc: Dave Young <>
Cc: Chuck Ebbert <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarAndi Kleen <>
Signed-off-by: default avatarLinus Torvalds <>
parent a2900975
......@@ -196,7 +196,7 @@ void iounmap(volatile void __iomem *addr)
/* Reset the direct mapping. Can block */
if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) {
p->size >> PAGE_SHIFT,
get_vm_area_size(p) >> PAGE_SHIFT,
......@@ -58,6 +58,13 @@ void vmalloc_sync_all(void);
* Lowlevel-APIs (not for driver use!)
static inline size_t get_vm_area_size(const struct vm_struct *area)
/* return actual size without guard page */
return area->size - PAGE_SIZE;
extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
unsigned long start, unsigned long end);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment