[PATCH 1/2] etnaviv: fall back if composite region is bigger than src or mask

Lucas Stach l.stach at pengutronix.de
Tue Dec 13 19:20:50 UTC 2016


Having a composite region bigger than the src or mask picture is well
defined as per the X.Org renderproto spec chapter
"9. Source and Mask Transformations".

We can not do this on the GPU as the core is not clipping the source
size in relative mode and there is no way to control the behavior in
absolute mode.

This is especially visible on a GPU with MMUv2, where such operations
will cause MMU faults, as the GPU tries to read outside of the source
buffer. On MMUv1 it will only cause reading of undefined data.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 etnaviv/etnaviv_render.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/etnaviv/etnaviv_render.c b/etnaviv/etnaviv_render.c
index c4f87cd4d8b9..a46c1bb8f72b 100644
--- a/etnaviv/etnaviv_render.c
+++ b/etnaviv/etnaviv_render.c
@@ -413,6 +413,9 @@ static struct etnaviv_pixmap *etnaviv_acquire_src(ScreenPtr pScreen,
 	if (!vSrc)
 		goto fallback;
 
+	if (vSrc->width < clip->x2 || vSrc->height < clip->y2)
+		goto fallback;
+
 	etnaviv_set_format(vSrc, pict);
 	if (!etnaviv_src_format_valid(etnaviv, vSrc->pict_format))
 		goto fallback;
@@ -671,6 +674,9 @@ static int etnaviv_accel_composite_masked(PicturePtr pSrc, PicturePtr pMask,
 		if (!vMask)
 			goto fallback;
 
+		if (vMask->width < clip_temp.x2 || vMask->height < clip_temp.y2)
+			goto fallback;
+
 		mask_offset.x += mo.x;
 		mask_offset.y += mo.y;
 	} else {
-- 
2.10.2



More information about the etnaviv mailing list