From: Thomas Hellstrom <thellstrom@vmware.com>
To: dri-devel@lists.freedesktop.org
Cc: Sinclair Yeh <syeh@vmware.com>, stable@vger.kernel.org
Subject: [PATCH -fixes 4/9] drm/vmwgfx: Make sure backup_handle is always valid
Date: Wed, 7 Jun 2017 15:24:20 +0200 [thread overview]
Message-ID: <1496841865-2349-4-git-send-email-thellstrom@vmware.com> (raw)
In-Reply-To: <1496841865-2349-1-git-send-email-thellstrom@vmware.com>
From: Sinclair Yeh <syeh@vmware.com>
When vmw_gb_surface_define_ioctl() is called with an existing buffer,
we end up returning an uninitialized variable in the backup_handle.
The fix is to first initialize backup_handle to 0 just to be sure, and
second, when a user-provided buffer is found, we will use the
req->buffer_handle as the backup_handle.
Cc: <stable@vger.kernel.org>
Reported-by: Murray McAllister <murray.mcallister@insomniasec.com>
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Deepak Rawat <drawat@vmware.com>
---
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index baf03d4..834bb10 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1274,7 +1274,7 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
int ret;
uint32_t size;
- uint32_t backup_handle;
+ uint32_t backup_handle = 0;
if (req->multisample_count != 0)
return -EINVAL;
@@ -1317,12 +1317,16 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data,
ret = vmw_user_dmabuf_lookup(tfile, req->buffer_handle,
&res->backup,
&user_srf->backup_base);
- if (ret == 0 && res->backup->base.num_pages * PAGE_SIZE <
- res->backup_size) {
- DRM_ERROR("Surface backup buffer is too small.\n");
- vmw_dmabuf_unreference(&res->backup);
- ret = -EINVAL;
- goto out_unlock;
+ if (ret == 0) {
+ if (res->backup->base.num_pages * PAGE_SIZE <
+ res->backup_size) {
+ DRM_ERROR("Surface backup buffer is too small.\n");
+ vmw_dmabuf_unreference(&res->backup);
+ ret = -EINVAL;
+ goto out_unlock;
+ } else {
+ backup_handle = req->buffer_handle;
+ }
}
} else if (req->drm_surface_flags & drm_vmw_surface_flag_create_buffer)
ret = vmw_user_dmabuf_alloc(dev_priv, tfile,
--
2.7.4
next prev parent reply other threads:[~2017-06-07 13:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 13:24 [PATCH -fixes 1/9] drm/vmwgfx: limit the number of mip levels in vmw_gb_surface_define_ioctl() Thomas Hellstrom
2017-06-07 13:24 ` [PATCH -fixes 2/9] drm/vmwgfx: Don't create proxy surface for cursor Thomas Hellstrom
2017-06-07 13:24 ` [PATCH -fixes 3/9] drm/vmwgfx: Handle vmalloc() failure in vmw_local_fifo_reserve() Thomas Hellstrom
2017-06-07 13:24 ` Thomas Hellstrom [this message]
2017-06-07 13:24 ` [PATCH -fixes 5/9] drm/vmwgfx: Make sure to update STDU when FB is updated Thomas Hellstrom
2017-06-07 13:24 ` [PATCH -fixes 6/9] drm/vmwgfx: Fix large topology crash Thomas Hellstrom
2017-06-07 13:24 ` [PATCH -fixes 7/9] drm/vmwgfx: fix spelling mistake "exeeds" -> "exceeds" Thomas Hellstrom
2017-06-07 13:24 ` [PATCH -fixes 8/9] drm/vmwgfx: Remove unused legacy cursor functions Thomas Hellstrom
2017-06-07 13:24 ` [PATCH -fixes 9/9] drm/vmwgfx: Bump driver minor and date Thomas Hellstrom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496841865-2349-4-git-send-email-thellstrom@vmware.com \
--to=thellstrom@vmware.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=stable@vger.kernel.org \
--cc=syeh@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.