]> git.baikalelectronics.ru Git - kernel.git/commit
drm/vc4: hvs: Fix buffer overflow with the dlist handling
authorMaxime Ripard <maxime@cerno.tech>
Fri, 29 Jan 2021 16:06:47 +0000 (17:06 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Tue, 2 Feb 2021 16:34:08 +0000 (17:34 +0100)
commite228020a97031fd7be6efc9330929fa7bbfa4599
tree85688a341cdf53da9708bd76b9c6fb103dae387c
parent6ffbcbe411e17ce4990c297a11240501c3490fe6
drm/vc4: hvs: Fix buffer overflow with the dlist handling

Commit 5aa15d7595a5 ("drm/vc4: Move LBM creation out of
vc4_plane_mode_set()") changed the LBM allocation logic from first
allocating the LBM memory for the plane to running mode_set,
adding a gap in the LBM, and then running the dlist allocation filling
that gap.

The gap was introduced by incrementing the dlist array index, but was
never checking whether or not we were over the array length, leading
eventually to memory corruptions if we ever crossed this limit.

vc4_dlist_write had that logic though, and was reallocating a larger
dlist array when reaching the end of the buffer. Let's share the logic
between both functions.

Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Eric Anholt <eric@anholt.net>
Fixes: 5aa15d7595a5 ("drm/vc4: Move LBM creation out of vc4_plane_mode_set()")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210129160647.128373-1-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_plane.c