[PATCH] drm/radeon: fix race condition UAF in radeon_gem_set_domain_ioctl

Christian König christian.koenig at amd.com
Thu Jun 1 14:34:01 UTC 2023


Am 26.05.23 um 14:37 schrieb Min Li:
> 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.
>
> Signed-off-by: Min Li <lm0963hack at gmail.com>
> ---
>   drivers/gpu/drm/radeon/radeon_gem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index bdc5af23f005..450c7cbdd28a 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -478,7 +478,7 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
>   
>   	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);

This also makes the robj unused which the kernel test robot also 
complained about.

Please remove that local variable and re-submit.

Apart from that the patch looks good to me,
Christian.

>   	return r;
>   }
>   



More information about the dri-devel mailing list