public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] KVM: NULL pointer dereference in kvm_tdp_mmu_map under memory pressure
@ 2026-04-08 10:29 punixcorn
  2026-04-08 11:21 ` punixcorn
  2026-04-08 14:18 ` Sean Christopherson
  0 siblings, 2 replies; 6+ messages in thread
From: punixcorn @ 2026-04-08 10:29 UTC (permalink / raw)
  To: seanjc, pbonzini; +Cc: kvm, linux-kernel, punixcorn

Under host memory pressure, a NULL pointer dereference occurs in
kvm_tdp_mmu_map() at offset 0x24. The exact root cause is unclear --
it may be an unhandled NULL return from tdp_mmu_alloc_sp(), or a
violated invariant elsewhere in the map path.

Crash log:

  BUG: kernel NULL pointer dereference, address: 0000000000000024
  #PF: supervisor read access in kernel mode
  Oops: 0000 [#1] SMP NOPTI
  CPU: 2 PID: 1110212 Comm: MainLoopThread Tainted: G U OE 6.19.10-arch1-1
  Hardware name: Default Default/NLXB, BIOS BQ141 06/27/2024
  RIP: 0010:kvm_tdp_mmu_map+0x471/0x880 [kvm]
  Code: 00 00 00 80 48 2b 35 76 72 5c c8 48 c7 44 24 20 00 00 00 00 48 01 f1 48 c1 e9 0c 48 c1 e1 06 48 03 0d 4b 72 5c c8 48 8b 71 28 <0f> b6 4e 24 83 e1 0f 39 ca 0f 85 a7 02 00 00 f6 c4 08 74 26 80 7b
  RSP: 0018:ffffce128333f790 EFLAGS: 00010286

Reproduction:

The issue was observed under heavy host memory pressure while running
a KVM guest (Android emulator via QEMU).

The crash is not reliably reproducible and appears to be
timing-dependent. Fault injection targeting tdp_mmu_alloc_sp()
increases the frequency of hitting the same code path without
triggering a panic, suggesting the retry path may be a viable
recovery, though the exact failure condition is still unclear.

Fault injection used:

  sp = tdp_mmu_alloc_sp(vcpu);
  if (!sp || (atomic_inc_return(&fail_counter) % 100 == 0)) {
      if (sp) tdp_mmu_free_sp(sp);
      goto retry;
  }

With this injection the guest continues running normally initially,
but eventually terminates after sustained injection pressure. This is
expected behavior given the repeated forced failures.

A speculative fix:
  if (!sp)
      goto retry;

This has not been fully verified. Sending for maintainer review.

Environment:
  Linux 6.19.10-arch1-1 x86_64
  GNU C 15.2.1
  Binutils 2.46

Signed-off-by: punixcorn <ohyunwoods663@gmail.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <202604081418.sean.christopherson@intel.com>]
[parent not found: <202604081633.sean.christopherson@intel.com>]

end of thread, other threads:[~2026-04-08 18:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08 10:29 [BUG] KVM: NULL pointer dereference in kvm_tdp_mmu_map under memory pressure punixcorn
2026-04-08 11:21 ` punixcorn
2026-04-08 14:18 ` Sean Christopherson
     [not found] <202604081418.sean.christopherson@intel.com>
2026-04-08 15:36 ` punixcorn
2026-04-08 16:33   ` Sean Christopherson
     [not found] <202604081633.sean.christopherson@intel.com>
2026-04-08 18:43 ` punixcorn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox