From: John Levon <john.levon@nutanix.com>
To: zhaoguohan@kylinos.cn
Cc: "Thanos Makatos" <thanos.makatos@nutanix.com>,
"Cédric Le Goater" <clg@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] vfio-user: reject zero DMA page size capability
Date: Tue, 26 May 2026 09:52:48 +0100 [thread overview]
Message-ID: <ahVfYLhoKpWS2FDE@lent> (raw)
In-Reply-To: <20260522081306.4186242-1-zhaoguohan@kylinos.cn>
On Fri, May 22, 2026 at 04:13:05PM +0800, zhaoguohan@kylinos.cn wrote:
> check_pgsizes() validates that no page-size bits smaller than
> VFIO_USER_DEF_PGSIZE are set, but it still accepts pgsizes=0. This lets a
> malformed server overwrite the default page-size mask with zero.
>
> Later vfio_user_setup() asserts that proxy->dma_pgsizes is non-zero, so device
> realization aborts instead of reporting a version capability error. Reject a
> zero DMA page-size mask during version capability parsing.
>
> Fixes: 36227628d824 (vfio-user: implement message send infrastructure)
> Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
> ---
> hw/vfio-user/proxy.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c
> index 8b7cc36231ab..7c3036ec83c5 100644
> --- a/hw/vfio-user/proxy.c
> +++ b/hw/vfio-user/proxy.c
> @@ -1155,9 +1155,11 @@ static bool check_pgsizes(VFIOUserProxy *proxy, QObject *qobj, Error **errp)
> return false;
> }
>
> - /* must be larger than default */
> - if (pgsizes & (VFIO_USER_DEF_PGSIZE - 1)) {
> - error_setg(errp, "pgsize 0x%"PRIx64" too small", pgsizes);
> + /* must not be zero or smaller than default */
> + if (pgsizes < VFIO_USER_DEF_PGSIZE ||
> + (pgsizes & (VFIO_USER_DEF_PGSIZE - 1))) {
> + error_setg(errp, "%s 0x%"PRIx64" too small",
> + VFIO_USER_CAP_PGSIZES, pgsizes);
> return false;
> }
>
Reviewed-by: John Levon <john.levon@nutanix.com>
next prev parent reply other threads:[~2026-05-26 8:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 8:13 [PATCH 1/2] vfio-user: reject zero DMA page size capability zhaoguohan
2026-05-22 8:13 ` [PATCH 2/2] vfio-user: reject zero migration " zhaoguohan
2026-05-26 8:52 ` John Levon [this message]
2026-05-28 5:52 ` [PATCH 1/2] vfio-user: reject zero DMA " Michael Tokarev
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=ahVfYLhoKpWS2FDE@lent \
--to=john.levon@nutanix.com \
--cc=clg@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thanos.makatos@nutanix.com \
--cc=zhaoguohan@kylinos.cn \
/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.