Skip to contentSkip to conversation

security: Restrict CONFIG_ZERO_CALL_USED_REGS to gcc or clang > 15.0.6

PATCH Applied Nathan Chancellor 2 participants 2 messages Dec 14, 2022 – Dec 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 security: Restrict CONFIG_ZERO_CALL_USED_REGS to gcc or clang > 15.0.6

A bad bug in clang's implementation of -fzero-call-used-regs can result in NULL pointer dereferences (see the links above the check for more information). Restrict CONFIG_CC_HAS_ZERO_CALL_USED_REGS to either a supported GCC version or a clang newer than 15.0.6, which will catch both a theoretical 15.0.7 and the upcoming 16.0.0, which will both have the bug fixed.

---
 security/Kconfig.hardening | 3 +++
 1 file changed, 3 insertions(+)
security/Kconfig.hardening +3 -0
index d766b7d0ffd1..53baa95cb644 100644
@@ -257,6 +257,9 @@ config INIT_ON_FREE_DEFAULT_ON
 
 config CC_HAS_ZERO_CALL_USED_REGS
 	def_bool $(cc-option,-fzero-call-used-regs=used-gpr)
+	# https://github.com/ClangBuiltLinux/linux/issues/1766
+	# https://github.com/llvm/llvm-project/issues/59242
+	depends on !CC_IS_CLANG || CLANG_VERSION > 150006
 
 config ZERO_CALL_USED_REGS
 	bool "Enable register zeroing on function exit"

base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476

Signature · 1 line
2.39.0
Applied
#1 lore raw
Quoted 8 lines · Nathan Chancellor

A bad bug in clang's implementation of -fzero-call-used-regs can result in NULL pointer dereferences (see the links above the check for more information). Restrict CONFIG_CC_HAS_ZERO_CALL_USED_REGS to either a supported GCC version or a clang newer than 15.0.6, which will catch both a theoretical 15.0.7 and the upcoming 16.0.0, which will both have the bug fixed.

[...]

Applied to for-next/hardening, thanks! (And I'll send it for v6.2-rc1 too.)

[1/1] security: Restrict CONFIG_ZERO_CALL_USED_REGS to gcc or clang > 15.0.6

      https://git.kernel.org/kees/c/d6a9fb87e9d1
Signature · 1 line
Kees Cook