Skip to content

Commit 59a68d4

Browse files
rmurphy-armctmarinas
authored andcommitted
arm64: Mitigate MTE issues with str{n}cmp()
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: 758602c ("arm64: Import latest version of Cortex Strings' strcmp") Fixes: 020b199 ("arm64: Import latest version of Cortex Strings' strncmp") Cc: <[email protected]> # 5.14.x Reported-by: Branislav Rankov <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/34dc4d12eec0adae49b0ac927df642ed10089d40.1631890770.git.robin.murphy@arm.com Signed-off-by: Catalin Marinas <[email protected]>
1 parent 8c8a3b5 commit 59a68d4

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

arch/arm64/include/asm/assembler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ alternative_endif
525525
#define EXPORT_SYMBOL_NOKASAN(name) EXPORT_SYMBOL(name)
526526
#endif
527527

528+
#ifdef CONFIG_KASAN_HW_TAGS
529+
#define EXPORT_SYMBOL_NOHWKASAN(name)
530+
#else
531+
#define EXPORT_SYMBOL_NOHWKASAN(name) EXPORT_SYMBOL_NOKASAN(name)
532+
#endif
528533
/*
529534
* Emit a 64-bit absolute little endian symbol reference in a way that
530535
* ensures that it will be resolved at build time, even when building a

arch/arm64/include/asm/string.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ extern char *strrchr(const char *, int c);
1212
#define __HAVE_ARCH_STRCHR
1313
extern char *strchr(const char *, int c);
1414

15+
#ifndef CONFIG_KASAN_HW_TAGS
1516
#define __HAVE_ARCH_STRCMP
1617
extern int strcmp(const char *, const char *);
1718

1819
#define __HAVE_ARCH_STRNCMP
1920
extern int strncmp(const char *, const char *, __kernel_size_t);
21+
#endif
2022

2123
#define __HAVE_ARCH_STRLEN
2224
extern __kernel_size_t strlen(const char *);

arch/arm64/lib/strcmp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ L(done):
173173
ret
174174

175175
SYM_FUNC_END_PI(strcmp)
176-
EXPORT_SYMBOL_NOKASAN(strcmp)
176+
EXPORT_SYMBOL_NOHWKASAN(strcmp)

arch/arm64/lib/strncmp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,4 @@ L(ret0):
258258
ret
259259

260260
SYM_FUNC_END_PI(strncmp)
261-
EXPORT_SYMBOL_NOKASAN(strncmp)
261+
EXPORT_SYMBOL_NOHWKASAN(strncmp)

0 commit comments

Comments
 (0)