xserver/miext
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Enrico Weigelt, metux IT consult 7717c4a00f miext: damage: use drawable pointer instead of list head pointer to avoid realloc() UAF
Backport of ccfc4797cf (PR #3793) to release/25.2.

The original fix (da72833185) introduced a use-after-free vulnerability by
caching a pointer into a realloc()able privates array (pListHead). This fix
replaces the pListHead pointer with pListDrawable, storing the drawable pointer
at insertion time and re-deriving the list head at removal time via
getDrawableDamageRef(), avoiding the realloc() UAF.

The fix:
1. Changes pListHead (DamagePtr *) to pListDrawable (DrawablePtr) in damagestr.h
2. Updates damageInsertDamage to store pDamage->pDrawable instead of the list head pointer
3. Updates damageRemoveDamage to take a DrawablePtr and re-derive the list head via getDrawableDamageRef()
4. Updates all call sites to pass the drawable pointer instead of the list head pointer
5. Fixes damagePixmapDestroy to pass the pixmap as the drawable

*1) da72833185

Backport notes -- deviations from a clean cherry-pick, all measured:

The cherry-pick conflicted in five places, not one: four in miext/damage/damage.c
and one in include/damagestr.h. The conflicts are not cosmetic. pListHead was
introduced by da72833185, which only ever reached master, so it does not exist on
this branch at all:

    git grep -c pListHead origin/release/25.2 -> 0

The release tree still carries the *pre-da728331854* form, which cached the list
head locally in damageSetWindowPixmap(). Git's three-way merge reconstructs the
correct net effect, but the merge base is a tree that never had pListHead, so every
site where master merely *renamed* the field appears here as an addition.

1. All five conflict zones were resolved by taking the incoming side. Verified
   afterwards that no conflict marker remains and that the resulting function
   bodies match master's, field for field.

2. One additional hunk was required that is NOT part of the upstream commit:
   damageSetWindowPixmap() left behind

       PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow);
       DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap);

   Both become dead once the removal path goes through
   damageRemoveDamage(pDamage->pListDrawable, pDamage). master's version of that
   function has neither line, because on master the equivalent line had already
   become pListHead. Left in place they would fail the build with

       error: unused variable 'pPrev' [-Werror=unused-variable]

   so they are removed here, matching master.

   Note that pOldPixmap was the only user of pScreen->GetWindowPixmap in this
   function; pScreen itself stays live via damageScrPriv() and pScrPriv.

No other change. pPrev remains in the *insert* path of damageSetWindowPixmap(),
which is where master keeps it, because that call inserts into the list it just
derived.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
(cherry picked from commit ccfc4797cf)
2026-10-02 14:37:46 +02:00
..
damage miext: damage: use drawable pointer instead of list head pointer to avoid realloc() UAF 2026-10-02 14:37:46 +02:00
rootless rootless: Fix two region leaks 2026-09-30 11:37:14 +02:00
shadow miext: shadow: move over public SDK header to include/ 2026-02-12 14:39:55 +01:00
sync sync: fix deletion of counters and fences 2026-06-03 17:49:13 +02:00
extinit_priv.h treewide: Move the dri2 extension to Xext and use it for all X servers 2026-01-02 17:51:43 +01:00