[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240909012958.913438-3-feng.tang@intel.com>
Date: Mon, 9 Sep 2024 09:29:55 +0800
From: Feng Tang <feng.tang@...el.com>
To: Vlastimil Babka <vbabka@...e.cz>,
Andrew Morton <akpm@...ux-foundation.org>,
Christoph Lameter <cl@...ux.com>,
Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Hyeonggon Yoo <42.hyeyoo@...il.com>,
Andrey Konovalov <andreyknvl@...il.com>,
Marco Elver <elver@...gle.com>,
Shuah Khan <skhan@...uxfoundation.org>,
David Gow <davidgow@...gle.com>,
Danilo Krummrich <dakr@...nel.org>
Cc: linux-mm@...ck.org,
kasan-dev@...glegroups.com,
linux-kernel@...r.kernel.org,
Feng Tang <feng.tang@...el.com>
Subject: [PATCH 2/5] mm/slub: Consider kfence case for get_orig_size()
When 'orig_size' of kmalloc object is enabled by debug option, it
should either contains the actual requested size or the cache's
'object_size'.
But it's not true if that object is a kfence-allocated one, and its
'orig_size' in metadata could be zero or other values. This is not
a big issue for current 'orig_size' usage, as init_object() and
check_object() during alloc/free process will be skipped for kfence
addresses.
As 'orig_size' will be used by some function block like krealloc(),
handle it by returning the 'object_size' in get_orig_size() for
kfence addresses.
Signed-off-by: Feng Tang <feng.tang@...el.com>
---
mm/slub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slub.c b/mm/slub.c
index 996a72fa6f62..4cb3822dba08 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -768,7 +768,7 @@ static inline unsigned int get_orig_size(struct kmem_cache *s, void *object)
{
void *p = kasan_reset_tag(object);
- if (!slub_debug_orig_size(s))
+ if (!slub_debug_orig_size(s) || is_kfence_address(object))
return s->object_size;
p += get_info_end(s);
--
2.34.1
Powered by blists - more mailing lists