]> git.baikalelectronics.ru Git - kernel.git/commitdiff
arm64: Mitigate MTE issues with str{n}cmp()
authorRobin Murphy <robin.murphy@arm.com>
Fri, 17 Sep 2021 14:59:30 +0000 (15:59 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 21 Sep 2021 13:50:19 +0000 (14:50 +0100)
As with strlen(), the patches importing the updated str{n}cmp()
implementations were originally developed and tested before the
advent of CONFIG_KASAN_HW_TAGS, and have subsequently revealed
not to be MTE-safe. Since in-kernel MTE is still a rather niche
case, let it temporarily fall back to the generic C versions for
correctness until we can figure out the best fix.

Fixes: 59743625f0e3 ("arm64: Import latest version of Cortex Strings' strcmp")
Fixes: 90c04769905b ("arm64: Import latest version of Cortex Strings' strncmp")
Cc: <stable@vger.kernel.org> # 5.14.x
Reported-by: Branislav Rankov <branislav.rankov@arm.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/34dc4d12eec0adae49b0ac927df642ed10089d40.1631890770.git.robin.murphy@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/string.h
arch/arm64/lib/strcmp.S
arch/arm64/lib/strncmp.S

index 89faca0e740d03a306a70b49d19a91c4a3023886..bfa58409a4d4da3221f44ffc5d08bae2812b92cf 100644 (file)
@@ -525,6 +525,11 @@ alternative_endif
 #define EXPORT_SYMBOL_NOKASAN(name)    EXPORT_SYMBOL(name)
 #endif
 
+#ifdef CONFIG_KASAN_HW_TAGS
+#define EXPORT_SYMBOL_NOHWKASAN(name)
+#else
+#define EXPORT_SYMBOL_NOHWKASAN(name)  EXPORT_SYMBOL_NOKASAN(name)
+#endif
        /*
         * Emit a 64-bit absolute little endian symbol reference in a way that
         * ensures that it will be resolved at build time, even when building a
index 3a3264ff47b9709df741eaece1c8eae995a5ffb3..95f7686b728d7e5689f46ce6ae37fe7724779be2 100644 (file)
@@ -12,11 +12,13 @@ extern char *strrchr(const char *, int c);
 #define __HAVE_ARCH_STRCHR
 extern char *strchr(const char *, int c);
 
+#ifndef CONFIG_KASAN_HW_TAGS
 #define __HAVE_ARCH_STRCMP
 extern int strcmp(const char *, const char *);
 
 #define __HAVE_ARCH_STRNCMP
 extern int strncmp(const char *, const char *, __kernel_size_t);
+#endif
 
 #define __HAVE_ARCH_STRLEN
 extern __kernel_size_t strlen(const char *);
index d7bee210a798af7ab0a387279430cbd24b42c041..83bcad72ec97205f4e7dfd04d5d92ee304d81c13 100644 (file)
@@ -173,4 +173,4 @@ L(done):
        ret
 
 SYM_FUNC_END_PI(strcmp)
-EXPORT_SYMBOL_NOKASAN(strcmp)
+EXPORT_SYMBOL_NOHWKASAN(strcmp)
index 48d44f7fddb134c4cfdb4fc40b3a7c1f0f656b7e..e42bcfcd37e6f691a8b78e3c17a6330272cbefd0 100644 (file)
@@ -258,4 +258,4 @@ L(ret0):
        ret
 
 SYM_FUNC_END_PI(strncmp)
-EXPORT_SYMBOL_NOKASAN(strncmp)
+EXPORT_SYMBOL_NOHWKASAN(strncmp)