From: Alex Williamson <alex.williamson@nvidia.com>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: qemu-devel@nongnu.org,
"Viktor Prutyanov" <viktor.prutyanov@phystech.edu>,
"Cédric Le Goater" <clg@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Keith Busch" <kbusch@kernel.org>,
"Klaus Jensen" <its@irrelevant.dk>,
"Jesper Devantier" <foss@defmacro.it>,
qemu-block@nongnu.org
Subject: Re: [PATCH v2 2/4] vfio/pci: Grow buffer in vfio_pci_host_match()
Date: Mon, 2 Mar 2026 11:59:57 -0700 [thread overview]
Message-ID: <20260302115957.10cd3b9a@nvidia.com> (raw)
In-Reply-To: <20260302-nvme-v2-2-37ad8b5788c3@rsg.ci.i.u-tokyo.ac.jp>
On Mon, 02 Mar 2026 16:48:09 +0900
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> wrote:
> Ensure the buffer in vfio_pci_host_match() will not overflow even when
> an invalid addr parameter is provided.
This commit log could be much more straightforward. Something like:
Each field of PCIHostDeviceAddress is an unsigned int, therefore
while a valid address is limited to 13 characters, an invalid
address could exceed the specified format, up to:
ffffffff:ffffffff:ffffffff.ffffffff<NUL>
This requires 36 characters with the terminator.
With that:
Reviewed-by: Alex Williamson <alex.williamson@nvidia.com>
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> ---
> hw/vfio/pci.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index c89f3fbea348..94c174a773fb 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2739,7 +2739,7 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev)
>
> bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
> {
> - char tmp[13];
> + char tmp[36];
>
> sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain,
> addr->bus, addr->slot, addr->function);
>
next prev parent reply other threads:[~2026-03-02 19:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 7:48 [PATCH v2 0/4] Fix use-after-free and make format overflow more difficult Akihiko Odaki
2026-03-02 7:48 ` [PATCH v2 1/4] contrib/elf2dmp: Grow PDB URL buffer Akihiko Odaki
2026-03-02 7:48 ` [PATCH v2 2/4] vfio/pci: Grow buffer in vfio_pci_host_match() Akihiko Odaki
2026-03-02 18:59 ` Alex Williamson [this message]
2026-03-02 7:48 ` [PATCH v2 3/4] tests: Grow buffers for double string Akihiko Odaki
2026-03-02 11:52 ` Markus Armbruster
2026-03-02 11:57 ` Daniel P. Berrangé
2026-03-02 12:54 ` Akihiko Odaki
2026-03-02 7:48 ` [PATCH v2 4/4] meson: Add -Wformat-overflow=2 Akihiko Odaki
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=20260302115957.10cd3b9a@nvidia.com \
--to=alex.williamson@nvidia.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@redhat.com \
--cc=foss@defmacro.it \
--cc=its@irrelevant.dk \
--cc=kbusch@kernel.org \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=viktor.prutyanov@phystech.edu \
/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.