From: "Volker Rümelin" <vr_qemu@t-online.de>
To: qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org, Michael Tokarev <mjt@tls.msk.ru>
Subject: Re: [PULL 2/3] hw/audio/virtio-snd: fix invalid param check
Date: Fri, 30 Aug 2024 07:12:46 +0200 [thread overview]
Message-ID: <122bf0db-8763-432b-979c-f0c91c7710b9@t-online.de> (raw)
In-Reply-To: <7d14471a121878602cb4e748c4707f9ab9a9e3e2.1724151593.git.mst@redhat.com>
Cc: qemu-stable@nongnu.org
Without this patch, the virtio-sound device will not work in the next
QEMU stable-8.2 and stable-9.0 versions.
With best regards,
Volker
> From: Volker Rümelin <vr_qemu@t-online.de>
>
> Commit 9b6083465f ("virtio-snd: check for invalid param shift
> operands") tries to prevent invalid parameters specified by the
> guest. However, the code is not correct.
>
> Change the code so that the parameters format and rate, which are
> a bit numbers, are compared with the bit size of the data type.
>
> Fixes: 9b6083465f ("virtio-snd: check for invalid param shift operands")
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> Message-Id: <20240802071805.7123-1-vr_qemu@t-online.de>
> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/audio/virtio-snd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
> index e5196aa4bb..d1cf5eb445 100644
> --- a/hw/audio/virtio-snd.c
> +++ b/hw/audio/virtio-snd.c
> @@ -282,12 +282,12 @@ uint32_t virtio_snd_set_pcm_params(VirtIOSound *s,
> error_report("Number of channels is not supported.");
> return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
> }
> - if (BIT(params->format) > sizeof(supported_formats) ||
> + if (params->format >= sizeof(supported_formats) * BITS_PER_BYTE ||
> !(supported_formats & BIT(params->format))) {
> error_report("Stream format is not supported.");
> return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
> }
> - if (BIT(params->rate) > sizeof(supported_rates) ||
> + if (params->rate >= sizeof(supported_rates) * BITS_PER_BYTE ||
> !(supported_rates & BIT(params->rate))) {
> error_report("Stream rate is not supported.");
> return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP);
next prev parent reply other threads:[~2024-08-30 5:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 11:01 [PULL 0/3] virtio: regression fixes Michael S. Tsirkin
2024-08-20 11:01 ` [PULL 1/3] vhost: Add VIRTIO_NET_F_RSC_EXT to vhost feature bits Michael S. Tsirkin
2024-08-20 11:01 ` [PULL 2/3] hw/audio/virtio-snd: fix invalid param check Michael S. Tsirkin
2024-08-30 5:12 ` Volker Rümelin [this message]
2024-08-20 11:01 ` [PULL 3/3] virtio-pci: Fix the use of an uninitialized irqfd Michael S. Tsirkin
2024-08-20 22:46 ` [PULL 0/3] virtio: regression fixes Richard Henderson
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=122bf0db-8763-432b-979c-f0c91c7710b9@t-online.de \
--to=vr_qemu@t-online.de \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).