Skip to content

drm/buddy: Fix BUG_ON from oversized rounded allocations

Sanjay Yadav dri-devel intel-xe stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 4 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2drm/buddy: Prevent BUG_ON by validating rounded allocationdrivers/gpu/drm/drm_buddy.c+9 -03 replies
2/2drm/tests/drm_buddy: Add tests for allocations exceeding max_orderdrivers/gpu/drm/tests/drm_buddy_test.c+35 -00 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchMatthew AuldArunpravin Paneer Selvam
1/2R-b R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] drm/buddy: Fix BUG_ON from oversized rounded allocations

This series addresses a crash in drm_buddy allocator when allocation requests exceed mm->max_order after rounding operations. This can occur with non-power-of-two VRAM sizes (e.g., 10G = 8G + 2G roots) where mm->max_order represents the largest block (8G).

The issue manifests in two scenarios:

1. CONTIGUOUS allocations: roundup_pow_of_two(9G) = 16G > 10G
2. Large min_block_size: round_up(9G, 8G) = 16G > 10G

Both cases trigger BUG_ON(order > mm->max_order) deep in the allocation path, crashing the system on invalid user input.

The fix validates the rounded size early and handles it appropriately:
- For CONTIGUOUS-only allocations, use the existing try_harder fallback
- For other cases (non-contiguous, or contiguous+range), return -EINVAL

v2: (Matt A)
- Add Fixes, Cc stable, and Closes tags for context

Cc Christian König <[email protected]>
Cc Arunpravin Paneer Selvam <[email protected]>

Sanjay Yadav (2):
drm/buddy: Prevent BUG_ON by validating rounded allocation drm/tests/drm_buddy: Add tests for allocations exceeding max_order

 drivers/gpu/drm/drm_buddy.c            |  9 +++++++
 drivers/gpu/drm/tests/drm_buddy_test.c | 35 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
Signature · 1 line
2.52.0