]> err.no Git - linux-2.6/commitdiff
slub: ksize() abuse checks
authorPekka Enberg <penberg@cs.helsinki.fi>
Thu, 22 May 2008 16:22:25 +0000 (19:22 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Thu, 22 May 2008 16:52:18 +0000 (19:52 +0300)
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>
mm/slub.c

index a505a828ef411e08f149a413fb37f32da7c47e21..0987d1cd943cc88d626a7d1b1097ba1f83243591 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -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