[PATCH 1/4] mm: kvrealloc: disable KASAN when switching to vmalloc

From: Danilo Krummrich
Date: Tue Jul 30 2024 - 14:51:15 EST


Disable KASAN accessibility checks when switching from a kmalloc buffer
to a vmalloc buffer.

Fixes: 923a26b4c679 ("mm: kvmalloc: align kvrealloc() with krealloc()")
Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
---
mm/util.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/util.c b/mm/util.c
index 29ae93f6344f..bfb2d69b6434 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -753,7 +753,10 @@ void *kvrealloc_noprof(const void *p, size_t size, gfp_t flags)

if (p) {
/* We already know that `p` is not a vmalloc address. */
- memcpy(n, p, ksize(p));
+ kasan_disable_current();
+ memcpy(n, kasan_reset_tag(p), ksize(p));
+ kasan_enable_current();
+
kfree(p);
}
}
--
2.45.2