From: Yuchao Zhang <ndaugoing@gmail.com>
To: "Roger Pau Monné" <roger@xenproject.org>,
"Juergen Gross" <jgross@suse.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Jens Axboe" <axboe@kernel.dk>
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
xen-devel@lists.xenproject.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Yuchao Zhang <ndaugoing@gmail.com>
Subject: [PATCH 0/1] xen-blkfront: unbind irq before tearing down ring and shadow requests
Date: Fri, 18 Sep 2026 19:43:53 +0800 [thread overview]
Message-ID: <20260918114354.3660102-1-ndaugoing@gmail.com> (raw)
Hi Roger, Juergen, Stefano, and Jens,
This patch addresses a race condition during device disconnect and
ring teardown in drivers/block/xen-blkfront.c.
Problem:
In blkif_free_ring(), the driver currently cleans up all persistent
grants, frees indirect pages, frees the shadow request structures
(rinfo->shadow[i].grants_used and rinfo->shadow[i].sg), and tears
down the shared ring via xenbus_teardown_ring(). Only after all these
deallocations does it invoke unbind_from_irqhandler().
Because the event channel interrupt (blkif_interrupt) remains active
throughout this teardown procedure, a completion interrupt received
from the backend runs blkif_interrupt() concurrently on another CPU.
Since blkif_free_ring() tears the ring and shadow structures down
without holding rinfo->ring_lock, this races against the cleanup loop,
leading to use-after-free and NULL pointer dereferences when accessing
rinfo->ring.sring, rinfo->shadow[id].grants_used, or
rinfo->shadow[id].sg.
Fix:
Move unbind_from_irqhandler() to the beginning of blkif_free_ring().
This immediately unbinds the event channel and synchronizes with any
in-flight interrupt handlers via free_irq(), guaranteeing that no
interrupts execute concurrently while ring memory, grants, and shadow
structures are being freed.
This matches the teardown ordering already used in
drivers/net/xen-netfront.c (xennet_disconnect_backend()).
Best regards,
Yuchao Zhang
Yuchao Zhang (1):
xen-blkfront: unbind irq before tearing down ring and shadow requests
drivers/block/xen-blkfront.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--
2.53.0
next reply other threads:[~2026-09-19 7:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 11:43 Yuchao Zhang [this message]
2026-09-18 11:43 ` [PATCH 1/1] xen-blkfront: unbind irq before tearing down ring and shadow requests Yuchao Zhang
2026-09-21 9:38 ` Roger Pau Monné
2026-09-22 7:21 ` Yuchao Zhang
2026-09-22 7:21 ` [PATCH v2] " Yuchao Zhang
2026-09-22 8:35 ` Roger Pau Monné
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=20260918114354.3660102-1-ndaugoing@gmail.com \
--to=ndaugoing@gmail.com \
--cc=axboe@kernel.dk \
--cc=jgross@suse.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr_tyshchenko@epam.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xen-devel@lists.xenproject.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.