[Devel] [PATCH hci-8.2 0/4] drm/buddy: backport buddy allocator fixes
Mirian Shilakadze
mirian.shilakadze at virtuozzo.com
Wed Nov 18 14:38:09 MSK 2026
Item 1 from the review of VSTOR-154850 v1. Upstream fixes for the buddy
allocator code that came with the RHEL import:
1. 5488a29596cd: a rounded up allocation larger than the memory size
hits BUG_ON(order > mm->max_order).
2. 0251963afd22: a failed split_block() leaves a freed block in the free
tree (use-after-free).
3. 56bc6384314f: the contiguous fallback can return a start that ignores
min_block_size.
4. fb26cf4f1df4: when the contiguous fallback fails or retries, it
frees the whole list the caller passed in, including blocks the
caller allocated before. Not in the ticket and not in mainline yet
(linux-next, Cc stable). Taken because it fixes the same fallback as
3 and the drm_buddy suite catches it: without 4, alloc_contiguous
fails on the check that 4 adds.
Patches 2 to 4 are adapted to the drm_buddy names. 264.x already has 1
from RHEL, and 2 to 4 apply to it as is.
Tested with KUnit on the 211.75.1.26.2 debug kernel (KASAN, failslab),
stock and patched drm_buddy.ko built from this tree:
- drm_buddy suite with the test from 4: stock and 1-3 fail only
alloc_contiguous, on the check that 4 adds. 1-4 pass.
- dc0e3aa54eaa, the mainline test for 1: stock hits the BUG_ON, patched
passes.
- try_harder alignment (own test): stock returns 12K at 8K for a 16K
min_block_size, patched returns -ENOSPC.
- split_block() failing in alloc_from_freetree(), __alloc_range() and
__alloc_range_bias() via failslab (own test): stock gives KASAN
slab-use-after-free and then the BUG_ON in alloc_from_freetree(),
patched passes at every injection point.
- ve selftests: the same with stock and patched drm_buddy.ko
(ve_ns_owner_test and ve_vtty_stress fail on both).
https://virtuozzo.atlassian.net/browse/VSTOR-155318
Arunpravin Paneer Selvam (1):
ms/gpu/buddy: bail out of try_harder when alignment cannot be honoured
Francois Dugast (1):
ms/gpu/buddy: Fix use-after-free in split_block() call sites
Matthew Auld (1):
ms/gpu/buddy: do not pass caller list to __alloc_contig_try_harder()
Sanjay Yadav (1):
ms/drm/buddy: Prevent BUG_ON by validating rounded allocation
drivers/gpu/drm/drm_buddy.c | 107 ++++++++++++++++++-------
drivers/gpu/drm/tests/drm_buddy_test.c | 9 +++
2 files changed, 89 insertions(+), 27 deletions(-)
--
2.47.3
More information about the Devel
mailing list