@samitouri / QOSamiQemu / commits / c3c6226fa4

ui/vnc: fix OOB write in VNC stats array

The VncSurface struct maintains update statistics in an array: VncRectStat stats[VNC_STAT_ROWS][VNC_STAT_COLS]; where the dimensions are defined as: #define VNC_STAT_RECT 64 #define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT) #define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT) If VNC_MAX_WIDTH / VNC_MAX_HEIGHT are not an exact multiple of VNC_STAT_REC, the COLS/ROWS will be undersized by 1. Unfortunately: #define VNC_MAX_HEIGHT 2160 is not a multiple of 64, so there is potential for OOB reads and writes in the 'stats' array, if the guest surface is over 2112 pixels in height. An array overflow occurs when vnc_update_stats() records new statistics, either scribbling over data later in the VncDisplay struct that 'stats' is embedded in, or performing an OOB write on the allocated struct memory. Fixes: CVE-2026-48002 Reported-by: boy juju <agx1657748706@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20260521103353.1645561-3-berrange@redhat.com>

Daniel P. Berrangé committed May 21, 2026 at 11:33 UTC c3c6226fa48180edf9d4646d4112fb1becbc149b
1 file changed +2 -2
ui/vnc.h
+2 -2
@@ -85,8 +85,8 @@ typedef void VncSendHextileTile(VncState *vs,
85 #define VNC_DIRTY_BPL(x) (sizeof((x)->dirty) / VNC_MAX_HEIGHT * BITS_PER_BYTE)
86
87 #define VNC_STAT_RECT 64
88 -#define VNC_STAT_COLS (VNC_MAX_WIDTH / VNC_STAT_RECT)
89 -#define VNC_STAT_ROWS (VNC_MAX_HEIGHT / VNC_STAT_RECT)
88 +#define VNC_STAT_COLS DIV_ROUND_UP(VNC_MAX_WIDTH, VNC_STAT_RECT)
89 +#define VNC_STAT_ROWS DIV_ROUND_UP(VNC_MAX_HEIGHT, VNC_STAT_RECT)
90
91 #define VNC_AUTH_CHALLENGE_SIZE 16
92