[PATCH] drm/ttm: Don't warn on oversized page directory allocations

From: Shuicheng Lin

Date: Sat Nov 21 2026 - 04:18:54 EST


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@xxxxxxxxx>
---
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