mirror-linux/include/uapi/drm
Shuicheng Lin 8e46130400 drm/xe: Limit num_syncs to prevent oversized allocations
The exec and vm_bind ioctl allow userspace to specify an arbitrary
num_syncs value. Without bounds checking, a very large num_syncs
can force an excessively large allocation, leading to kernel warnings
from the page allocator as below.

Introduce DRM_XE_MAX_SYNCS (set to 1024) and reject any request
exceeding this limit.

"
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1217 at mm/page_alloc.c:5124 __alloc_frozen_pages_noprof+0x2f8/0x2180 mm/page_alloc.c:5124
...
Call Trace:
 <TASK>
 alloc_pages_mpol+0xe4/0x330 mm/mempolicy.c:2416
 ___kmalloc_large_node+0xd8/0x110 mm/slub.c:4317
 __kmalloc_large_node_noprof+0x18/0xe0 mm/slub.c:4348
 __do_kmalloc_node mm/slub.c:4364 [inline]
 __kmalloc_noprof+0x3d4/0x4b0 mm/slub.c:4388
 kmalloc_noprof include/linux/slab.h:909 [inline]
 kmalloc_array_noprof include/linux/slab.h:948 [inline]
 xe_exec_ioctl+0xa47/0x1e70 drivers/gpu/drm/xe/xe_exec.c:158
 drm_ioctl_kernel+0x1f1/0x3e0 drivers/gpu/drm/drm_ioctl.c:797
 drm_ioctl+0x5e7/0xc50 drivers/gpu/drm/drm_ioctl.c:894
 xe_drm_ioctl+0x10b/0x170 drivers/gpu/drm/xe/xe_device.c:224
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl fs/ioctl.c:584 [inline]
 __x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xbb/0x380 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
...
"

v2: Add "Reported-by" and Cc stable kernels.
v3: Change XE_MAX_SYNCS from 64 to 1024. (Matt & Ashutosh)
v4: s/XE_MAX_SYNCS/DRM_XE_MAX_SYNCS/ (Matt)
v5: Do the check at the top of the exec func. (Matt)

Fixes: dd08ebf6c3 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Reported-by: Koen Koning <koen.koning@intel.com>
Reported-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6450
Cc: <stable@vger.kernel.org> # v6.12+
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michal Mrozek <michal.mrozek@intel.com>
Cc: Carl Zhang <carl.zhang@intel.com>
Cc: José Roberto de Souza <jose.souza@intel.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Ivan Briano <ivan.briano@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251205234715.2476561-5-shuicheng.lin@intel.com
(cherry picked from commit b07bac9bd708ec468cd1b8a5fe70ae2ac9b0a11c)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
2025-12-18 18:10:34 +01:00
..
amdgpu_drm.h drm/colorop: Add 3x4 CTM type 2025-11-26 23:03:33 +01:00
amdxdna_accel.h accel/amdxdna: Support preemption requests 2025-11-05 08:56:28 -08:00
armada_drm.h
asahi_drm.h drm: Add UAPI for the Asahi driver 2025-04-08 17:15:57 -04:00
drm.h drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 2025-11-26 23:03:32 +01:00
drm_fourcc.h drm: define NVIDIA DRM format modifiers for GB20x 2025-11-06 11:01:45 +10:00
drm_mode.h drm/colorop: Add 3D LUT support to color pipeline 2025-11-26 23:09:42 +01:00
drm_sarea.h
ethosu_accel.h accel: Add Arm Ethos-U NPU driver 2025-10-24 15:07:39 -05:00
etnaviv_drm.h Revert "drm/etnaviv: Expose a few more chipspecs to userspace" 2024-04-25 16:56:20 +02:00
exynos_drm.h
habanalabs_accel.h accel/habanalabs/gaudi2: add signed dev info uAPI 2023-12-19 11:09:43 +02:00
i915_drm.h drm/i915: Support replaying GPU hangs with captured context image 2024-05-16 07:37:05 +00:00
ivpu_accel.h accel/ivpu: Add support for userptr buffer objects 2025-10-30 08:52:51 +01:00
lima_drm.h
msm_drm.h drm/msm: Add VM_BIND ioctl 2025-07-04 17:48:38 -07:00
nouveau_drm.h drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations 2024-05-13 22:27:33 +02:00
nova_drm.h drm: nova-drm: add initial driver skeleton 2025-05-12 20:48:15 +02:00
omap_drm.h
panfrost_drm.h drm/panfrost: fix UAPI kernel-doc warnings 2025-11-06 08:34:12 +00:00
panthor_drm.h drm/panthor: Add support for Mali-Gx15 family of GPUs 2025-08-15 10:51:24 +01:00
pvr_drm.h drm/imagination: Numerous documentation fixes. 2023-11-28 18:56:03 +01:00
qaic_accel.h accel/qaic: Fix typo for struct qaic_manage_trans_passthrough 2024-12-13 08:55:09 -07:00
qxl_drm.h
radeon_drm.h
rocket_accel.h accel/rocket: Add IOCTLs for synchronizing memory accesses 2025-07-25 10:04:46 -06:00
tegra_drm.h
v3d_drm.h drm/v3d: Add parameter to retrieve the number of GPU resets per-fd 2025-07-17 11:17:32 -03:00
vc4_drm.h
vgem_drm.h
virtgpu_drm.h drm/virtio: Add capset definitions to UAPI 2025-03-28 04:53:51 +03:00
vmwgfx_drm.h drm/vmwgfx: Add SPDX header to vmwgfx_drm.h 2024-01-30 14:18:19 -05:00
xe_drm.h drm/xe: Limit num_syncs to prevent oversized allocations 2025-12-18 18:10:34 +01:00