CVE: CVE-2023-54241
Published: 2025-12-30
Description: In the Linux kernel, the following vulnerability has been resolved:

MIPS: KVM: Fix NULL pointer dereference

After commit 45c7e8af4a5e3f0bea4ac209 ("MIPS: Remove KVM_TE support") we
get a NULL pointer dereference when creating a KVM guest:

[  146.243409] Starting KVM with MIPS VZ extensions
[  149.849151] CPU 3 Unable to handle kernel paging request at virtual address [PII_REDACTED], epc == ffffffffc06356ec, ra == ffffffffc063568c
[  149.849177] Oops[#1]:
[  149.849182] CPU: 3 PID: 2265 Comm: qemu-system-mip Not tainted 6.4.0-rc3+ #1671
[  149.849188] Hardware name: THTF CX TL630 Series/THTF-LS3A4000-7A1000-ML4A, BIOS KL4.1F.TF.D.166.201225.R 12/25/2020
[  149.849192] $ 0   : [PII_REDACTED][PII_REDACTED]00cce0 [PII_REDACTED] ffffffff8119c740
[  149.849209] $ 4   :[PII_REDACTED]00cce[PII_REDACTED]00cce1 [PII_REDACTED] [PII_REDACTED]
[  149.849221] $ 8   :[PII_REDACTED]58bb36 ffffffff81421ac0 [PII_REDACTED][PII_REDACTED]400dc0
[  149.849233] $12   :[PII_REDACTED]a07cc8 ffffffff80e40e38 [PII_REDACTED][PII_REDACTED]400dc0
[  149.849245] $16   : [PII_REDACTED][PII_REDACTED]cd0[PII_REDACTED]106cd0[PII_REDACTED]100cce000
[  149.849257] $20   : ffffffffc0632b28 ffffffffc05b31b0[PII_REDACTED]ccca00 [PII_REDACTED]
[  149.849269] $24   :[PII_REDACTED]cd09ce ffffffff802f69d0
[  149.849281] $28   :[PII_REDACTED]a04[PII_REDACTED]102a07cd0[PII_REDACTED]6a8000 ffffffffc063568c
[  149.849293] Hi    : 00000335b2111e66
[  149.849295] Lo    : 6668d90061ae0ae9
[  149.849298] epc   : ffffffffc06356ec kvm_vz_vcpu_setup+0xc4/0x328 [kvm]
[  149.849324] ra    : ffffffffc063568c kvm_vz_vcpu_setup+0x64/0x328 [kvm]
[  149.849336] Status: 7400cce3 KX SX UX KERNEL EXL IE
[  149.849351] Cause : 1000000c (ExcCode 03)
[  149.849354] BadVA : [PII_REDACTED]
[  149.849357] PrId  : 0014c004 (ICT Loongson-3)
[  149.849360] Modules linked in: kvm nfnetlink_queue nfnetlink_log nfnetlink fuse sha256_generic libsha256 cfg80211 rfkill binfmt_misc vfat fat snd_hda_codec_hdmi input_leds led_class snd_hda_intel snd_intel_dspcfg snd_hda_codec snd_hda_core snd_pcm snd_timer snd serio_raw xhci_pci radeon drm_suballoc_helper drm_display_helper xhci_hcd ip_tables x_tables
[  149.849432] Process qemu-system-mip (pid: 2265, threadinfo=00000000ae2982d2, task=[PII_REDACTED]e09ad4, tls=000000ffeba16030)
[  149.849439] Stack : [PII_REDACTED][PII_REDACTED]ccca00[PII_REDACTED]ccc000 ffffffffc062cef4
[  149.849453]        [PII_REDACTED]a07d18 c89b63a7ab338e00 [PII_REDACTED] ffffffff811a0000
[  149.849465]         [PII_REDACTED][PII_REDACTED]cd0000 ffffffff80e59[PII_REDACTED]1106a8920
[  149.849476]         ffffffff80e57f30 ffffffffc062854c ffffffff811a0[PII_REDACTED]102bf4240
[  149.849488]         ffffffffc05b0000 ffffffff80e3a798 000000ff78[PII_REDACTED]00ff78000010
[  149.849500]         [PII_REDACTED][PII_REDACTED]1f7de0[PII_REDACTED]3f0078 ffffffff81434000
[  149.849511]         [PII_REDACTED] [PII_REDACTED][PII_REDACTED]ae0[PII_REDACTED]25e92ae28
[  149.849523]         [PII_REDACTED] c89b63a7ab338e00 [PII_REDACTED] ffffffff8119dce0
[  149.849535]         000000ff78000010 ffffffff804f3d3c[PII_REDACTED]a07eb0 [PII_REDACTED]
[  149.849546]         [PII_REDACTED] ffffffff8049460c 000000ff78000010 [PII_REDACTED]
[  149.849558]         ...
[  149.849565] Call Trace:
[  149.849567] [<ffffffffc06356ec>] kvm_vz_vcpu_setup+0xc4/0x328 [kvm]
[  149.849586] [<ffffffffc062cef4>] kvm_arch_vcpu_create+0x184/0x228 [kvm]
[  149.849605] [<ffffffffc062854c>] kvm_vm_ioctl+0x64c/0xf28 [kvm]
[  149.849623] [<ffffffff805209c0>] sys_ioctl+0xc8/0x118
[  149.849631] [<ffffffff80219eb0>] syscall_common+0x34/0x58

The root cause is the deletion of kvm_mips_commpage_init() leaves vcpu
->arch.cop0 NULL. So fix it by making cop0 from a pointer to an embedded
object.
References: https://git.kernel.org/stable/c/6b9fb255d53759e3ea9b30067cb55091df1caf06; https://git.kernel.org/stable/c/bd9cf2a5f9e1b2229ad22f21de6f6ad1a9c8858e; https://git.kernel.org/stable/c/cd517f9a9d07d41f4f3593b1da3982261e09d162