Skip to content

Commit df3ae2c

Browse files
melvertorvalds
authored andcommitted
kfence, slab: fix cache_alloc_debugcheck_after() for bulk allocations
cache_alloc_debugcheck_after() performs checks on an object, including adjusting the returned pointer. None of this should apply to KFENCE objects. While for non-bulk allocations, the checks are skipped when we allocate via KFENCE, for bulk allocations cache_alloc_debugcheck_after() is called via cache_alloc_debugcheck_after_bulk(). Fix it by skipping cache_alloc_debugcheck_after() for KFENCE objects. Link: https://lkml.kernel.org/r/20210304205256.2162309-1-elver@google.com Signed-off-by: Marco Elver <elver@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Cc: Jann Horn <jannh@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 702b16d commit df3ae2c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mm/slab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2992,7 +2992,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
29922992
gfp_t flags, void *objp, unsigned long caller)
29932993
{
29942994
WARN_ON_ONCE(cachep->ctor && (flags & __GFP_ZERO));
2995-
if (!objp)
2995+
if (!objp || is_kfence_address(objp))
29962996
return objp;
29972997
if (cachep->flags & SLAB_POISON) {
29982998
check_poison_obj(cachep, objp);

0 commit comments

Comments
 (0)