Re: [PATCH] drm/vc4: tests: pv_muxing: Fix locking

From: Maxime Ripard
Date: Tue May 27 2025 - 09:58:18 EST


On Sat, May 24, 2025 at 08:09:36AM -0300, Maíra Canal wrote:
> On 20/05/25 09:08, Maxime Ripard wrote:
> > Commit 30188df0c387 ("drm/tests: Drop drm_kunit_helper_acquire_ctx_alloc()")
> > removed a kunit-managed function to get a drm_modeset_acquire_ctx.
> >
> > It converted the vc4_pv_muxing_test_init() function, used by
> > drm_vc4_test_pv_muxing() and drm_vc4_test_pv_muxing_invalid(). However,
> > during that conversion, it went from being kzalloc'd to being allocated
> > on the stack.
> >
> > vc4_pv_muxing_test_init() then uses that context to allocate a
> > drm_atomic_state using drm_kunit_helper_atomic_state_alloc(), which
> > stores a pointer to the locking context in the allocated state.
> >
> > However, since vc4_pv_muxing_test_init() is a test init function, the
> > context is then cleared when we leave the function, and before executing
> > the test. We're then running the test with a dangling pointer, which
> > then leads to various crashes.
> >
> > Rework the context initialization and state allocation to move them to
> > drm_vc4_test_pv_muxing() and drm_vc4_test_pv_muxing_invalid().
> >
> > Fixes: 30188df0c387 ("drm/tests: Drop drm_kunit_helper_acquire_ctx_alloc()")
> > Reported-by: Catalin Marinas <catalin.marinas@xxxxxxx>
> > Closes: https://lore.kernel.org/r/Z_95jWM2YMTGy3pi@xxxxxxx/
> > Signed-off-by: Maxime Ripard <mripard@xxxxxxxxxx>
> > ---
> > drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 38 ++++++++++++++++----------
> > 1 file changed, 24 insertions(+), 14 deletions(-)
>
> Hi Maxime,
>
> Didn't you fix this issue in commit 7e0351ae91ed ("drm/vc4: tests: Stop
> allocating the state in test init") [1]?
>
> [1] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/7e0351ae91ed2b6178abbfae96c3c6aaa1652567

I did, and forgot I guess.. :/

It should be on its way to 6.16-rc1 already, so hopefully it'll get
picked up by the stable kernel team at some point.

Maxime

Attachment: signature.asc
Description: PGP signature