[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210304205256.2162309-1-elver@google.com>
Date: Thu, 4 Mar 2021 21:52:56 +0100
From: Marco Elver <elver@...gle.com>
To: elver@...gle.com, akpm@...ux-foundation.org
Cc: glider@...gle.com, dvyukov@...gle.com, andreyknvl@...gle.com,
jannh@...gle.com, linux-kernel@...r.kernel.org, linux-mm@...ck.org,
kasan-dev@...glegroups.com
Subject: [PATCH mm] 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.
Signed-off-by: Marco Elver <elver@...gle.com>
---
mm/slab.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slab.c b/mm/slab.c
index 51fd424e0d6d..ae651bf540b7 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2992,7 +2992,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
gfp_t flags, void *objp, unsigned long caller)
{
WARN_ON_ONCE(cachep->ctor && (flags & __GFP_ZERO));
- if (!objp)
+ if (!objp || is_kfence_address(objp))
return objp;
if (cachep->flags & SLAB_POISON) {
check_poison_obj(cachep, objp);
--
2.30.1.766.gb4fecdf3b7-goog
Powered by blists - more mailing lists