Skip to content

Commit dc30c01

Browse files
Min Lijnikula
authored andcommitted
drm/i915: fix race condition UAF in i915_perf_add_config_ioctl
Userspace can guess the id value and try to race oa_config object creation with config remove, resulting in a use-after-free if we dereference the object after unlocking the metrics_lock. For that reason, unlocking the metrics_lock must be done after we are done dereferencing the object. Signed-off-by: Min Li <[email protected]> Fixes: f89823c ("drm/i915/perf: Implement I915_PERF_ADD/REMOVE_CONFIG interface") Cc: <[email protected]> # v4.14+ Reviewed-by: Andi Shyti <[email protected]> Reviewed-by: Umesh Nerlige Ramappa <[email protected]> Signed-off-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] [tursulin: Manually added stable tag.] (cherry picked from commit 49f6f64) Signed-off-by: Jani Nikula <[email protected]>
1 parent 95d939b commit dc30c01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/i915/i915_perf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,13 +4638,13 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
46384638
err = oa_config->id;
46394639
goto sysfs_err;
46404640
}
4641-
4642-
mutex_unlock(&perf->metrics_lock);
4641+
id = oa_config->id;
46434642

46444643
drm_dbg(&perf->i915->drm,
46454644
"Added config %s id=%i\n", oa_config->uuid, oa_config->id);
4645+
mutex_unlock(&perf->metrics_lock);
46464646

4647-
return oa_config->id;
4647+
return id;
46484648

46494649
sysfs_err:
46504650
mutex_unlock(&perf->metrics_lock);

0 commit comments

Comments
 (0)