All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/ttm: Don't warn on oversized page directory allocations
@ 2026-11-21  9:18 Shuicheng Lin
  2026-11-21  9:27 ` ✓ CI.KUnit: success for " Patchwork
  2026-11-21  9:32 ` [PATCH] " sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: Shuicheng Lin @ 2026-11-21  9:18 UTC (permalink / raw)
  To: dri-devel
  Cc: Shuicheng Lin, intel-xe, Natalie Vock, Arun Pravin, Matthew Auld,
	Matthew Brost, Thomas Hellström, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, linux-kernel

The page directory size in ttm_tt_alloc_page_directory() and
ttm_dma_tt_alloc_page_directory() comes from the user-supplied BO size.
kvmalloc() warns on requests above INT_MAX unless __GFP_NOWARN is set,
so userspace can trigger a WARN (or a panic with panic_on_warn) by
creating a huge BO, e.g. a 1 TiB sysmem BO on xe with DEFER_BACKING:

  WARNING: mm/slub.c:7144 at __kvmalloc_node_noprof+0x665/0x810
  Call Trace:
   ttm_tt_init+0x1e0/0x2b0
   xe_ttm_tt_create+0x2cf/0x4b0 [xe]
   ttm_tt_create+0x17c/0x310
   ...
   xe_gem_create_ioctl+0x70f/0x12b0 [xe]

The failure is already handled and the ioctl returns -ENOMEM, so pass
__GFP_NOWARN to both allocations.

Fixes: 7661809d493b ("mm: don't allow oversized kvmalloc() calls")
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 drivers/gpu/drm/ttm/ttm_tt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index b645a1818184..5dc9d3795b04 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -117,7 +117,8 @@ EXPORT_SYMBOL_FOR_TESTS_ONLY(ttm_tt_create);
  */
 static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
-	ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*), GFP_KERNEL);
+	ttm->pages = kvcalloc(ttm->num_pages, sizeof(void *),
+			      GFP_KERNEL | __GFP_NOWARN);
 	if (!ttm->pages)
 		return -ENOMEM;
 
@@ -127,7 +128,8 @@ static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
 static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
 	ttm->pages = kvcalloc(ttm->num_pages, sizeof(*ttm->pages) +
-			      sizeof(*ttm->dma_address), GFP_KERNEL);
+			      sizeof(*ttm->dma_address),
+			      GFP_KERNEL | __GFP_NOWARN);
 	if (!ttm->pages)
 		return -ENOMEM;
 

base-commit: 61df0d1929e7e99d38404a1be02c461a8f6a3f5a
-- 
2.43.0


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

end of thread, other threads:[~2026-11-21  9:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21  9:18 [PATCH] drm/ttm: Don't warn on oversized page directory allocations Shuicheng Lin
2026-11-21  9:27 ` ✓ CI.KUnit: success for " Patchwork
2026-11-21  9:32 ` [PATCH] " sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.