From: John Stultz <john.stultz@linaro.org>
To: Jordy Zomer <jordy@pwning.systems>
Cc: "Christian König" <christian.koenig@amd.com>,
linux-kernel@vger.kernel.org, "Liam Mark" <lmark@codeaurora.org>,
linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org,
"Benjamin Gaignard" <benjamin.gaignard@linaro.org>,
"Laura Abbott" <labbott@redhat.com>,
linux-media@vger.kernel.org
Subject: Re: [PATCH] dma-buf: heaps: Fix potential spectre v1 gadget
Date: Mon, 31 Jan 2022 12:39:29 -0800 [thread overview]
Message-ID: <CALAqxLU58UYLRNrf4C7t4_SmSa1aUVaDj4SP=zCPfb9m6HBUNw@mail.gmail.com> (raw)
In-Reply-To: <20220129150604.3461652-1-jordy@pwning.systems>
On Sat, Jan 29, 2022 at 7:06 AM Jordy Zomer <jordy@pwning.systems> wrote:
>
> It appears like nr could be a Spectre v1 gadget as it's supplied by a
> user and used as an array index. Prevent the contents
> of kernel memory from being leaked to userspace via speculative
> execution by using array_index_nospec.
>
> Signed-off-by: Jordy Zomer <jordy@pwning.systems>
> ---
> drivers/dma-buf/dma-heap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
> index 56bf5ad01ad5..8f5848aa144f 100644
> --- a/drivers/dma-buf/dma-heap.c
> +++ b/drivers/dma-buf/dma-heap.c
> @@ -14,6 +14,7 @@
> #include <linux/xarray.h>
> #include <linux/list.h>
> #include <linux/slab.h>
> +#include <linux/nospec.h>
> #include <linux/uaccess.h>
> #include <linux/syscalls.h>
> #include <linux/dma-heap.h>
> @@ -135,6 +136,7 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
> if (nr >= ARRAY_SIZE(dma_heap_ioctl_cmds))
> return -EINVAL;
>
> + nr = array_index_nospec(nr, ARRAY_SIZE(dma_heap_ioctl_cmds));
> /* Get the kernel ioctl cmd that matches */
> kcmd = dma_heap_ioctl_cmds[nr];
Thanks for submitting this! It looks sane to me.
Acked-by: John Stultz <john.stultz@linaro.org>
thanks
-john
next prev parent reply other threads:[~2022-01-31 20:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 15:06 [PATCH] dma-buf: heaps: Fix potential spectre v1 gadget Jordy Zomer
2022-01-31 20:39 ` John Stultz [this message]
2022-02-01 8:05 ` Sumit Semwal
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='CALAqxLU58UYLRNrf4C7t4_SmSa1aUVaDj4SP=zCPfb9m6HBUNw@mail.gmail.com' \
--to=john.stultz@linaro.org \
--cc=benjamin.gaignard@linaro.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jordy@pwning.systems \
--cc=labbott@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lmark@codeaurora.org \
/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;
as well as URLs for NNTP newsgroup(s).