All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] ui/vnc: validate SetPixelFormat field ranges
Date: Mon, 13 Jul 2026 11:07:48 +0100	[thread overview]
Message-ID: <alS49FlxfpXVgheR@redhat.com> (raw)
In-Reply-To: <20260713100056.4104383-1-marcandre.lureau@redhat.com>

On Mon, Jul 13, 2026 at 02:00:56PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> The VNC SetPixelFormat message carries red/green/blue_max as 16-bit
> values, but PixelFormat stores them as uint8_t. A client sending a
> max value above 255 (e.g. 0x0100) passes the existing non-zero check
> but silently truncates to 0 on assignment, leading to a division by
> zero in the Tight PNG palette path.
> 
> Similarly, the shift values are read as uint8_t from the wire but
> used in left-shift expressions (red_max << red_shift). Shifts >= 32
> are undefined behavior in C for 32-bit operands.
> 
> Add explicit range checks for both: reject the connection if any
> channel max exceeds UINT8_MAX, or any shift is >= 32.
> 
> Fixes: CVE-2026-15578
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3976
> Reported-by: dong ling
> Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
> ---
>  ui/vnc.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/ui/vnc.c b/ui/vnc.c
> index dfc8262d42a..c4ee4738b28 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -2276,6 +2276,16 @@ static void set_pixel_format(VncState *vs, int bits_per_pixel,
>          return;
>      }
>  
> +    if (red_max > UINT8_MAX || green_max > UINT8_MAX || blue_max > UINT8_MAX) {
> +        vnc_client_error(vs);
> +        return;
> +    }
> +
> +    if (red_shift >= 32 || green_shift >= 32 || blue_shift >= 32) {
> +        vnc_client_error(vs);
> +        return;
> +    }
> +
>      vs->client_pf.rmax = red_max ? red_max : 0xFF;
>      vs->client_pf.rbits = ctpopl(red_max);
>      vs->client_pf.rshift = red_shift;

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-07-13 10:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 10:00 [PATCH] ui/vnc: validate SetPixelFormat field ranges marcandre.lureau
2026-07-13 10:07 ` Daniel P. Berrangé [this message]
2026-07-13 10:49 ` Philippe Mathieu-Daudé
2026-07-13 11:06 ` Marc-André Lureau

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=alS49FlxfpXVgheR@redhat.com \
    --to=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@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 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.