Commit 54fe2b5b authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Linus Torvalds

[PATCH] fix iounmap and a pageattr memleak (x86 and x86-64)

Reject zero page vm-area request, align size properly and hide the guard page
from the callers like ioremap - this avoids a kernel crash due one more page
being passed to change_page_attr
Signed-off-by: default avatarAndrea Arcangeli <andrea@novell.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b525cd44
......@@ -256,20 +256,22 @@ struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
align = 1ul << bit;
}
addr = ALIGN(start, align);
size = PAGE_ALIGN(size);
area = kmalloc(sizeof(*area), GFP_KERNEL);
if (unlikely(!area))
return NULL;
/*
* We always allocate a guard page.
*/
size += PAGE_SIZE;
if (unlikely(!size)) {
kfree (area);
return NULL;
}
/*
* We always allocate a guard page.
*/
size += PAGE_SIZE;
write_lock(&vmlist_lock);
for (p = &vmlist; (tmp = *p) != NULL ;p = &tmp->next) {
if ((unsigned long)tmp->addr < addr) {
......@@ -349,6 +351,11 @@ struct vm_struct *remove_vm_area(void *addr)
unmap_vm_area(tmp);
*p = tmp->next;
write_unlock(&vmlist_lock);
/*
* Remove the guard page.
*/
tmp->size -= PAGE_SIZE;
return tmp;
}
......
Markdown is supported
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