|
|
c38cbc |
From 73c1db23af5c7364af380d21739a6e1220a2490d Mon Sep 17 00:00:00 2001
|
|
|
c38cbc |
From: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
c38cbc |
Date: Tue, 1 Mar 2022 15:34:07 -0500
|
|
|
c38cbc |
Subject: [KPATCH CVE-2022-22942] drm/vmwgfx: kpatch fixes for CVE-2022-22942
|
|
|
c38cbc |
|
|
|
c38cbc |
Kernels:
|
|
|
c38cbc |
4.18.0-348.el8
|
|
|
c38cbc |
4.18.0-348.2.1.el8_5
|
|
|
c38cbc |
4.18.0-348.7.1.el8_5
|
|
|
c38cbc |
4.18.0-348.12.2.el8_5
|
|
|
c38cbc |
|
|
|
c38cbc |
Changes since last build:
|
|
|
c38cbc |
arches: x86_64
|
|
|
c38cbc |
vmwgfx_execbuf.o: changed function: vmw_execbuf_copy_fence_user
|
|
|
c38cbc |
vmwgfx_execbuf.o: changed function: vmw_execbuf_process
|
|
|
c38cbc |
vmwgfx_fence.o: changed function: vmw_fence_event_ioctl
|
|
|
c38cbc |
vmwgfx_kms.o: changed function: vmw_kms_helper_validation_finish
|
|
|
c38cbc |
---------------------------
|
|
|
c38cbc |
|
|
|
c38cbc |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/32
|
|
|
c38cbc |
Approved-by: Yannick Cote (@ycote1)
|
|
|
c38cbc |
Kernels:
|
|
|
c38cbc |
4.18.0-348.el8
|
|
|
c38cbc |
4.18.0-348.2.1.el8_5
|
|
|
c38cbc |
4.18.0-348.7.1.el8_5
|
|
|
c38cbc |
4.18.0-348.12.2.el8_5
|
|
|
c38cbc |
|
|
|
c38cbc |
Modifications: none
|
|
|
c38cbc |
|
|
|
c38cbc |
commit 1b221c65601c93cb4ad2b24487c0015d6bae7c7f
|
|
|
c38cbc |
Author: Dave Airlie <airlied@redhat.com>
|
|
|
c38cbc |
Date: Fri Jan 28 16:36:48 2022 -0500
|
|
|
c38cbc |
|
|
|
c38cbc |
drm/vmwgfx: Fix stale file descriptors on failed usercopy
|
|
|
c38cbc |
|
|
|
c38cbc |
Bugzilla: https://bugzilla.redhat.com/2047601
|
|
|
c38cbc |
CVE: CVE-2022-22942
|
|
|
c38cbc |
Y-Commit: b6793b842fba127aa491384431e84b79c7619afd
|
|
|
c38cbc |
|
|
|
c38cbc |
O-Bugzilla: http://bugzilla.redhat.com/2047602
|
|
|
c38cbc |
O-CVE: CVE-2022-22942
|
|
|
c38cbc |
|
|
|
c38cbc |
commit a0f90c8815706981c483a652a6aefca51a5e191c
|
|
|
c38cbc |
Author: Mathias Krause <minipli@grsecurity.net>
|
|
|
c38cbc |
Date: Thu Jan 27 18:34:19 2022 +1000
|
|
|
c38cbc |
|
|
|
c38cbc |
drm/vmwgfx: Fix stale file descriptors on failed usercopy
|
|
|
c38cbc |
|
|
|
c38cbc |
A failing usercopy of the fence_rep object will lead to a stale entry in
|
|
|
c38cbc |
the file descriptor table as put_unused_fd() won't release it. This
|
|
|
c38cbc |
enables userland to refer to a dangling 'file' object through that still
|
|
|
c38cbc |
valid file descriptor, leading to all kinds of use-after-free
|
|
|
c38cbc |
exploitation scenarios.
|
|
|
c38cbc |
|
|
|
c38cbc |
Fix this by deferring the call to fd_install() until after the usercopy
|
|
|
c38cbc |
has succeeded.
|
|
|
c38cbc |
|
|
|
c38cbc |
Fixes: c906965dee22 ("drm/vmwgfx: Add export fence to file descriptor support")
|
|
|
c38cbc |
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
|
|
|
c38cbc |
Signed-off-by: Zack Rusin <zackr@vmware.com>
|
|
|
c38cbc |
Signed-off-by: Dave Airlie <airlied@redhat.com>
|
|
|
c38cbc |
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
|
|
c38cbc |
|
|
|
c38cbc |
Signed-off-by: Dave Airlie <airlied@redhat.com>
|
|
|
c38cbc |
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
|
|
|
c38cbc |
|
|
|
c38cbc |
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
|
|
|
c38cbc |
---
|
|
|
c38cbc |
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 5 ++--
|
|
|
c38cbc |
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 33 +++++++++++++------------
|
|
|
c38cbc |
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
|
|
|
c38cbc |
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
|
|
|
c38cbc |
4 files changed, 21 insertions(+), 21 deletions(-)
|
|
|
c38cbc |
|
|
|
c38cbc |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
|
|
|
c38cbc |
index eb76a6b9ebca..2f4f39446240 100644
|
|
|
c38cbc |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
|
|
|
c38cbc |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
|
|
|
c38cbc |
@@ -1069,15 +1069,14 @@ extern int vmw_execbuf_fence_commands(struct drm_file *file_priv,
|
|
|
c38cbc |
struct vmw_private *dev_priv,
|
|
|
c38cbc |
struct vmw_fence_obj **p_fence,
|
|
|
c38cbc |
uint32_t *p_handle);
|
|
|
c38cbc |
-extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
c38cbc |
+extern int vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
c38cbc |
struct vmw_fpriv *vmw_fp,
|
|
|
c38cbc |
int ret,
|
|
|
c38cbc |
struct drm_vmw_fence_rep __user
|
|
|
c38cbc |
*user_fence_rep,
|
|
|
c38cbc |
struct vmw_fence_obj *fence,
|
|
|
c38cbc |
uint32_t fence_handle,
|
|
|
c38cbc |
- int32_t out_fence_fd,
|
|
|
c38cbc |
- struct sync_file *sync_file);
|
|
|
c38cbc |
+ int32_t out_fence_fd);
|
|
|
c38cbc |
bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd);
|
|
|
c38cbc |
|
|
|
c38cbc |
/**
|
|
|
c38cbc |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
|
|
|
c38cbc |
index 462f17320708..399cb4cce292 100644
|
|
|
c38cbc |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
|
|
|
c38cbc |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
|
|
|
c38cbc |
@@ -3804,17 +3804,17 @@ int vmw_execbuf_fence_commands(struct drm_file *file_priv,
|
|
|
c38cbc |
* Also if copying fails, user-space will be unable to signal the fence object
|
|
|
c38cbc |
* so we wait for it immediately, and then unreference the user-space reference.
|
|
|
c38cbc |
*/
|
|
|
c38cbc |
-void
|
|
|
c38cbc |
+int
|
|
|
c38cbc |
vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
c38cbc |
struct vmw_fpriv *vmw_fp, int ret,
|
|
|
c38cbc |
struct drm_vmw_fence_rep __user *user_fence_rep,
|
|
|
c38cbc |
struct vmw_fence_obj *fence, uint32_t fence_handle,
|
|
|
c38cbc |
- int32_t out_fence_fd, struct sync_file *sync_file)
|
|
|
c38cbc |
+ int32_t out_fence_fd)
|
|
|
c38cbc |
{
|
|
|
c38cbc |
struct drm_vmw_fence_rep fence_rep;
|
|
|
c38cbc |
|
|
|
c38cbc |
if (user_fence_rep == NULL)
|
|
|
c38cbc |
- return;
|
|
|
c38cbc |
+ return 0;
|
|
|
c38cbc |
|
|
|
c38cbc |
memset(&fence_rep, 0, sizeof(fence_rep));
|
|
|
c38cbc |
|
|
|
c38cbc |
@@ -3842,20 +3842,14 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
|
|
|
c38cbc |
* handle.
|
|
|
c38cbc |
*/
|
|
|
c38cbc |
if (unlikely(ret != 0) && (fence_rep.error == 0)) {
|
|
|
c38cbc |
- if (sync_file)
|
|
|
c38cbc |
- fput(sync_file->file);
|
|
|
c38cbc |
-
|
|
|
c38cbc |
- if (fence_rep.fd != -1) {
|
|
|
c38cbc |
- put_unused_fd(fence_rep.fd);
|
|
|
c38cbc |
- fence_rep.fd = -1;
|
|
|
c38cbc |
- }
|
|
|
c38cbc |
-
|
|
|
c38cbc |
ttm_ref_object_base_unref(vmw_fp->tfile, fence_handle,
|
|
|
c38cbc |
TTM_REF_USAGE);
|
|
|
c38cbc |
VMW_DEBUG_USER("Fence copy error. Syncing.\n");
|
|
|
c38cbc |
(void) vmw_fence_obj_wait(fence, false, false,
|
|
|
c38cbc |
VMW_FENCE_WAIT_TIMEOUT);
|
|
|
c38cbc |
}
|
|
|
c38cbc |
+
|
|
|
c38cbc |
+ return ret ? -EFAULT : 0;
|
|
|
c38cbc |
}
|
|
|
c38cbc |
|
|
|
c38cbc |
/**
|
|
|
c38cbc |
@@ -4193,16 +4187,23 @@ int vmw_execbuf_process(struct drm_file *file_priv,
|
|
|
c38cbc |
|
|
|
c38cbc |
(void) vmw_fence_obj_wait(fence, false, false,
|
|
|
c38cbc |
VMW_FENCE_WAIT_TIMEOUT);
|
|
|
c38cbc |
+ }
|
|
|
c38cbc |
+ }
|
|
|
c38cbc |
+
|
|
|
c38cbc |
+ ret = vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret,
|
|
|
c38cbc |
+ user_fence_rep, fence, handle, out_fence_fd);
|
|
|
c38cbc |
+
|
|
|
c38cbc |
+ if (sync_file) {
|
|
|
c38cbc |
+ if (ret) {
|
|
|
c38cbc |
+ /* usercopy of fence failed, put the file object */
|
|
|
c38cbc |
+ fput(sync_file->file);
|
|
|
c38cbc |
+ put_unused_fd(out_fence_fd);
|
|
|
c38cbc |
} else {
|
|
|
c38cbc |
/* Link the fence with the FD created earlier */
|
|
|
c38cbc |
fd_install(out_fence_fd, sync_file->file);
|
|
|
c38cbc |
}
|
|
|
c38cbc |
}
|
|
|
c38cbc |
|
|
|
c38cbc |
- vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret,
|
|
|
c38cbc |
- user_fence_rep, fence, handle, out_fence_fd,
|
|
|
c38cbc |
- sync_file);
|
|
|
c38cbc |
-
|
|
|
c38cbc |
/* Don't unreference when handing fence out */
|
|
|
c38cbc |
if (unlikely(out_fence != NULL)) {
|
|
|
c38cbc |
*out_fence = fence;
|
|
|
c38cbc |
@@ -4220,7 +4221,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,
|
|
|
c38cbc |
*/
|
|
|
c38cbc |
vmw_validation_unref_lists(&val_ctx);
|
|
|
c38cbc |
|
|
|
c38cbc |
- return 0;
|
|
|
c38cbc |
+ return ret;
|
|
|
c38cbc |
|
|
|
c38cbc |
out_unlock_binding:
|
|
|
c38cbc |
mutex_unlock(&dev_priv->binding_mutex);
|
|
|
c38cbc |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
|
|
|
c38cbc |
index 378ec7600154..23cf8a264f3d 100644
|
|
|
c38cbc |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
|
|
|
c38cbc |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
|
|
|
c38cbc |
@@ -1167,7 +1167,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
|
|
|
c38cbc |
}
|
|
|
c38cbc |
|
|
|
c38cbc |
vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence,
|
|
|
c38cbc |
- handle, -1, NULL);
|
|
|
c38cbc |
+ handle, -1);
|
|
|
c38cbc |
vmw_fence_obj_unreference(&fence);
|
|
|
c38cbc |
return 0;
|
|
|
c38cbc |
out_no_create:
|
|
|
c38cbc |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
|
|
|
c38cbc |
index 9a89f658e501..bb0448044ced 100644
|
|
|
c38cbc |
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
|
|
|
c38cbc |
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
|
|
|
c38cbc |
@@ -2477,7 +2477,7 @@ void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv,
|
|
|
c38cbc |
if (file_priv)
|
|
|
c38cbc |
vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv),
|
|
|
c38cbc |
ret, user_fence_rep, fence,
|
|
|
c38cbc |
- handle, -1, NULL);
|
|
|
c38cbc |
+ handle, -1);
|
|
|
c38cbc |
if (out_fence)
|
|
|
c38cbc |
*out_fence = fence;
|
|
|
c38cbc |
else
|
|
|
c38cbc |
--
|
|
|
c38cbc |
2.34.1
|
|
|
c38cbc |
|
|
|
c38cbc |
|