From: Jeremy Cline <jcline@redhat.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jeremy Cline <jcline@redhat.com>,
stable@vger.kernel.org
Subject: [PATCH 2/2] net: socket: Fix potential spectre v1 gadget in sock_is_registered
Date: Fri, 27 Jul 2018 22:43:02 +0000 [thread overview]
Message-ID: <20180727224302.5503-3-jcline@redhat.com> (raw)
In-Reply-To: <20180727224302.5503-1-jcline@redhat.com>
'family' can be a user-controlled value, so sanitize it after the bounds
check to avoid speculative out-of-bounds access.
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jeremy Cline <jcline@redhat.com>
---
net/socket.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/socket.c b/net/socket.c
index f15d5cbb3ba4..608e29ae6baf 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2672,7 +2672,8 @@ EXPORT_SYMBOL(sock_unregister);
bool sock_is_registered(int family)
{
- return family < NPROTO && rcu_access_pointer(net_families[family]);
+ return family < NPROTO &&
+ rcu_access_pointer(net_families[array_index_nospec(family, NPROTO)]);
}
static int __init sock_init(void)
--
2.17.1
next prev parent reply other threads:[~2018-07-27 22:43 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
2018-07-27 22:43 ` Jeremy Cline [this message]
2018-07-29 13:59 ` [PATCH 2/2] net: socket: Fix potential spectre v1 gadget in sock_is_registered 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=20180727224302.5503-3-jcline@redhat.com \
--to=jcline@redhat.com \
--cc=davem@davemloft.net \
--cc=jpoimboe@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;
as well as URLs for NNTP newsgroup(s).