Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>,
	virtualization@lists.linux.dev
Subject: Re: [PATCH v3 2/3] virtio_pci_legacy: drop callback sync on reset
Date: Fri, 11 Sep 2026 21:38:29 +0000	[thread overview]
Message-ID: <20260911213829.B18D51F00898@smtp.kernel.org> (raw)
In-Reply-To: <572661b65eebb784652e5843944d284bbceb2954.1789160982.git.mst@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Race condition during system shutdown due to missing callback synchronization after device reset, leading to potential use-after-free or system crash.
--

commit 78e24f18ba4e25cf07c789fb8728c72626386f80
Author: Michael S. Tsirkin <mst@redhat.com>

virtio_pci_legacy: drop callback sync on reset

The virtio core now synchronizes callbacks after reset,
so the legacy PCI transport no longer needs to do it itself.

> diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
> index d9cbb02b35a11..8115aa39e01e9 100644
> --- a/drivers/virtio/virtio_pci_legacy.c
> +++ b/drivers/virtio/virtio_pci_legacy.c
> @@ -98,8 +98,6 @@ static void vp_reset(struct virtio_device *vdev)
>  	/* Flush out the status write, and flush in device writes,
>  	 * including MSi-X interrupts, if any. */
>  	vp_legacy_get_status(&vp_dev->ldev);
> -	/* Flush pending VQ/configuration callbacks. */
> -	vp_synchronize_vectors(vdev);

[Severity: High]
Does removing this internal synchronization introduce a race condition
during system shutdown?

Unlike virtio_reset_device(), virtio_device_shutdown() in
drivers/virtio/virtio.c does not synchronize callbacks after resetting
the device:

drivers/virtio/virtio.c:virtio_device_shutdown() {
	...
	virtio_synchronize_cbs(dev);
	/*
	 * As IOMMUs are reset on shutdown, this will block device access to memory.
	 * Some devices get wedged if this happens, so reset to make sure it does not.
	 */
	dev->config->reset(dev);
}

When dev->config->reset(dev) calls vp_reset(), the status read can trigger
a final in-flight MSI-X interrupt.

Without vp_synchronize_vectors(), vp_reset() now returns immediately while
the interrupt handler could still execute drv->config_changed(dev)
concurrently on another CPU.

Can this lead to a fatal bus error, use-after-free, or kernel crash as the
system teardown sequence proceeds?

>  }
>  
>  static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789160982.git.mst@redhat.com?part=2

  reply	other threads:[~2026-09-11 21:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 21:20 [PATCH v3 0/3] virtio: fix callback synchronization and avq cleanup on reset Michael S. Tsirkin
2026-09-11 21:20 ` [PATCH v3 1/3] virtio: synchronize callbacks after device reset Michael S. Tsirkin
2026-09-11 21:37   ` sashiko-bot
2026-09-11 22:50   ` Karl Mehltretter
2026-09-11 21:20 ` [PATCH v3 3/3] virtio_pci_modern: move avq cleanup from reset to del_vqs Michael S. Tsirkin
2026-09-11 21:38   ` sashiko-bot
2026-09-11 22:48   ` Karl Mehltretter
2026-09-11 22:51     ` Michael S. Tsirkin
2026-09-11 21:20 ` [PATCH v3 2/3] virtio_pci_legacy: drop callback sync on reset Michael S. Tsirkin
2026-09-11 21:38   ` sashiko-bot [this message]
2026-09-11 22:51   ` Karl Mehltretter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260911213829.B18D51F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox