x86/purgatory: Compile purgatory with -D__DISABLE_EXPORTS
PATCH 1/1 x86/purgatory: Compile purgatory with -D__DISABLE_EXPORTS
From: Arnd Bergmann <[email protected]>
A previous patch fixed compile-time issues by setting __NO_FORTIFY for all of the purgatory code, but this is insufficient and still leaves build failures that appeared recently in linux-next:
ld.lld: error: undefined symbol: __memset
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
string.carch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memset_2)
ld.lld: error: undefined symbol: __memmove
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
string.carch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memmove_3)
Set __DISABLE_EXPORTS as well, to avoid pulling in a reference to the wrong string functions.
--- arch/x86/purgatory/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/purgatory/Makefile +1 -3
@@ -11,8 +11,6 @@ $(obj)/string.o: $(srctree)/arch/x86/boot/compressed/string.c FORCE $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE $(call if_changed_rule,cc_o_c) -CFLAGS_sha256.o := -D__DISABLE_EXPORTS - # When profile-guided optimization is enabled, llvm emits two different # overlapping text sections, which is not supported by kexec. Remove profile # optimization flags.
@@ -37,7 +35,7 @@ PURGATORY_CFLAGS := -mcmodel=small -ffreestanding -fno-zero-initialized-in-bss - PURGATORY_CFLAGS += -fpic -fvisibility=hidden PURGATORY_CFLAGS += $(DISABLE_KSTACK_ERASE) -DDISABLE_BRANCH_PROFILING PURGATORY_CFLAGS += -fno-stack-protector -PURGATORY_CFLAGS += -D__NO_FORTIFY +PURGATORY_CFLAGS += -D__NO_FORTIFY -D__DISABLE_EXPORTS # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # in turn leaves some undefined symbols like __fentry__ in purgatory and not
Signature · 1 line
2.53.0
Quoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
A previous patch fixed compile-time issues by setting
__NO_FORTIFYfor all of the purgatory code, but this is insufficient and still leaves build failures that appeared recently in linux-next:ld.lld: error: undefined symbol:
__memsetQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
string.carch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memset_2)ld.lld: error: undefined symbol:
__memmoveQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
string.carch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memmove_3)
Quoted 9 lines
Set
__DISABLE_EXPORTSas well, to avoid pulling in a reference to the wrong string functions.Fixes 65cbe410d312 ("x86/purgatory: Compile purgatory with -D__NO_FORTIFY")Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/purgatory/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
I dropped the patch this fixes already, as I mentioned at
https://lore.kernel.org/linux-crypto/20260924174911.GA1978@sol/ . It's gone from linux-next now. I think Thomas Huth is planning to send a fixed version, together with the two patches that depend on this.
But compiling all of purgatory (and not just sha256.o as is the status quo) with -D__NO_FORTIFY -D__DISABLE_EXPORTS sounds good to me.
Alternatively it could be just sha256.o and purgatory.o specifically. But it seems it might as well just be all files.
- Eric
Quoted 25 lines · Eric Biggers
Quoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
A previous patch fixed compile-time issues by setting
__NO_FORTIFYfor all of the purgatory code, but this is insufficient and still leaves build failures that appeared recently in linux-next:ld.lld: error: undefined symbol:
__memsetQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
string.carch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memset_2)ld.lld: error: undefined symbol:
__memmoveQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
referenced by
string.carch/x86/purgatory/purgatory.ro:(__UNIQUE_ID_addressable___memmove_3)Quoted 9 lines
Set
__DISABLE_EXPORTSas well, to avoid pulling in a reference to the wrong string functions.Fixes 65cbe410d312 ("x86/purgatory: Compile purgatory with -D__NO_FORTIFY")Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/purgatory/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 7 lines
I dropped the patch this fixes already, as I mentioned at
https://lore.kernel.org/linux-crypto/20260924174911.GA1978@sol/ . It's gone from linux-next now. I think Thomas Huth is planning to send a fixed version, together with the two patches that depend on this.But compiling all of purgatory (and not just sha256.o as is the status quo) with -D__NO_FORTIFY -D__DISABLE_EXPORTS sounds good to me.
Yes, I think that's the way to go, and I've now also verified that the change is working. I've now send a new version of the patch here:
https://lore.kernel.org/lkml/[email protected]/
Thomas