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