Skip to content

Commit a371d55

Browse files
rikvanrieltehcaster
authored andcommitted
mm, slub: do not call do_slab_free for kfence object
In 782f890 the freeing of kfence objects was moved from deep inside do_slab_free to the wrapper functions outside. This is a nice change, but unfortunately it missed one spot in __kmem_cache_free_bulk. This results in a crash like this: BUG skbuff_head_cache (Tainted: G S B E ): Padding overwritten. 0xffff88907fea0f00-0xffff88907fea0fff @offset=3840 slab_err (mm/slub.c:1129) free_to_partial_list (mm/slub.c:? mm/slub.c:4036) slab_pad_check (mm/slub.c:864 mm/slub.c:1290) check_slab (mm/slub.c:?) free_to_partial_list (mm/slub.c:3171 mm/slub.c:4036) kmem_cache_alloc_bulk (mm/slub.c:? mm/slub.c:4495 mm/slub.c:4586 mm/slub.c:4635) napi_build_skb (net/core/skbuff.c:348 net/core/skbuff.c:527 net/core/skbuff.c:549) All the other callers to do_slab_free appear to be ok. Add a kfence_free check in __kmem_cache_free_bulk to avoid the crash. Reported-by: Chris Mason <[email protected]> Fixes: 782f890 ("mm/slub: free KFENCE objects in slab_free_hook()") Cc: [email protected] Signed-off-by: Rik van Riel <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 8400291 commit a371d55

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/slub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4690,6 +4690,9 @@ static void __kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
46904690
if (!df.slab)
46914691
continue;
46924692

4693+
if (kfence_free(df.freelist))
4694+
continue;
4695+
46934696
do_slab_free(df.s, df.slab, df.freelist, df.tail, df.cnt,
46944697
_RET_IP_);
46954698
} while (likely(size));

0 commit comments

Comments
 (0)