Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/2] vhost-vdpa: fix a use-after-free on the config eventfd
@ 2026-08-07 10:00 Yu Zhang
  2026-08-07 10:00 ` [PATCH 1/2] vhost-vdpa: don't install the eventfd_ctx_fdget() error in config_ctx Yu Zhang
  2026-08-07 10:00 ` [PATCH 2/2] vhost-vdpa: protect config_ctx from being freed under the config callback Yu Zhang
  0 siblings, 2 replies; 3+ messages in thread
From: Yu Zhang @ 2026-08-07 10:00 UTC (permalink / raw)
  To: mst, jasowangio
  Cc: eperezma, kvm, virtualization, netdev, linux-kernel, Yu Zhang

vhost_vdpa_config_cb() reads v->config_ctx with no reference and no lock
while VHOST_VDPA_SET_CONFIG_CALL frees the old context, so a config
interrupt delivered at the wrong moment signals freed memory.

Patch 1 stops the fdget error value from ever being installed in
config_ctx.  It is a fix in its own right -- the callback tests only for
NULL and would signal the ERR_PTR -- and it is also what lets patch 2's
lock establish "non-NULL implies valid".

Patch 2 adds the lock that closes the use-after-free.

This is not the reopen refcount underflow fixed by f6bbf0010ba0
("vhost-vdpa: fix use-after-free of v->config_ctx"), and it is a
different bug from the vq call fd one I sent on Aug 6
(https://lore.kernel.org/all/20260806150323.2154-1-yuz08559@gmail.com/),
which is about the parent caching an eventfd_ctx it does not own.  The
three touch different functions.

Tested on v7.2-rc6 with KASAN under qemu, VDUSE as the parent: one thread
swaps the config call fd on the vhost-vdpa fd while another injects
VDUSE_DEV_INJECT_CONFIG_IRQ on the VDUSE fd.  9 of 10 30-second runs hit
the UAF; 0 of 5 with the series applied, with the workload counters
unchanged either way (~30k swaps and ~2.6M injects per run), so the race
is still being exercised rather than merely not reached.  Also clean over
5 runs with PROVE_LOCKING, and vdpa_sim shows no change on the shared
VHOST_VDPA_SET_CONFIG_CALL path (20000 install/unbind cycles plus the
bad-fd path, identical before and after).

For patch 1 specifically: with a working config fd installed, 250 injects
deliver 250 signals; after a VHOST_VDPA_SET_CONFIG_CALL with a bad fd,
delivery stops on an unpatched kernel and continues with the patch.

Yu Zhang (2):
  vhost-vdpa: don't install the eventfd_ctx_fdget() error in config_ctx
  vhost-vdpa: protect config_ctx from being freed under the config
    callback

 drivers/vhost/vdpa.c | 44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-07 10:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 10:00 [PATCH 0/2] vhost-vdpa: fix a use-after-free on the config eventfd Yu Zhang
2026-08-07 10:00 ` [PATCH 1/2] vhost-vdpa: don't install the eventfd_ctx_fdget() error in config_ctx Yu Zhang
2026-08-07 10:00 ` [PATCH 2/2] vhost-vdpa: protect config_ctx from being freed under the config callback Yu Zhang

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