From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Thomas Hellstrom <thellstrom@vmware.com>,
Deepak Singh Rawat <drawat@vmware.com>,
linux-graphics-maintainer <linux-graphics-maintainer@vmware.com>,
Sinclair Yeh <syeh@vmware.com>, David Airlie <airlied@linux.ie>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Subject: Re: [Linux-graphics-maintainer] [PATCH] drm/vmwgfx: Fix potential Spectre v1
Date: Thu, 23 Aug 2018 09:43:33 -0500 [thread overview]
Message-ID: <0d9c46fd-40a0-4d9b-bd9a-9e0f36da763d@embeddedor.com> (raw)
In-Reply-To: <68b1a4bc-87d8-a93a-edd1-5794ca9e93f6@vmware.com>
Hi all,
On 8/21/18 3:19 AM, Thomas Hellstrom wrote:
>>> #include "vmwgfx_drv.h"
>>> #include "vmwgfx_reg.h"
>>> @@ -4520,8 +4521,10 @@ int vmw_execbuf_ioctl(struct drm_device *dev,
>>> unsigned long data,
>>> return -EINVAL;
>>> }
>>>
>>> - if (arg.version > 1 &&
>>> - copy_from_user(&arg.context_handle,
>>> + if (arg.version >= ARRAY_SIZE(copy_offset))
>>> + return -EFAULT;
>
> I must admit my understanding of spectre workings in this case is limited, but why do you need to compare
> arg.version against ARRAY_SIZE here, when it is already checked against DRM_VMW_EXECBUF_VERSION earlier?
>
Oh, I wasn't aware of the value in DRM_VMW_EXECBUF_VERSION. But as arg.version is used to index copy_offset,
it is safer to compare its value against the actual size of copy_offset.
So, what do you think if I replace DRM_VMW_EXECBUF_VERSION with ARRAY_SIZE instead of adding a new check
against ARRAY_SIZE?
Something like:
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 1f13457..3ef9f7b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -25,6 +25,7 @@
*
**************************************************************************/
#include <linux/sync_file.h>
+#include <linux/nospec.h>
#include "vmwgfx_drv.h"
#include "vmwgfx_reg.h"
@@ -4514,11 +4515,12 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data,
* arg.version.
*/
- if (unlikely(arg.version > DRM_VMW_EXECBUF_VERSION ||
+ if (unlikely(arg.version > ARRAY_SIZE(copy_offset) ||
arg.version == 0)) {
DRM_ERROR("Incorrect execbuf version.\n");
return -EINVAL;
}
+ arg.version = array_index_nospec(arg.version, ARRAY_SIZE(copy_offset));
if (arg.version > 1 &&
copy_from_user(&arg.context_handle,
>
>
>>> + arg.version = array_index_nospec(arg.version,
>>> ARRAY_SIZE(copy_offset));
>>> + if (copy_from_user(&arg.context_handle,
>>> (void __user *) (data + copy_offset[0]),
>>> copy_offset[arg.version - 1] -
>>> copy_offset[0]) != 0)
>
> Similarly, we want to perform this copy iff arg.version > 1. Why did you remove that check?
>
Yeah, this check must remain in place. I will add it back and send v2.
Thanks for the feedback!
--
Gustavo
prev parent reply other threads:[~2018-08-23 14:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-16 19:30 Gustavo A. R. Silva
2018-08-20 20:53 ` [Linux-graphics-maintainer] " Deepak Singh Rawat
2018-08-21 8:19 ` Thomas Hellstrom
2018-08-23 14:43 ` Gustavo A. R. Silva [this message]
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=0d9c46fd-40a0-4d9b-bd9a-9e0f36da763d@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=airlied@linux.ie \
--cc=drawat@vmware.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-graphics-maintainer@vmware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syeh@vmware.com \
--cc=thellstrom@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®