From 95cf222d43c9d58ae84ace27651eb60809594898 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 2 Oct 2026 15:02:54 +0200 Subject: [PATCH] xfree86: bound EDID DS_RANGES against hsync/vrefresh array size handle_detailed_monset() records Display-Range (DS_RANGES) descriptors from EDID into the fixed-size MonRec hsync[] and vrefresh[] arrays without checking nHsync / nVrefresh against MAX_HSYNC / MAX_VREFRESH. A malicious EDID with more DS_RANGES descriptors than the array capacity (base block plus CEA extension detailed slots) overruns those arrays and clobbers adjacent MonRec members such as Modes, Last, and DDC, leading to an out-of-bounds write and subsequent crash. Clamp each store the same way the xorg.conf path already does, and drop extra descriptors while still applying maxPixClock. CVE-2026-109091 Reported-by: Eun0us / Espilon Signed-off-by: Olivier Fourdan Assisted-by: AI Part-of: --- hw/xfree86/modes/xf86EdidModes.c | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index b0f93e2b79..b2ade1e279 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -1125,14 +1125,16 @@ handle_detailed_monset(struct detailed_monitor_section *det_mon, void *data) switch (det_mon->type) { case DS_RANGES: if (!p->have_hsync) { - if (!p->Monitor->nHsync) - xf86DrvMsg(scrnIndex, X_INFO, - "Using EDID range info for horizontal sync\n"); - p->Monitor->hsync[p->Monitor->nHsync].lo = - det_mon->section.ranges.min_h; - p->Monitor->hsync[p->Monitor->nHsync].hi = - det_mon->section.ranges.max_h; - p->Monitor->nHsync++; + if (p->Monitor->nHsync < MAX_HSYNC) { + if (!p->Monitor->nHsync) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for horizontal sync\n"); + p->Monitor->hsync[p->Monitor->nHsync].lo = + det_mon->section.ranges.min_h; + p->Monitor->hsync[p->Monitor->nHsync].hi = + det_mon->section.ranges.max_h; + p->Monitor->nHsync++; + } } else { xf86DrvMsg(scrnIndex, X_INFO, @@ -1140,14 +1142,16 @@ handle_detailed_monset(struct detailed_monitor_section *det_mon, void *data) } if (!p->have_vrefresh) { - if (!p->Monitor->nVrefresh) - xf86DrvMsg(scrnIndex, X_INFO, - "Using EDID range info for vertical refresh\n"); - p->Monitor->vrefresh[p->Monitor->nVrefresh].lo = - det_mon->section.ranges.min_v; - p->Monitor->vrefresh[p->Monitor->nVrefresh].hi = - det_mon->section.ranges.max_v; - p->Monitor->nVrefresh++; + if (p->Monitor->nVrefresh < MAX_VREFRESH) { + if (!p->Monitor->nVrefresh) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for vertical refresh\n"); + p->Monitor->vrefresh[p->Monitor->nVrefresh].lo = + det_mon->section.ranges.min_v; + p->Monitor->vrefresh[p->Monitor->nVrefresh].hi = + det_mon->section.ranges.max_v; + p->Monitor->nVrefresh++; + } } else { xf86DrvMsg(scrnIndex, X_INFO, -- GitLab