render: filter: fix integer-overflow bypass of convolution size check

convolutionFilterValidateParams() derives w/h from client-supplied
xFixed values via the sign-extending xFixedToInt(), then checked
'w * h > nparams' as a plain (signed) int product. A client can choose
negative w/h so the mathematical product is huge but the signed int
product wraps to a small or negative value, defeating the bounds check
that is supposed to reject a convolution kernel larger than the actual
parameter list.

Reject negative w/h outright and compare the product as int64_t so it
cannot wrap before the comparison.

Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt@vnc.biz>
(cherry picked from commit 6a97f6d38e)
This commit is contained in:
Enrico Weigelt, metux IT consult 2026-07-03 19:30:21 +02:00 • committed by Enrico Weigelt
commit 8e88faae02

View file

@ -273,7 +273,11 @@ convolutionFilterValidateParams(ScreenPtr pScreen,
h = xFixedToInt(params[1]);
nparams -= 2;
if (w * h > nparams)
/* w and h come from client xFixed values via the sign-extending
* xFixedToInt(); reject negatives and use a 64-bit product so the
* comparison cannot be defeated by signed overflow before w/h are
* handed back to the caller. */
if (w < 0 || h < 0 || (int64_t) w * h > nparams)
return FALSE;
*width = w;