Patch "drm/virtio: Fix GEM handle creation UAF" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm/virtio: Fix GEM handle creation UAF

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-virtio-fix-gem-handle-creation-uaf.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bbca764a1324b52ab58dcee7935dc73fa0a6b951
Author: Rob Clark <robdclark@xxxxxxxxxxxx>
Date:   Fri Dec 16 15:33:55 2022 -0800

    drm/virtio: Fix GEM handle creation UAF
    
    [ Upstream commit 52531258318ed59a2dc5a43df2eaf0eb1d65438e ]
    
    Userspace can guess the handle value and try to race GEM object creation
    with handle close, resulting in a use-after-free if we dereference the
    object after dropping the handle's reference.  For that reason, dropping
    the handle's reference must be done *after* we are done dereferencing
    the object.
    
    Signed-off-by: Rob Clark <robdclark@xxxxxxxxxxxx>
    Reviewed-by: Chia-I Wu <olvaffe@xxxxxxxxx>
    Fixes: 62fb7a5e1096 ("virtio-gpu: add 3d/virgl support")
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20221216233355.542197-2-robdclark@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index 8d2f5ded86d6..a539843a03ba 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -309,7 +309,6 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
 		}
 		return ret;
 	}
-	drm_gem_object_put_unlocked(obj);
 
 	rc->res_handle = res_id; /* similiar to a VM address */
 	rc->bo_handle = handle;
@@ -318,6 +317,15 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
 		virtio_gpu_unref_list(&validate_list);
 		dma_fence_put(&fence->f);
 	}
+
+	/*
+	 * The handle owns the reference now.  But we must drop our
+	 * remaining reference *after* we no longer need to dereference
+	 * the obj.  Otherwise userspace could guess the handle and
+	 * race closing it from another thread.
+	 */
+	drm_gem_object_put_unlocked(obj);
+
 	return 0;
 fail_unref:
 	if (vgdev->has_virgl_3d) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux