All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org,
	Greg Kurz <groug@kaod.org>,
	 Anthony PERARD <anthony@xenproject.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Subject: Re: [PATCH v2 2/2] hw/9pfs/xen: drain in-flight PDUs before xen-9p disconnect
Date: Thu, 23 Jul 2026 13:20:46 +0200	[thread overview]
Message-ID: <6287622.lOV4Wx5bFT@weasel> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2607221815520.5295@ubuntu-linux-20-04-desktop>

On Thursday, 23 July 2026 03:17:12 CEST Stefano Stabellini wrote:
> On Wed, 22 Jul 2026, Christian Schoenebeck wrote:
[...]
> > > @@ -368,10 +375,18 @@ static void xen_9pfs_evtchn_event(void *opaque)
> > > 
> > >  static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
> > >  {
> > >  
> > >      Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
> > > 
> > > +    V9fsState *s = &xen_9pdev->state;
> > > 
> > >      int i;
> > > 
> > > +    if (!xen_9pdev->rings) {
> 
> specifically this check is not sufficient are there can be cases where
> rings != NULL but transport is not set and v9fs_reset should not be
> called. For instance xen_be_map_grant_ref() returns NULL,
> xen_9pfs_connect() go out without calling v9fs_device_realize_common().
> s->transport == NULL and also s->fids == NULL but rings != NULL. Later
> v9fs_reset calls g_hash_table_get_values(s->fids)
> 
> > > +        return;
> > > +    }
> > > +
> > > 
> > >      trace_xen_9pfs_disconnect(xendev->name);
> > > 
> > > +    v9fs_reset(s);
> > > +    v9fs_device_unrealize_common(s);
> > > +
> > > 
> > >      for (i = 0; i < xen_9pdev->num_rings; i++) {
> > >      
> > >          if (xen_9pdev->rings[i].evtchndev != NULL) {
> > > 
> > > qemu_set_fd_handler(qemu_xen_evtchn_fd(xen_9pdev->rings[i].evtchndev),
> 
> See this below. If you agree and add the below to this patch you can add
> my Reviewed-by.
> 
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index 3119f01117..fc01791830 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -4530,6 +4530,7 @@ void v9fs_device_unrealize_common(V9fsState *s)
>      qp_table_destroy(&s->qpp_table);
>      qp_table_destroy(&s->qpf_table);
>      g_free(s->ctx.fs_root);
> +    s->transport = NULL;
>  }
> 
>  typedef struct VirtfsCoResetData {
> diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
> index edb65a7afc..f0791f9e97 100644
> --- a/hw/9pfs/xen-9p-backend.c
> +++ b/hw/9pfs/xen-9p-backend.c
> @@ -384,8 +384,10 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice
> *xendev)
> 
>      trace_xen_9pfs_disconnect(xendev->name);
> 
> -    v9fs_reset(s);
> -    v9fs_device_unrealize_common(s);
> +    if (s->transport) {
> +        v9fs_reset(s);
> +        v9fs_device_unrealize_common(s);
> +    }
> 
>      for (i = 0; i < xen_9pdev->num_rings; i++) {
>          if (xen_9pdev->rings[i].evtchndev != NULL) {

Agreed, these two changes makes sense. I'll formally send a v3 with these two 
changes added now.

My plan is to send a PR with this and other fixes tomorrow already, as we're 
getting very close to release.

Thanks Stefano!

/Christian




  reply	other threads:[~2026-07-23 11:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 16:50 [PATCH v2 0/2] 9p: fix guest-triggered Treaddir/ACPI eject UAF Christian Schoenebeck
2026-07-18 16:50 ` [PATCH v2 2/2] hw/9pfs/xen: drain in-flight PDUs before xen-9p disconnect Christian Schoenebeck
2026-07-22  9:27   ` Christian Schoenebeck
2026-07-23  1:17     ` Stefano Stabellini
2026-07-23 11:20       ` Christian Schoenebeck [this message]
2026-07-18 16:50 ` [PATCH v2 1/2] hw/9pfs/virtio: drain in-flight PDUs before virtio-9p unrealize Christian Schoenebeck

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=6287622.lOV4Wx5bFT@weasel \
    --to=qemu_oss@crudebyte.com \
    --cc=anthony@xenproject.org \
    --cc=edgar.iglesias@gmail.com \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=sstabellini@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.