]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/oa: Limit num_syncs to prevent oversized allocations
authorShuicheng Lin <shuicheng.lin@intel.com>
Fri, 5 Dec 2025 23:47:18 +0000 (23:47 +0000)
committerMatthew Brost <matthew.brost@intel.com>
Mon, 15 Dec 2025 21:33:58 +0000 (13:33 -0800)
The OA open parameters did not validate num_syncs, allowing
userspace to pass arbitrarily large values, potentially
leading to excessive allocations.

Add check to ensure that num_syncs does not exceed DRM_XE_MAX_SYNCS,
returning -EINVAL when the limit is violated.

v2: use XE_IOCTL_DBG() and drop duplicated check. (Ashutosh)

Fixes: c8507a25cebd ("drm/xe/oa/uapi: Define and parse OA sync properties")
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20251205234715.2476561-6-shuicheng.lin@intel.com
drivers/gpu/drm/xe/xe_oa.c

index cc48663c2b48f314432f6a9b15340b8acc849bfd..92aa25fc0422fb5a8d9cafb170e559d65ac48abc 100644 (file)
@@ -1254,6 +1254,9 @@ static int xe_oa_set_no_preempt(struct xe_oa *oa, u64 value,
 static int xe_oa_set_prop_num_syncs(struct xe_oa *oa, u64 value,
                                    struct xe_oa_open_param *param)
 {
+       if (XE_IOCTL_DBG(oa->xe, value > DRM_XE_MAX_SYNCS))
+               return -EINVAL;
+
        param->num_syncs = value;
        return 0;
 }