Skip to content

Commit dcb1719

Browse files
sanjayumangThomas Hellström
authored andcommitted
drm/xe/oa: Fix potential UAF in xe_oa_add_config_ioctl()
In xe_oa_add_config_ioctl(), we accessed oa_config->id after dropping metrics_lock. Since this lock protects the lifetime of oa_config, an attacker could guess the id and call xe_oa_remove_config_ioctl() with perfect timing, freeing oa_config before we dereference it, leading to a potential use-after-free. Fix this by caching the id in a local variable while holding the lock. v2: (Matt A) - Dropped mutex_unlock(&oa->metrics_lock) ordering change from xe_oa_remove_config_ioctl() Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/6614 Fixes: cdf02fe ("drm/xe/oa/uapi: Add/remove OA config perf ops") Cc: <stable@vger.kernel.org> # v6.11+ Suggested-by: Matthew Auld <matthew.auld@intel.com> Signed-off-by: Sanjay Yadav <sanjay.kumar.yadav@intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Signed-off-by: Matthew Auld <matthew.auld@intel.com> Link: https://patch.msgid.link/20251118114859.3379952-2-sanjay.kumar.yadav@intel.com (cherry picked from commit 28aeaed) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 551801b commit dcb1719

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,11 +2403,13 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
24032403
goto sysfs_err;
24042404
}
24052405

2406-
mutex_unlock(&oa->metrics_lock);
2406+
id = oa_config->id;
2407+
2408+
drm_dbg(&oa->xe->drm, "Added config %s id=%i\n", oa_config->uuid, id);
24072409

2408-
drm_dbg(&oa->xe->drm, "Added config %s id=%i\n", oa_config->uuid, oa_config->id);
2410+
mutex_unlock(&oa->metrics_lock);
24092411

2410-
return oa_config->id;
2412+
return id;
24112413

24122414
sysfs_err:
24132415
mutex_unlock(&oa->metrics_lock);

0 commit comments

Comments
 (0)