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