Commit 05e3ff95 authored by Chintan Pandya's avatar Chintan Pandya Committed by Linus Torvalds

mm: vmalloc: pass proper vm_start into debugobjects

Client can call vunmap with some intermediate 'addr' which may not be
the start of the VM area.  Entire unmap code works with vm->vm_start
which is proper but debug object API is called with 'addr'.  This could
be a problem within debug objects.

Pass proper start address into debug object API.

[akpm@linux-foundation.org: fix warning]
Link: http://lkml.kernel.org/r/1523961828-9485-3-git-send-email-cpandya@codeaurora.orgSigned-off-by: default avatarChintan Pandya <cpandya@codeaurora.org>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Yisheng Xie <xieyisheng1@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f3c01d2f
...@@ -1128,15 +1128,16 @@ void vm_unmap_ram(const void *mem, unsigned int count) ...@@ -1128,15 +1128,16 @@ void vm_unmap_ram(const void *mem, unsigned int count)
BUG_ON(addr > VMALLOC_END); BUG_ON(addr > VMALLOC_END);
BUG_ON(!PAGE_ALIGNED(addr)); BUG_ON(!PAGE_ALIGNED(addr));
debug_check_no_locks_freed(mem, size);
if (likely(count <= VMAP_MAX_ALLOC)) { if (likely(count <= VMAP_MAX_ALLOC)) {
debug_check_no_locks_freed(mem, size);
vb_free(mem, size); vb_free(mem, size);
return; return;
} }
va = find_vmap_area(addr); va = find_vmap_area(addr);
BUG_ON(!va); BUG_ON(!va);
debug_check_no_locks_freed((void *)va->va_start,
(va->va_end - va->va_start));
free_unmap_vmap_area(va); free_unmap_vmap_area(va);
} }
EXPORT_SYMBOL(vm_unmap_ram); EXPORT_SYMBOL(vm_unmap_ram);
...@@ -1511,8 +1512,8 @@ static void __vunmap(const void *addr, int deallocate_pages) ...@@ -1511,8 +1512,8 @@ static void __vunmap(const void *addr, int deallocate_pages)
return; return;
} }
debug_check_no_locks_freed(addr, get_vm_area_size(area)); debug_check_no_locks_freed(area->addr, get_vm_area_size(area));
debug_check_no_obj_freed(addr, get_vm_area_size(area)); debug_check_no_obj_freed(area->addr, get_vm_area_size(area));
remove_vm_area(addr); remove_vm_area(addr);
if (deallocate_pages) { if (deallocate_pages) {
......
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