|
|
06f91a |
From 05639043d88c1ed4c13670721d222b8621d2fbca Mon Sep 17 00:00:00 2001
|
|
|
06f91a |
From: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
06f91a |
Date: Wed, 9 Feb 2022 13:27:43 -0500
|
|
|
06f91a |
Subject: [KPATCH CVE-2022-22942] drm/vmwgfx: kpatch fixes for CVE-2022-22942
|
|
|
06f91a |
|
|
|
06f91a |
Kernels:
|
|
|
06f91a |
3.10.0-1160.21.1.el7
|
|
|
06f91a |
3.10.0-1160.24.1.el7
|
|
|
06f91a |
3.10.0-1160.25.1.el7
|
|
|
06f91a |
3.10.0-1160.31.1.el7
|
|
|
06f91a |
3.10.0-1160.36.2.el7
|
|
|
06f91a |
3.10.0-1160.41.1.el7
|
|
|
06f91a |
3.10.0-1160.42.2.el7
|
|
|
06f91a |
3.10.0-1160.45.1.el7
|
|
|
06f91a |
3.10.0-1160.49.1.el7
|
|
|
06f91a |
3.10.0-1160.53.1.el7
|
|
|
06f91a |
|
|
|
06f91a |
Changes since last build:
|
|
|
06f91a |
arches: x86_64
|
|
|
06f91a |
vmwgfx_execbuf.o: changed function: vmw_execbuf_copy_fence_user
|
|
|
06f91a |
vmwgfx_execbuf.o: changed function: vmw_execbuf_process
|
|
|
06f91a |
vmwgfx_fence.o: changed function: vmw_fence_event_ioctl
|
|
|
06f91a |
vmwgfx_kms.o: changed function: vmw_kms_helper_validation_finish
|
|
|
06f91a |
---------------------------
|
|
|
06f91a |
|
|
|
06f91a |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/23
|
|
|
06f91a |
Approved-by: Yannick Cote (@ycote1)
|
|
|
06f91a |
Approved-by: Artem Savkov (@artem.savkov)
|
|
|
06f91a |
Kernels:
|
|
|
06f91a |
3.10.0-1160.21.1.el7
|
|
|
06f91a |
3.10.0-1160.24.1.el7
|
|
|
06f91a |
3.10.0-1160.25.1.el7
|
|
|
06f91a |
3.10.0-1160.31.1.el7
|
|
|
06f91a |
3.10.0-1160.36.2.el7
|
|
|
06f91a |
3.10.0-1160.41.1.el7
|
|
|
06f91a |
3.10.0-1160.42.2.el7
|
|
|
06f91a |
3.10.0-1160.45.1.el7
|
|
|
06f91a |
3.10.0-1160.49.1.el7
|
|
|
06f91a |
3.10.0-1160.53.1.el7
|
|
|
06f91a |
|
|
|
06f91a |
Modifications: none
|
|
|
06f91a |
|
|
|
06f91a |
commit 26695bc7aeaf0bae32d7ab7fcf8950143acb5020
|
|
|
06f91a |
Author: Dave Airlie <airlied@redhat.com>
|
|
|
06f91a |
Date: Sat Jan 29 02:36:46 2022 -0500
|
|
|
06f91a |
|
|
|
06f91a |
drm/vmwgfx: Fix stale file descriptors on failed usercopy
|
|
|
06f91a |
|
|
|
06f91a |
Bugzilla: http://bugzilla.redhat.com/2047597
|
|
|
06f91a |
CVE: CVE-2022-22942
|
|
|
06f91a |
|
|
|
06f91a |
commit a0f90c8815706981c483a652a6aefca51a5e191c
|
|
|
06f91a |
Author: Mathias Krause <minipli@grsecurity.net>
|
|
|
06f91a |
Date: Thu Jan 27 18:34:19 2022 +1000
|
|
|
06f91a |
|
|
|
06f91a |
drm/vmwgfx: Fix stale file descriptors on failed usercopy
|
|
|
06f91a |
|
|
|
06f91a |
A failing usercopy of the fence_rep object will lead to a stale entry in
|
|
|
06f91a |
the file descriptor table as put_unused_fd() won't release it. This
|
|
|
06f91a |
enables userland to refer to a dangling 'file' object through that still
|
|
|
06f91a |
valid file descriptor, leading to all kinds of use-after-free
|
|
|
06f91a |
exploitation scenarios.
|
|
|
06f91a |
|
|
|
06f91a |
Fix this by deferring the call to fd_install() until after the usercopy
|
|
|
06f91a |
has succeeded.
|
|
|
06f91a |
|
|
|
06f91a |
Fixes: c906965dee22 ("drm/vmwgfx: Add export fence to file descriptor support")
|
|
|
06f91a |
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
|
|
|
06f91a |
Signed-off-by: Zack Rusin <zackr@vmware.com>
|
|
|
06f91a |
Signed-off-by: Dave Airlie <airlied@redhat.com>
|
|
|
06f91a |
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
|
|
06f91a |
|
|
|
06f91a |
Signed-off-by: Dave Airlie <airlied@redhat.com>
|
|
|
06f91a |
|
|
|
06f91a |
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
06f91a |
---
|
|
|
06f91a |
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 5 ++--
|
|
|
06f91a |
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 34 ++++++++++++-------------
|
|
|
06f91a |
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
|
|
|
06f91a |
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
|
|
|
06f91a |
4 files changed, 21 insertions(+), 22 deletions(-)
|
|
|
06f91a |
|
|
|
06f91a |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
|
|
|
06f91a |
index cd607ba9c2fe..efd540f02227 100644
|
|
|
06f91a |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
|
|
|
06f91a |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
|
|
|
06f91a |
@@ -924,15 +924,14 @@ extern int vmw_execbuf_fence_commands(struct drm_file *file_priv,
|
|
|
06f91a |
struct vmw_private *dev_priv,
|
|
|
06f91a |
struct vmw_fence_obj **p_fence,
|
|
|
06f91a |
uint32_t *p_handle);
|
|
|
06f91a |
-extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
06f91a |
+extern int vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
06f91a |
struct vmw_fpriv *vmw_fp,
|
|
|
06f91a |
int ret,
|
|
|
06f91a |
struct drm_vmw_fence_rep __user
|
|
|
06f91a |
*user_fence_rep,
|
|
|
06f91a |
struct vmw_fence_obj *fence,
|
|
|
06f91a |
uint32_t fence_handle,
|
|
|
06f91a |
- int32_t out_fence_fd,
|
|
|
06f91a |
- struct sync_file *sync_file);
|
|
|
06f91a |
+ int32_t out_fence_fd);
|
|
|
06f91a |
bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd);
|
|
|
06f91a |
|
|
|
06f91a |
/**
|
|
|
06f91a |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
|
|
|
06f91a |
index 88b8178d4687..4f792fb89bb8 100644
|
|
|
06f91a |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
|
|
|
06f91a |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
|
|
|
06f91a |
@@ -3595,20 +3595,19 @@ int vmw_execbuf_fence_commands(struct drm_file *file_priv,
|
|
|
06f91a |
* object so we wait for it immediately, and then unreference the
|
|
|
06f91a |
* user-space reference.
|
|
|
06f91a |
*/
|
|
|
06f91a |
-void
|
|
|
06f91a |
+int
|
|
|
06f91a |
vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
06f91a |
struct vmw_fpriv *vmw_fp,
|
|
|
06f91a |
int ret,
|
|
|
06f91a |
struct drm_vmw_fence_rep __user *user_fence_rep,
|
|
|
06f91a |
struct vmw_fence_obj *fence,
|
|
|
06f91a |
uint32_t fence_handle,
|
|
|
06f91a |
- int32_t out_fence_fd,
|
|
|
06f91a |
- struct sync_file *sync_file)
|
|
|
06f91a |
+ int32_t out_fence_fd)
|
|
|
06f91a |
{
|
|
|
06f91a |
struct drm_vmw_fence_rep fence_rep;
|
|
|
06f91a |
|
|
|
06f91a |
if (user_fence_rep == NULL)
|
|
|
06f91a |
- return;
|
|
|
06f91a |
+ return 0;
|
|
|
06f91a |
|
|
|
06f91a |
memset(&fence_rep, 0, sizeof(fence_rep));
|
|
|
06f91a |
|
|
|
06f91a |
@@ -3636,20 +3635,14 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
06f91a |
* and unreference the handle.
|
|
|
06f91a |
*/
|
|
|
06f91a |
if (unlikely(ret != 0) && (fence_rep.error == 0)) {
|
|
|
06f91a |
- if (sync_file)
|
|
|
06f91a |
- fput(sync_file->file);
|
|
|
06f91a |
-
|
|
|
06f91a |
- if (fence_rep.fd != -1) {
|
|
|
06f91a |
- put_unused_fd(fence_rep.fd);
|
|
|
06f91a |
- fence_rep.fd = -1;
|
|
|
06f91a |
- }
|
|
|
06f91a |
-
|
|
|
06f91a |
ttm_ref_object_base_unref(vmw_fp->tfile,
|
|
|
06f91a |
fence_handle, TTM_REF_USAGE);
|
|
|
06f91a |
DRM_ERROR("Fence copy error. Syncing.\n");
|
|
|
06f91a |
(void) vmw_fence_obj_wait(fence, false, false,
|
|
|
06f91a |
VMW_FENCE_WAIT_TIMEOUT);
|
|
|
06f91a |
}
|
|
|
06f91a |
+
|
|
|
06f91a |
+ return ret ? -EFAULT : 0;
|
|
|
06f91a |
}
|
|
|
06f91a |
|
|
|
06f91a |
/**
|
|
|
06f91a |
@@ -3997,16 +3990,23 @@ int vmw_execbuf_process(struct drm_file *file_priv,
|
|
|
06f91a |
|
|
|
06f91a |
(void) vmw_fence_obj_wait(fence, false, false,
|
|
|
06f91a |
VMW_FENCE_WAIT_TIMEOUT);
|
|
|
06f91a |
+ }
|
|
|
06f91a |
+ }
|
|
|
06f91a |
+
|
|
|
06f91a |
+ ret = vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret,
|
|
|
06f91a |
+ user_fence_rep, fence, handle, out_fence_fd);
|
|
|
06f91a |
+
|
|
|
06f91a |
+ if (sync_file) {
|
|
|
06f91a |
+ if (ret) {
|
|
|
06f91a |
+ /* usercopy of fence failed, put the file object */
|
|
|
06f91a |
+ fput(sync_file->file);
|
|
|
06f91a |
+ put_unused_fd(out_fence_fd);
|
|
|
06f91a |
} else {
|
|
|
06f91a |
/* Link the fence with the FD created earlier */
|
|
|
06f91a |
fd_install(out_fence_fd, sync_file->file);
|
|
|
06f91a |
}
|
|
|
06f91a |
}
|
|
|
06f91a |
|
|
|
06f91a |
- vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret,
|
|
|
06f91a |
- user_fence_rep, fence, handle,
|
|
|
06f91a |
- out_fence_fd, sync_file);
|
|
|
06f91a |
-
|
|
|
06f91a |
/* Don't unreference when handing fence out */
|
|
|
06f91a |
if (unlikely(out_fence != NULL)) {
|
|
|
06f91a |
*out_fence = fence;
|
|
|
06f91a |
@@ -4024,7 +4024,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,
|
|
|
06f91a |
*/
|
|
|
06f91a |
vmw_validation_unref_lists(&val_ctx);
|
|
|
06f91a |
|
|
|
06f91a |
- return 0;
|
|
|
06f91a |
+ return ret;
|
|
|
06f91a |
|
|
|
06f91a |
out_unlock_binding:
|
|
|
06f91a |
mutex_unlock(&dev_priv->binding_mutex);
|
|
|
06f91a |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
|
|
|
06f91a |
index 301260e23e52..624754cc4fc1 100644
|
|
|
06f91a |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
|
|
|
06f91a |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
|
|
|
06f91a |
@@ -1167,7 +1167,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
|
|
|
06f91a |
}
|
|
|
06f91a |
|
|
|
06f91a |
vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence,
|
|
|
06f91a |
- handle, -1, NULL);
|
|
|
06f91a |
+ handle, -1);
|
|
|
06f91a |
vmw_fence_obj_unreference(&fence);
|
|
|
06f91a |
return 0;
|
|
|
06f91a |
out_no_create:
|
|
|
06f91a |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
|
|
|
06f91a |
index ed2f67822f45..fdf58090aa4a 100644
|
|
|
06f91a |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
|
|
|
06f91a |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
|
|
|
06f91a |
@@ -2565,7 +2565,7 @@ void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv,
|
|
|
06f91a |
if (file_priv)
|
|
|
06f91a |
vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv),
|
|
|
06f91a |
ret, user_fence_rep, fence,
|
|
|
06f91a |
- handle, -1, NULL);
|
|
|
06f91a |
+ handle, -1);
|
|
|
06f91a |
if (out_fence)
|
|
|
06f91a |
*out_fence = fence;
|
|
|
06f91a |
else
|
|
|
06f91a |
--
|
|
|
06f91a |
2.26.3
|
|
|
06f91a |
|
|
|
06f91a |
|