Skip to contentSkip to conversation

arm64: disable -fsanitize=shadow-call-stack for big-endian

PATCH In review Arnd Bergmann 4 participants 6 messages May 27, 2020 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: disable -fsanitize=shadow-call-stack for big-endian

clang-11 and earlier do not support -fsanitize=shadow-call-stack in combination with -mbig-endian, but the Kconfig check does not pass the endianess flag, so building a big-endian kernel with this fails at build time:

clang: error: unsupported option '-fsanitize=shadow-call-stack' for target 'aarch64_be-unknown-linux'

Change the Kconfig check to let Kconfig figure this out earlier and prevent the broken configuration. I assume this is a bug in clang that needs to be fixed, but we also have to work around existing releases.

Fixes 5287569a790d ("arm64: Implement Shadow Call Stack")
---
 arch/arm64/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +3 -1
index a82441d6dc36..692e1575a6c8 100644
@@ -1031,7 +1031,9 @@ config ARCH_ENABLE_SPLIT_PMD_PTLOCK
 
 # Supported by clang >= 7.0
 config CC_HAVE_SHADOW_CALL_STACK
-	def_bool $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18)
+	bool
+	default $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18 -mbig-endian) if CPU_BIG_ENDIAN
+	default $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18 -mlittle-endian) if !CPU_BIG_ENDIAN
 
 config SECCOMP
 	bool "Enable seccomp to safely compute untrusted bytecode"
Signature · 7 lines
2.26.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
reviewer
#1 lore raw
Quoted 7 lines · Arnd Bergmann

clang-11 and earlier do not support -fsanitize=shadow-call-stack in combination with -mbig-endian, but the Kconfig check does not pass the endianess flag, so building a big-endian kernel with this fails at build time:

clang: error: unsupported option '-fsanitize=shadow-call-stack' for target 'aarch64_be-unknown-linux'

Quoted 8 lines

Change the Kconfig check to let Kconfig figure this out earlier and prevent the broken configuration. I assume this is a bug in clang that needs to be fixed, but we also have to work around existing releases.

Fixes 5287569a790d ("arm64: Implement Shadow Call Stack")

I suspect this is similar to the patchable-function-entry issue, and this is an oversight that we'd rather fix toolchain side.

Nick, Fangrui, thoughts?

Mark.

Quoted 27 lines
---
 arch/arm64/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +3 -1
index a82441d6dc36..692e1575a6c8 100644
@@ -1031,7 +1031,9 @@ config ARCH_ENABLE_SPLIT_PMD_PTLOCK
 
 # Supported by clang >= 7.0
 config CC_HAVE_SHADOW_CALL_STACK
-	def_bool $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18)
+	bool
+	default $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18 -mbig-endian) if CPU_BIG_ENDIAN
+	default $(cc-option, -fsanitize=shadow-call-stack -ffixed-x18 -mlittle-endian) if !CPU_BIG_ENDIAN
 
 config SECCOMP
 	bool "Enable seccomp to safely compute untrusted bytecode"
Signature · 7 lines
2.26.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw
Quoted 14 lines · Mark Rutland
Quoted 12 lines · Arnd Bergmann

clang-11 and earlier do not support -fsanitize=shadow-call-stack in combination with -mbig-endian, but the Kconfig check does not pass the endianess flag, so building a big-endian kernel with this fails at build time:

clang: error: unsupported option '-fsanitize=shadow-call-stack' for target 'aarch64_be-unknown-linux'

Change the Kconfig check to let Kconfig figure this out earlier and prevent the broken configuration. I assume this is a bug in clang that needs to be fixed, but we also have to work around existing releases.

Quoted 8 lines
Quoted 3 lines
Fixes 5287569a790d ("arm64: Implement Shadow Call Stack")

I suspect this is similar to the patchable-function-entry issue, and this is an oversight that we'd rather fix toolchain side.

Nick, Fangrui, thoughts?

Exactly, Fangrui already has a fix: https://reviews.llvm.org/D80647.
Thanks Fangrui!
It seems it's easy in the codebase to check the specific ABI, which isn't explicitly LE, rather than use a method that checks the ISA regardless of endianness.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
Quoted 20 lines · Nick Desaulniers' via Clang Built Linux
Quoted 18 lines · Mark Rutland
Quoted 15 lines · Arnd Bergmann

clang-11 and earlier do not support -fsanitize=shadow-call-stack in combination with -mbig-endian, but the Kconfig check does not pass the endianess flag, so building a big-endian kernel with this fails at build time:

clang: error: unsupported option '-fsanitize=shadow-call-stack' for target 'aarch64_be-unknown-linux'

Change the Kconfig check to let Kconfig figure this out earlier and prevent the broken configuration. I assume this is a bug in clang that needs to be fixed, but we also have to work around existing releases.

Fixes 5287569a790d ("arm64: Implement Shadow Call Stack")
Quoted 7 lines
Quoted 4 lines

I suspect this is similar to the patchable-function-entry issue, and this is an oversight that we'd rather fix toolchain side.

Nick, Fangrui, thoughts?

Exactly, Fangrui already has a fix: https://reviews.llvm.org/D80647.
Thanks Fangrui!

Ok, great! I had opened the bug first so I could reference it in the commit changelog, it seems the fix came fast than I managed to send out the kernel workaround.

Do we still want the kernel workaround anyway to make it work with older clang versions, or do we expect to fall back to not use the integrated assembler for the moment?

Arnd

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#4 lore raw
Quoted 34 lines · Arnd Bergmann
Quoted 20 lines · Nick Desaulniers' via Clang Built Linux
Quoted 18 lines · Mark Rutland
Quoted 15 lines · Arnd Bergmann

clang-11 and earlier do not support -fsanitize=shadow-call-stack in combination with -mbig-endian, but the Kconfig check does not pass the endianess flag, so building a big-endian kernel with this fails at build time:

clang: error: unsupported option '-fsanitize=shadow-call-stack' for target 'aarch64_be-unknown-linux'

Change the Kconfig check to let Kconfig figure this out earlier and prevent the broken configuration. I assume this is a bug in clang that needs to be fixed, but we also have to work around existing releases.

Fixes 5287569a790d ("arm64: Implement Shadow Call Stack")
Quoted 7 lines
Quoted 4 lines

I suspect this is similar to the patchable-function-entry issue, and this is an oversight that we'd rather fix toolchain side.

Nick, Fangrui, thoughts?

Exactly, Fangrui already has a fix: https://reviews.llvm.org/D80647.
Thanks Fangrui!

Ok, great! I had opened the bug first so I could reference it in the commit changelog, it seems the fix came fast than I managed to send out the kernel workaround.

Quoted 5 lines

Do we still want the kernel workaround anyway to make it work with older clang versions, or do we expect to fall back to not use the integrated assembler for the moment?

Arnd

We can condition it on CLANG_VERSION >= 100001 (assuming Tom (CCed)
is happy (and there is still time) cherrying pick the two commits https://bugs.llvm.org/show_bug.cgi?id=46076 to clang 10.0.1)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 35 lines · Fangrui Song' via Clang Built Linux
Quoted 34 lines · Arnd Bergmann
Quoted 20 lines · Nick Desaulniers' via Clang Built Linux
Quoted 18 lines · Mark Rutland
Quoted 15 lines · Arnd Bergmann

clang-11 and earlier do not support -fsanitize=shadow-call-stack in combination with -mbig-endian, but the Kconfig check does not pass the endianess flag, so building a big-endian kernel with this fails at build time:

clang: error: unsupported option '-fsanitize=shadow-call-stack' for target 'aarch64_be-unknown-linux'

Change the Kconfig check to let Kconfig figure this out earlier and prevent the broken configuration. I assume this is a bug in clang that needs to be fixed, but we also have to work around existing releases.

Fixes 5287569a790d ("arm64: Implement Shadow Call Stack")
Quoted 7 lines
Quoted 4 lines

I suspect this is similar to the patchable-function-entry issue, and this is an oversight that we'd rather fix toolchain side.

Nick, Fangrui, thoughts?

Exactly, Fangrui already has a fix: https://reviews.llvm.org/D80647.
Thanks Fangrui!

Ok, great! I had opened the bug first so I could reference it in the commit changelog, it seems the fix came fast than I managed to send out the kernel workaround.

Quoted 6 lines
Quoted 3 lines

Do we still want the kernel workaround anyway to make it work with older clang versions, or do we expect to fall back to not use the integrated assembler for the moment?

We can condition it on CLANG_VERSION >= 100001 (assuming Tom (CCed)
is happy (and there is still time) cherrying pick the two commits https://bugs.llvm.org/show_bug.cgi?id=46076 to clang 10.0.1)

Good idea. I assume we will keep requiring fairly recent clang versions for a while now, so chances are that 10.1 or 11.0 becomes the minimum supported version not too far in the future and then the workaround can be dropped again.

Arnd