Skip to content

Commit

Permalink
slub: ksize() abuse checks
Browse files Browse the repository at this point in the history
Add a WARN_ON for pages that don't have PageSlab nor PageCompound set to catch
the worst abusers of ksize() in the kernel.

Acked-by: Christoph Lameter <clameter@sgi.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
  • Loading branch information
Pekka Enberg committed May 22, 2008
1 parent 239f49c commit 7699441
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2726,9 +2726,10 @@ size_t ksize(const void *object)

page = virt_to_head_page(object);

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

}
s = page->slab;

#ifdef CONFIG_SLUB_DEBUG
Expand Down

0 comments on commit 7699441

Please sign in to comment.