Skip to content

Stack alignment plugin option boot failure with CONFIG_CFI_CLANG #1384

@nathanchance

Description

@nathanchance

My commit 0024430e920f ("x86/build: Fix location of '-plugin-opt=' flags") prevents my WSL2 virtual machine from booting on my Intel based laptop, even though my AMD based workstation has no issues with the exact same binary.

So far, I have verified that:

  1. The issue is not present with just CONFIG_LTO_CLANG_THIN, only with CONFIG_LTO_CLANG_THIN + CONFIG_CFI_CLANG (regardless of CONFIG_CFI_PERMISSIVE).
  2. The issue is not present with CONFIG_CFI_CLANG and the following diff:
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 307529417021..3ecc786f8144 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -200,8 +200,7 @@ endif
 KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)

 ifdef CONFIG_LTO_CLANG
-KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \
-                  -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
+KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel
 endif

 ifdef CONFIG_X86_NEED_RELOCS

Unfortunately, getting kernel logs from WSL2 seems impossible but I will continue to research that. QEMU within WSL2 does not reproduce the issue. I will see if I can reproduce in some other way. This does not appear to LLVM version dependent because I can reproduce at LLVM 12.0.0 but I can try earlier versions to see.

cc @samitolvanen

Metadata

Metadata

Assignees

No one assigned

    Labels

    [ARCH] x86_64This bug impacts ARCH=x86_64[BUG] linux-nextThis is an issue only seen in linux-next[FEATURE] CFIRelated to building the kernel with Clang Control Flow Integrity[FIXED][LINUX] 5.13This bug was fixed in Linux 5.13

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions