Netdev List
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Jeremy Cline <jcline@redhat.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 1/2] net: socket: fix potential spectre v1 gadget in socketcall
Date: Sun, 29 Jul 2018 08:59:20 -0500	[thread overview]
Message-ID: <20180729135920.a2zo6de4f7chszgd@treble> (raw)
In-Reply-To: <20180727224302.5503-2-jcline@redhat.com>

On Fri, Jul 27, 2018 at 10:43:01PM +0000, Jeremy Cline wrote:
> 'call' is a user-controlled value, so sanitize the array index after the
> bounds check to avoid speculating past the bounds of the 'nargs' array.
> 
> Found with the help of Smatch:
> 
> net/socket.c:2508 __do_sys_socketcall() warn: potential spectre issue
> 'nargs' [r] (local cap)
> 
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Jeremy Cline <jcline@redhat.com>
> ---
>  net/socket.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/socket.c b/net/socket.c
> index 3015ddace71e..f15d5cbb3ba4 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -89,6 +89,7 @@
>  #include <linux/magic.h>
>  #include <linux/slab.h>
>  #include <linux/xattr.h>
> +#include <linux/nospec.h>
>  
>  #include <linux/uaccess.h>
>  #include <asm/unistd.h>
> @@ -2504,6 +2505,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
>  
>  	if (call < 1 || call > SYS_SENDMMSG)
>  		return -EINVAL;
> +	call = array_index_nospec(call, SYS_SENDMMSG + 1);
>  
>  	len = nargs[call];
>  	if (len > sizeof(a))

Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>

-- 
Josh

  reply	other threads:[~2018-07-29 15:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 22:43 [PATCH 0/2] net: socket: Fix potential spectre v1 gadgets Jeremy Cline
2018-07-27 22:43 ` [PATCH 1/2] net: socket: fix potential spectre v1 gadget in socketcall Jeremy Cline
2018-07-29 13:59   ` Josh Poimboeuf [this message]
2018-07-27 22:43 ` [PATCH 2/2] net: socket: Fix potential spectre v1 gadget in sock_is_registered Jeremy Cline
2018-07-29 13:59   ` Josh Poimboeuf
2018-07-29 15:59     ` Jeremy Cline
2018-08-13 17:16       ` Josh Poimboeuf
2018-08-13 19:03         ` Jeremy Cline
2018-07-29  5:45 ` [PATCH 0/2] net: socket: Fix potential spectre v1 gadgets David Miller

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=20180729135920.a2zo6de4f7chszgd@treble \
    --to=jpoimboe@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jcline@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.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