summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMin Li <lm0963hack@gmail.com>2023-06-03 15:43:45 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-28 10:29:53 +0200
commitfdac0aa4a175069105ad79112ba99913b8be1167 (patch)
treef7ae1e1c9651d6931fd0058f5509d8b82c428599
parentf012d3037c15401dd72d8717806311dc4c568ea8 (diff)
downloadlinux-stable-fdac0aa4a175069105ad79112ba99913b8be1167.tar.gz
linux-stable-fdac0aa4a175069105ad79112ba99913b8be1167.tar.bz2
linux-stable-fdac0aa4a175069105ad79112ba99913b8be1167.zip
drm/radeon: fix race condition UAF in radeon_gem_set_domain_ioctl
[ Upstream commit 982b173a6c6d9472730c3116051977e05d17c8c5 ] Userspace can race to free the gobj(robj converted from), robj should not be accessed again after drm_gem_object_put, otherwith it will result in use-after-free. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Min Li <lm0963hack@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index a36a4f2c76b0..57218263ef3b 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -456,7 +456,6 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
struct radeon_device *rdev = dev->dev_private;
struct drm_radeon_gem_set_domain *args = data;
struct drm_gem_object *gobj;
- struct radeon_bo *robj;
int r;
/* for now if someone requests domain CPU -
@@ -469,13 +468,12 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
up_read(&rdev->exclusive_lock);
return -ENOENT;
}
- robj = gem_to_radeon_bo(gobj);
r = radeon_gem_set_domain(gobj, args->read_domains, args->write_domain);
drm_gem_object_put(gobj);
up_read(&rdev->exclusive_lock);
- r = radeon_gem_handle_lockup(robj->rdev, r);
+ r = radeon_gem_handle_lockup(rdev, r);
return r;
}