From: sashiko-bot@kernel.org
To: "Weimin Xiong" <xiongwm2026@163.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] vhost-vdpa: propagate set_map error to caller
Date: Fri, 17 Jul 2026 03:03:05 +0000 [thread overview]
Message-ID: <20260717030305.F1C511F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260716030242.124455-1-xiongwm2026@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The patch introduces a critical DMA Use-After-Free (UAF) vulnerability by breaking the `v->in_batch` state machine.
--
--- Patch [1]: [PATCH] vhost-vdpa: propagate set_map error to caller ---
commit a21d695ba480576c165ed7bd7fa965169ba30248
Author: xiongweimin <xiongweimin@kylinos.cn>
vhost-vdpa: propagate set_map error to caller
This commit updates vhost_vdpa_process_iotlb_msg() to propagate the return
value of ops->set_map() during VHOST_IOTLB_BATCH_END operations. It modifies
the switch case to capture the error and break early.
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index ac55275fa0d0a..908ca383b1522 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -1292,8 +1292,10 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid,
> v->in_batch = true;
> break;
> case VHOST_IOTLB_BATCH_END:
> - if (v->in_batch && ops->set_map)
> - ops->set_map(vdpa, asid, iotlb);
> + if (v->in_batch && ops->set_map) {
> + r = ops->set_map(vdpa, asid, iotlb);
> + break;
> + }
> v->in_batch = false;
> break;
[Severity: Critical]
Does this early break bypass the reset of v->in_batch?
If VHOST_IOTLB_BATCH_END is processed and ops->set_map is present, the switch
statement exits before executing v->in_batch = false. This leaves v->in_batch
permanently set to true.
Later, if a VHOST_IOTLB_INVALIDATE message is processed, vhost_vdpa_unmap()
checks the batch status:
drivers/vhost/vdpa.c:vhost_vdpa_unmap() {
...
if (ops->set_map) {
if (!v->in_batch)
ops->set_map(vdpa, asid, iotlb);
}
...
}
Since v->in_batch is still true, ops->set_map() is skipped. The software
unpins and frees the host pages, but the hardware IOMMU mappings are never
removed. Could this regression allow the hardware device to DMA into reused
host memory after it is freed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716030242.124455-1-xiongwm2026@163.com?part=1
prev parent reply other threads:[~2026-07-17 3:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 3:02 [PATCH] vhost-vdpa: propagate set_map error to caller Weimin Xiong
2026-07-16 10:01 ` Eugenio Perez Martin
2026-07-17 2:13 ` Weimin Xiong
2026-07-17 2:17 ` Re: [PATCH] vhost-vdpa: propagate set_map error to caller Weimin Xiong
2026-07-17 3:03 ` sashiko-bot [this message]
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=20260717030305.F1C511F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xiongwm2026@163.com \
/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