Skip to content

kexec_file is broken with LLVM 18 and newer on x86_64 #2016

Closed
@0n-s

Description

@0n-s

Don't really think there's much to explain here. Very nice & simple reproducer & splat:

# kexec -s -l /mnt/vmlinuz-6.8.6 --reuse-cmdline
<4>[  319.553852] ------------[ cut here ]------------
<4>[  319.555068] WARNING: CPU: 0 PID: 1501 at kernel/kexec_file.c:936 kexec_load_purgatory+0x3b1/0x4a0
<4>[  319.557254] Modules linked in: 9p netfs drbd lru_cache libcrc32c crc32c_generic af_packet scsi_transport_iscsi cfg80211 qrtr rfkill uinput edac_core intel_rapl_msr intel_rapl_common kvm_intel sr_mod cdrom kvm ahci libahci irqbypass crct10dif_pclmul crct10dif_common crc32_pclmul crc32c_intel polyval_clmulni polyval_generic libata gf128mul ghash_clmulni_intel sha512_ssse3 psmouse sha256_ssse3 input_leds iTCO_wdt sha1_ssse3 atkbd intel_pmc_bxt iTCO_vendor_support vivaldi_fmap ppdev libps2 watchdog rapl evdev snd_pcm i8042 parport_pc bochs 9pnet_virtio drm_vram_helper snd_timer drm_ttm_helper 9pnet parport rtc_cmos serio e1000e snd ttm lpc_ich i2c_i801 soundcore button pcspkr i2c_smbus ksmbd rdma_cm iw_cm ib_cm ib_core dm_multipath dm_mod fuse nls_ucs2_utils cifs_arc4 efi_pstore scsi_mod scsi_common dmi_sysfs qemu_fw_cfg virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev autofs4 aesni_intel crypto_simd cryptd
<4>[  319.576191] CPU: 0 PID: 1501 Comm: kexec Tainted: G        W          6.8.6 #1 191f8fecad84ce150bee56a123c22a930e1c0594
<4>[  319.578826] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-stable202302-for-qemu 03/01/2023
<4>[  319.581167] RIP: 0010:kexec_load_purgatory+0x3b1/0x4a0
<4>[  319.582449] Code: 54 24 0c 48 89 c8 48 29 d0 0f 82 4a ff ff ff 49 03 54 24 1c 48 39 d1 0f 83 3c ff ff ff 49 8b 17 48 39 4a 18 0f 84 0e ff ff ff <0f> 0b e9 28 ff ff ff 66 85 c9 74 13 48 8b 5a 28 48 01 d3 45 31 e4
<4>[  319.586837] RSP: 0018:ffffb4e0c0e13bc0 EFLAGS: 00010206
<4>[  319.588123] RAX: 0000000000000000 RBX: 00000000000000d0 RCX: 0000000000000000
<4>[  319.589883] RDX: ffff975f440c7400 RSI: 0000000000000010 RDI: ffffb4e0c027d0c0
<4>[  319.591604] RBP: 0000000000000002 R08: 0000003d8b4c0000 R09: cc0000000025ff00
<4>[  319.593359] R10: 0000003d8b4c0000 R11: cc0000000025ff00 R12: ffffb4e0c0139084
<4>[  319.595079] R13: 00000002bfffe000 R14: ffff975f440c76e0 R15: ffffb4e0c0e13c50
<4>[  319.596833] FS:  00005a2dc5157740(0000) GS:ffff975fb6c00000(0000) knlGS:0000000000000000
<4>[  319.598763] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4>[  319.600202] CR2: 00005a2dc5364370 CR3: 0000000181be4002 CR4: 0000000000060ef0
<4>[  319.601928] Call Trace:
<4>[  319.602597]  <TASK>
<4>[  319.603198]  ? __warn+0xcf/0x1e0
<4>[  319.604038]  ? kexec_load_purgatory+0x3b1/0x4a0
<4>[  319.605170]  ? report_bug+0x154/0x210
<4>[  319.606121]  ? handle_bug+0x3d/0x90
<4>[  319.607037]  ? exc_invalid_op+0x1a/0x60
<4>[  319.608012]  ? asm_exc_invalid_op+0x1a/0x20
<4>[  319.609077]  ? kexec_load_purgatory+0x3b1/0x4a0
<4>[  319.610232]  bzImage64_load+0x1c7/0x6e0
<4>[  319.611222]  kexec_image_load_default+0x57/0x80
<4>[  319.612354]  __se_sys_kexec_file_load+0x57c/0x720
<4>[  319.613570]  do_syscall_64+0x90/0x150
<4>[  319.614511]  ? syscall_exit_work+0x109/0x1a0
<4>[  319.615587]  ? syscall_exit_to_user_mode+0x96/0xc0
<4>[  319.616819]  ? do_syscall_64+0x9c/0x150
<4>[  319.617794]  ? do_user_addr_fault+0x37d/0x6a0
<4>[  319.618891]  ? syscall_exit_to_user_mode+0x96/0xc0
<4>[  319.620118]  entry_SYSCALL_64_after_hwframe+0x78/0x80
<4>[  319.621372] RIP: 0033:0x5a2dc5229469
<4>[  319.622302] Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 8f 19 0b 00 f7 d8 64 89 01 48
<4>[  319.626711] RSP: 002b:000077d8310cac88 EFLAGS: 00000246 ORIG_RAX: 0000000000000140
<4>[  319.628531] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00005a2dc5229469
<4>[  319.630282] RDX: 000000000000001c RSI: 00000000ffffffff RDI: 0000000000000003
<4>[  319.632001] RBP: 0000000000000003 R08: 0000000000000004 R09: 000077d8310cb453
<4>[  319.633755] R10: 00005a2dc6c84010 R11: 0000000000000246 R12: 00005a2dc5362080
<4>[  319.635476] R13: 00005a2dc5362120 R14: 000077d8310cb008 R15: 0000000000000004
<4>[  319.637234]  </TASK>
<4>[  319.637835] ---[ end trace 0000000000000000 ]---
<3>[  319.638986] kexec: Overflow in relocation type 10 value 0x2bfffb7f0
<3>[  319.643562] kexec-bzImage64: Loading purgatory failed

vmlinuz-6.8.6 is a bzImage with EFI_STUB enabled, if that matters.

Unsurprisingly trying to kexec -e here will result in a hang.

Metadata

Metadata

Assignees

Labels

[ARCH] x86_64This bug impacts ARCH=x86_64[BUG] linuxA bug that should be fixed in the mainline kernel.[FIXED][LINUX] 6.10This bug was fixed in Linux 6.10

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions