Skip to content

Commit

Permalink
SLUB's ksize() fails for size > 2048
Browse files Browse the repository at this point in the history
I can't pass memory allocated by kmalloc() to ksize() if it is allocated by
SLUB allocator and size is larger than (I guess) PAGE_SIZE / 2.

The error of ksize() seems to be that it does not check if the allocation
was made by SLUB or the page allocator.

Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>
Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Christoph Lameter <clameter@sgi.com>, Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Vegard Nossum authored and Linus Torvalds committed Dec 5, 2007
1 parent 5a622f2 commit 294a80a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,8 +2558,12 @@ size_t ksize(const void *object)
if (unlikely(object == ZERO_SIZE_PTR))
return 0;

page = get_object_page(object);
page = virt_to_head_page(object);
BUG_ON(!page);

if (unlikely(!PageSlab(page)))
return PAGE_SIZE << compound_order(page);

s = page->slab;
BUG_ON(!s);

Expand Down

0 comments on commit 294a80a

Please sign in to comment.