Skip to content

Commit d0fe47c

Browse files
Kefeng Wangtorvalds
authored andcommitted
slub: add back check for free nonslab objects
After commit f227f0f ("slub: fix unreclaimable slab stat for bulk free"), the check for free nonslab page is replaced by VM_BUG_ON_PAGE, which only check with CONFIG_DEBUG_VM enabled, but this config may impact performance, so it only for debug. Commit 0937502 ("slub: Add check for kfree() of non slab objects.") add the ability, which should be needed in any configs to catch the invalid free, they even could be potential issue, eg, memory corruption, use after free and double free, so replace VM_BUG_ON_PAGE to WARN_ON_ONCE, add object address printing to help use to debug the issue. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kefeng Wang <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rienjes <[email protected]> Cc: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ffc95a4 commit d0fe47c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/slub.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3522,7 +3522,9 @@ static inline void free_nonslab_page(struct page *page, void *object)
35223522
{
35233523
unsigned int order = compound_order(page);
35243524

3525-
VM_BUG_ON_PAGE(!PageCompound(page), page);
3525+
if (WARN_ON_ONCE(!PageCompound(page)))
3526+
pr_warn_once("object pointer: 0x%p\n", object);
3527+
35263528
kfree_hook(object);
35273529
mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, -(PAGE_SIZE << order));
35283530
__free_pages(page, order);

0 commit comments

Comments
 (0)