* [PATCH] ARM: current: prevent literal references from going out of range
@ 2021-12-20 22:52 Ard Biesheuvel
0 siblings, 0 replies; only message in thread
From: Ard Biesheuvel @ 2021-12-20 22:52 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: arnd, linux, Ard Biesheuvel, Nathan Chancellor
Nathan reports that the new get_current() accessor may cause problems at
build time due to the use of a literal to hold the address of the
variable that stores the 'current' pointer. This is due to the fact that
LLD before v14 does not support the PC-relative group relocations that
are normally used for this, and the fallback relies on literals without
emitting the literal pools explictly using the .ltorg directive.
Since emitting a literal pool in this particular case is not possible,
avoid the LOAD_SYM_ARMV6() entirely, and use the ordinary C assigment
instead.
While at it, add a .ltorg directive to the other instantiation of
LOAD_SYM_ARMV6(), which could potentially suffer from the same issue,
but can be fixed by an .ltorg directive due to the existence of an
unconditional branch right after it.
Fixes: 9c46929e7989 ("ARM: implement THREAD_INFO_IN_TASK for uniprocessor systems")
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/1551
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm/include/asm/current.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/current.h b/arch/arm/include/asm/current.h
index 69ecf4c6c725..6b2e4c9fae35 100644
--- a/arch/arm/include/asm/current.h
+++ b/arch/arm/include/asm/current.h
@@ -39,6 +39,7 @@ static inline __attribute_const__ struct task_struct *get_current(void)
" .subsection 1 \n\t"
"2: " LOAD_SYM_ARMV6(%0, __current) " \n\t"
" b 1b \n\t"
+ " .ltorg \n\t"
" .previous \n\t"
" .pushsection \".alt.smp.init\", \"a\" \n\t"
" .long 0b - . \n\t"
@@ -46,7 +47,8 @@ static inline __attribute_const__ struct task_struct *get_current(void)
" .popsection \n\t"
#endif
: "=r"(cur));
-#elif __LINUX_ARM_ARCH__>=7 || \
+#elif __LINUX_ARM_ARCH__>= 7 || \
+ (defined(CONFIG_LD_IS_LLD) && CONFIG_LLD_VERSION < 140000) || \
(defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS))
cur = __current;
#else
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-20 22:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-20 22:52 [PATCH] ARM: current: prevent literal references from going out of range Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).