[PATCH 0/3] Fix a couble of bugs in drm_kunit_helpers.c

Arthur Grillo
2023-09-20T06:12:06Z

This patchset started when I found a use-after-free error reported by
KASAN while running some tests that did some mocking. When trying to fix
the initial problem, I found another noon-related one.

The second bug is just a wrong argument passed to a kunit_release_action
call. Patch #1 solves that.

Patches #2 and #3 solve the use-after-free bug. This error was a bit
trickier to find. Basically, the usual order in which the kunit_actions
run is the culprit, so #2 creates a helper function to reorder actions,
and #3 uses that helper.

Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
---
Arthur Grillo (3):
drm/tests: Fix kunit_release_action ctx argument
kunit: Add kunit_move_action_to_top_or_reset() to reorder actions
drm/tests: Fix a use-after-free bug in __drm_kunit_helper_alloc_drm_device()

drivers/gpu/drm/tests/drm_kunit_helpers.c | 18 +++++++++++++++++-
include/kunit/resource.h | 17 +++++++++++++++++
lib/kunit/resource.c | 19 +++++++++++++++++++
3 files changed, 53 insertions(+), 1 deletion(-)
---
base-commit: 37454bcbb68601c326b58ac45f508067047d791f
change-id: 20230918-kunit-kasan-fixes-88ee78002078

Best regards,
--
Arthur Grillo <arthurgrillo@riseup.net>