* [PATCH] drm/ttm: Don't warn on oversized page directory allocations
@ 2026-11-21 9:18 Shuicheng Lin
2026-11-21 9:32 ` sashiko-bot
0 siblings, 1 reply; 2+ 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] 2+ messages in thread* Re: [PATCH] drm/ttm: Don't warn on oversized page directory allocations
2026-11-21 9:18 [PATCH] drm/ttm: Don't warn on oversized page directory allocations Shuicheng Lin
@ 2026-11-21 9:32 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-21 9:32 UTC (permalink / raw)
To: Shuicheng Lin, dri-devel; +Cc: intel-xe
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/ttm: missing __GFP_NOWARN in
ttm_sg_tt_alloc_page_directory()
--
commit b4df7a501d5e41a0a776550ea76ddd972d2c5a9c
Author: Shuicheng Lin <shuicheng.lin@intel.com>
drm/ttm: Don't warn on oversized page directory allocations
This commit passes __GFP_NOWARN to kvcalloc() in
ttm_tt_alloc_page_directory() and ttm_dma_tt_alloc_page_directory() to
prevent user-controlled BO sizes from triggering oversized allocation
warnings in kvmalloc().
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index b645a18181843..5dc9d3795b046 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;
>
[Severity: Medium]
Should ttm_sg_tt_alloc_page_directory() immediately below also pass
GFP_KERNEL | __GFP_NOWARN to kvzalloc_objs()?
drivers/gpu/drm/ttm/ttm_tt.c:ttm_sg_tt_alloc_page_directory() {
ttm->dma_address = kvzalloc_objs(*ttm->dma_address, ttm->num_pages);
if (!ttm->dma_address)
return -ENOMEM;
return 0;
}
ttm_sg_tt_init() calls ttm_sg_tt_alloc_page_directory() for
TTM_TT_FLAG_EXTERNAL objects (such as ttm_bo_type_sg), which can be
reached when importing a dma-buf > 1 TiB via DRM_IOCTL_PRIME_FD_TO_HANDLE
(for example through amdgpu_gem_prime_import() ->
amdgpu_dma_buf_create_obj() -> amdgpu_gem_object_create(), which creates
and validates the BO in AMDGPU_GEM_DOMAIN_CPU before attaching the
dma-buf), triggering the same WARN_ON_ONCE(size > INT_MAX) in
__kvmalloc_node_noprof().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121091815.1436090-2-shuicheng.lin@intel.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-21 9:32 UTC | newest]
Thread overview: 2+ 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:32 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox