Tong Tiangen (2): arm64: fix return value type of memcpy_mcs() kasan: add kasan support for memcpy_mcs()
arch/arm64/include/asm/string.h | 4 ++-- mm/kasan/common.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6AQE8 CVE: NA
-------------------------------
The return value type of function memcpy_mcs() should be unsigned long. Currently, using this function will force type conversion, but the error of the return value type must be corrected.
Fixes: 11ac448894fc ("[Huawei] arm64: introduce copy_mc_to_kernel() implementation") Signed-off-by: Tong Tiangen tongtiangen@huawei.com --- arch/arm64/include/asm/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/string.h b/arch/arm64/include/asm/string.h index 08e0327a1719..c12a3ca42d61 100644 --- a/arch/arm64/include/asm/string.h +++ b/arch/arm64/include/asm/string.h @@ -36,8 +36,8 @@ extern void *memcpy(void *, const void *, __kernel_size_t); extern void *__memcpy(void *, const void *, __kernel_size_t);
#define __HAVE_ARCH_MEMCPY_MC -extern unsigned long *memcpy_mcs(void *, const void *, __kernel_size_t); -extern unsigned long *__memcpy_mcs(void *, const void *, __kernel_size_t); +extern unsigned long memcpy_mcs(void *, const void *, __kernel_size_t); +extern unsigned long __memcpy_mcs(void *, const void *, __kernel_size_t);
#define __HAVE_ARCH_MEMMOVE extern void *memmove(void *, const void *, __kernel_size_t);
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6AQE8 CVE: NA
-------------------------------
The function memcpy_mcs() is designed to copy in memory and should be supported by kasan.
Signed-off-by: Tong Tiangen tongtiangen@huawei.com --- mm/kasan/common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 6c8fa5aed54c..b273b362034f 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -109,6 +109,18 @@ void *memcpy(void *dest, const void *src, size_t len) return __memcpy(dest, src, len); }
+#ifdef __HAVE_ARCH_MEMCPY_MC +#undef memcpy_mcs +unsigned long memcpy_mcs(void *dest, const void *src, size_t len) +{ + if (!check_memory_region((unsigned long)src, len, false, _RET_IP_) || + !check_memory_region((unsigned long)dest, len, true, _RET_IP_)) + return (unsigned long)len; + + return __memcpy_mcs(dest, src, len); +} +#endif + /* * Poisons the shadow memory for 'size' bytes starting from 'addr'. * Memory addresses should be aligned to KASAN_SHADOW_SCALE_SIZE.