public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] drm/buddy: Fix BUG_ON from oversized rounded allocations
@ 2026-01-08 11:32 Sanjay Yadav
  2026-01-08 11:32 ` [PATCH v2 1/2] drm/buddy: Prevent BUG_ON by validating rounded allocation Sanjay Yadav
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Sanjay Yadav @ 2026-01-08 11:32 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-xe, Christian König, Arunpravin Paneer Selvam,
	Matthew Auld

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 <christian.koenig@amd.com>
Cc: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Suggested-by: Matthew Auld <matthew.auld@intel.com>

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(+)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-01-21 10:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 11:32 [PATCH v2 0/2] drm/buddy: Fix BUG_ON from oversized rounded allocations Sanjay Yadav
2026-01-08 11:32 ` [PATCH v2 1/2] drm/buddy: Prevent BUG_ON by validating rounded allocation Sanjay Yadav
2026-01-20 10:41   ` Matthew Auld
2026-01-21  6:36     ` Arunpravin Paneer Selvam
2026-01-21 10:00       ` Matthew Auld
2026-01-08 11:32 ` [PATCH v2 2/2] drm/tests/drm_buddy: Add tests for allocations exceeding max_order Sanjay Yadav
2026-01-08 11:46 ` ✓ CI.KUnit: success for drm/buddy: Fix BUG_ON from oversized rounded allocations (rev2) Patchwork
2026-01-08 12:01 ` ✗ CI.checksparse: warning " Patchwork
2026-01-08 12:24 ` ✓ Xe.CI.BAT: success " Patchwork
2026-01-08 15:36 ` ✗ Xe.CI.Full: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox