Skip to content

KVM: Fix a guest_memfd memslot UAF

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Applied to kvm-x86 fixes (I'm feeling lucky with the ABI change).

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: Disallow toggling KVM_MEM_GUEST_MEMFD on an existing memslotvirt/kvm/kvm_main.c+1 -10 replies
2/2KVM: Harden and prepare for modifying existing guest_memfd memslotsvirt/kvm/kvm_main.c+15 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] KVM: Fix a guest_memfd memslot UAF

Fix a UAF due to leaving a dangling guest_memfd memslot binding by disallowing clearing KVM_MEM_GUEST_MEMFD on a memslot. The intent was that guest_memfd memslots would be immutable (could only be deleted), but somewhat ironically we missed the case where KVM_MEM_GUEST_MEMFD itself is the only flag that's toggled.

This is an ABI change, but I can't imagine anyone was relying on disappearing a guest_memfd memslot.

Patch 2 hardens against the UAF, and prepares for allowing FLAGS_ONLY changes on guest_memfd memslots. Sooner or later, we're going to allow dirty logging on guest_memfd, so I think it makes sense to guard against that so that whoever adds dirty logging support doesn't forget to unbind on a FLAGS_ONLY change.

I'll respond with the syzkaller reproducer (it's comically simple).

Sean Christopherson (2):
KVM: Disallow toggling KVM_MEM_GUEST_MEMFD on an existing memslot
KVM: Harden and prepare for modifying existing guest_memfd memslots

 virt/kvm/kvm_main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

base-commit: 115d5de2eef32ac5cd488404b44b38789362dbe6

Signature · 1 line
2.52.0.107.ga0afd4fd5b-goog