* [PATCH] netlink: Fix spectre v1 gadget in netlink_create()
@ 2018-07-31 21:13 Jeremy Cline
2018-07-31 21:23 ` Josh Poimboeuf
2018-08-01 16:51 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Jeremy Cline @ 2018-07-31 21:13 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, linux-kernel, Jeremy Cline, Josh Poimboeuf
'protocol' is a user-controlled value, so sanitize it after the bounds
check to avoid using it for speculative out-of-bounds access to arrays
indexed by it.
This addresses the following accesses detected with the help of smatch:
* net/netlink/af_netlink.c:654 __netlink_create() warn: potential
spectre issue 'nlk_cb_mutex_keys' [w]
* net/netlink/af_netlink.c:654 __netlink_create() warn: potential
spectre issue 'nlk_cb_mutex_key_strings' [w]
* net/netlink/af_netlink.c:685 netlink_create() warn: potential spectre
issue 'nl_table' [w] (local cap)
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Jeremy Cline <jcline@redhat.com>
---
net/netlink/af_netlink.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 393573a99a5a..59dac45ad452 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -63,6 +63,7 @@
#include <linux/hash.h>
#include <linux/genetlink.h>
#include <linux/net_namespace.h>
+#include <linux/nospec.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>
@@ -679,6 +680,7 @@ static int netlink_create(struct net *net, struct socket *sock, int protocol,
if (protocol < 0 || protocol >= MAX_LINKS)
return -EPROTONOSUPPORT;
+ protocol = array_index_nospec(protocol, MAX_LINKS);
netlink_lock_table();
#ifdef CONFIG_MODULES
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] netlink: Fix spectre v1 gadget in netlink_create()
2018-07-31 21:13 [PATCH] netlink: Fix spectre v1 gadget in netlink_create() Jeremy Cline
@ 2018-07-31 21:23 ` Josh Poimboeuf
2018-08-01 16:51 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Josh Poimboeuf @ 2018-07-31 21:23 UTC (permalink / raw)
To: Jeremy Cline; +Cc: David S . Miller, netdev, linux-kernel
On Tue, Jul 31, 2018 at 09:13:16PM +0000, Jeremy Cline wrote:
> 'protocol' is a user-controlled value, so sanitize it after the bounds
> check to avoid using it for speculative out-of-bounds access to arrays
> indexed by it.
>
> This addresses the following accesses detected with the help of smatch:
>
> * net/netlink/af_netlink.c:654 __netlink_create() warn: potential
> spectre issue 'nlk_cb_mutex_keys' [w]
>
> * net/netlink/af_netlink.c:654 __netlink_create() warn: potential
> spectre issue 'nlk_cb_mutex_key_strings' [w]
>
> * net/netlink/af_netlink.c:685 netlink_create() warn: potential spectre
> issue 'nl_table' [w] (local cap)
>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Signed-off-by: Jeremy Cline <jcline@redhat.com>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
--
Josh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] netlink: Fix spectre v1 gadget in netlink_create()
2018-07-31 21:13 [PATCH] netlink: Fix spectre v1 gadget in netlink_create() Jeremy Cline
2018-07-31 21:23 ` Josh Poimboeuf
@ 2018-08-01 16:51 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-08-01 16:51 UTC (permalink / raw)
To: jcline; +Cc: netdev, linux-kernel, jpoimboe
From: Jeremy Cline <jcline@redhat.com>
Date: Tue, 31 Jul 2018 21:13:16 +0000
> 'protocol' is a user-controlled value, so sanitize it after the bounds
> check to avoid using it for speculative out-of-bounds access to arrays
> indexed by it.
>
> This addresses the following accesses detected with the help of smatch:
>
> * net/netlink/af_netlink.c:654 __netlink_create() warn: potential
> spectre issue 'nlk_cb_mutex_keys' [w]
>
> * net/netlink/af_netlink.c:654 __netlink_create() warn: potential
> spectre issue 'nlk_cb_mutex_key_strings' [w]
>
> * net/netlink/af_netlink.c:685 netlink_create() warn: potential spectre
> issue 'nl_table' [w] (local cap)
>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Signed-off-by: Jeremy Cline <jcline@redhat.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-01 19:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-31 21:13 [PATCH] netlink: Fix spectre v1 gadget in netlink_create() Jeremy Cline
2018-07-31 21:23 ` Josh Poimboeuf
2018-08-01 16:51 ` David Miller
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).