]> git.ipfire.org Git - thirdparty/linux.git/commit
KVM: Add irqfd to eventfd's waitqueue while holding irqfds.lock
authorSean Christopherson <seanjc@google.com>
Thu, 22 May 2025 23:52:15 +0000 (16:52 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 23 Jun 2025 16:50:56 +0000 (09:50 -0700)
commit86e00cd162a727c0b847def89bbd787c20eb8f5d
tree70bb3f43320af57c714b6cbbc9a0a24038423054
parent5f8ca05ea99183ab2b69c7fd9617961211d194e7
KVM: Add irqfd to eventfd's waitqueue while holding irqfds.lock

Add an irqfd to its target eventfd's waitqueue while holding irqfds.lock,
which is mildly terrifying but functionally safe.  irqfds.lock is taken
inside the waitqueue's lock, but if and only if the eventfd is being
released, i.e. that path is mutually exclusive with registration as KVM
holds a reference to the eventfd (and obviously must do so to avoid UAF).

This will allow using the eventfd's waitqueue to enforce KVM's requirement
that eventfd is assigned to at most one irqfd, without introducing races.

Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250522235223.3178519-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
virt/kvm/eventfd.c