forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
Changed defaultsThe compiler/linker/etc. has been patched to implicitly change a default valueThe compiler/linker/etc. has been patched to implicitly change a default value[ARCH] x86_64This bug impacts ARCH=x86_64This bug impacts ARCH=x86_64[FEATURE] CFIRelated to building the kernel with Clang Control Flow IntegrityRelated to building the kernel with Clang Control Flow Integrity
Description
Greetings. I've tried to build an x86_64 kernel with CFI enabled. It's a "distro kernel" config of sorts, kitted out with every driver & every bit of functionality. The x86 CoCo infrastructure breaks when you enable CFI. Here's the relevant log snippet:
<4>[ 0.913788] ------------[ cut here ]------------
<4>[ 0.916633] no CFI hash found at: __cfi_cc_platform_has+0x0/0x20 ffffffffaa451460 90 90 90 90 90
<4>[ 0.919977] WARNING: CPU: 0 PID: 0 at arch/x86/kernel/alternative.c:1183 __apply_fineibt+0xb15/0xb80
<4>[ 0.923297] Modules linked in:
<4>[ 0.924268] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.8.5-ehhhhhhhhh #1 77789fd3cc3ef13083ac0da371db90ee68380b84
<4>[ 0.926629] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-stable202302-for-qemu 03/01/2023
<4>[ 0.929965] RIP: 0010:__apply_fineibt+0xb15/0xb80
<4>[ 0.933296] Code: 80 7c 24 0c 00 74 4f 48 c7 c7 6e b5 a0 aa eb 41 48 c7 c7 c0 1b a2 aa 48 89 de 48 89 da b9 05 00 00 00 49 89 d8 e8 8b b2 09 00 <0f> 0b eb 1c 48 c7 c7 c0 1b a2 aa 48 89 ee 48 89 ea b9 05 00 00 00
<4>[ 0.936635] RSP: 0000:ffffffffab203e68 EFLAGS: 00010246
<4>[ 0.939962] RAX: 0000000000000000 RBX: ffffffffaa451460 RCX: 0000000000000000
<4>[ 0.942013] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
<4>[ 0.943298] RBP: 000000009434d7bb R08: 0000000000000000 R09: 0000000000000000
<4>[ 0.945433] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffac202de0
<4>[ 0.946637] R13: ffffffffac1f5258 R14: ffffffffac32fd18 R15: ffffffffac304e94
<4>[ 0.949962] FS: 0000000000000000(0000) GS:ffff9dcdf6c00000(0000) knlGS:0000000000000000
<4>[ 0.953301] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4>[ 0.956629] CR2: ffff9dcd55001000 CR3: 0000000213a22001 CR4: 0000000000060ef0
<4>[ 0.959968] Call Trace:
<4>[ 0.963299] <TASK>
<4>[ 0.963983] ? __warn+0xcf/0x1e0
<4>[ 0.966630] ? __apply_fineibt+0xb15/0xb80
<4>[ 0.969964] ? report_bug+0x154/0x220
<4>[ 0.973299] ? handle_bug+0x3d/0x90
<4>[ 0.976630] ? exc_invalid_op+0x1a/0x70
<4>[ 0.977841] ? asm_exc_invalid_op+0x1a/0x20
<4>[ 0.979972] ? memset_orig+0xb0/0xb0
<4>[ 0.981083] ? __apply_fineibt+0xb15/0xb80
<4>[ 0.983297] ? __apply_fineibt+0xb15/0xb80
<4>[ 0.984587] alternative_instructions+0x3f/0x15b
<4>[ 0.986635] arch_cpu_finalize_init+0x46/0xbb
<4>[ 0.987978] start_kernel+0x3bb/0x48b
<4>[ 0.989964] x86_64_start_reservations+0x32/0x40
<4>[ 0.991376] x86_64_start_kernel+0x78/0x8b
<4>[ 0.993300] secondary_startup_64_no_verify+0x185/0x19b
<4>[ 0.994871] </TASK>
<4>[ 0.996630] ---[ end trace 0000000000000000 ]---
You don't need any CoCo-supporting HW or setup to trigger this, this'll break anywhere on boot. Specifically, it happens during the alternative patching stage, so you can't miss it. Just enable any option that enables CONFIG_ARCH_HAS_CC_PLATFORM
(enables the cc_platform_has
function seen above).
I am compiling with LLVM=1 LLVM_IAS=1
, with self-built LLVM 18.1.4.
Let me know if you need the config.
Metadata
Metadata
Assignees
Labels
Changed defaultsThe compiler/linker/etc. has been patched to implicitly change a default valueThe compiler/linker/etc. has been patched to implicitly change a default value[ARCH] x86_64This bug impacts ARCH=x86_64This bug impacts ARCH=x86_64[FEATURE] CFIRelated to building the kernel with Clang Control Flow IntegrityRelated to building the kernel with Clang Control Flow Integrity