* [PATCH bpf] bpf: Fix use of sk->sk_reuseport from sk_assign
@ 2020-04-08 3:35 Joe Stringer
2020-04-08 18:12 ` Martin KaFai Lau
2020-04-08 23:14 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Joe Stringer @ 2020-04-08 3:35 UTC (permalink / raw)
To: bpf; +Cc: netdev, daniel, ast
In testing, we found that for request sockets the sk->sk_reuseport field
may yet be uninitialized, which caused bpf_sk_assign() to randomly
succeed or return -ESOCKTNOSUPPORT when handling the forward ACK in a
three-way handshake.
Fix it by only applying the reuseport check for full sockets.
Fixes: cf7fbe660f2d ("bpf: Add socket assign support")
Signed-off-by: Joe Stringer <joe@wand.net.nz>
---
net/core/filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 7628b947dbc3..7d6ceaa54d21 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5925,7 +5925,7 @@ BPF_CALL_3(bpf_sk_assign, struct sk_buff *, skb, struct sock *, sk, u64, flags)
return -EOPNOTSUPP;
if (unlikely(dev_net(skb->dev) != sock_net(sk)))
return -ENETUNREACH;
- if (unlikely(sk->sk_reuseport))
+ if (unlikely(sk_fullsock(sk) && sk->sk_reuseport))
return -ESOCKTNOSUPPORT;
if (sk_is_refcounted(sk) &&
unlikely(!refcount_inc_not_zero(&sk->sk_refcnt)))
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: Fix use of sk->sk_reuseport from sk_assign
2020-04-08 3:35 [PATCH bpf] bpf: Fix use of sk->sk_reuseport from sk_assign Joe Stringer
@ 2020-04-08 18:12 ` Martin KaFai Lau
2020-04-08 23:14 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Martin KaFai Lau @ 2020-04-08 18:12 UTC (permalink / raw)
Cc: bpf, netdev, daniel, ast
On Tue, Apr 07, 2020 at 08:35:40PM -0700, Joe Stringer wrote:
> In testing, we found that for request sockets the sk->sk_reuseport field
> may yet be uninitialized, which caused bpf_sk_assign() to randomly
> succeed or return -ESOCKTNOSUPPORT when handling the forward ACK in a
> three-way handshake.
>
> Fix it by only applying the reuseport check for full sockets.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: Fix use of sk->sk_reuseport from sk_assign
2020-04-08 3:35 [PATCH bpf] bpf: Fix use of sk->sk_reuseport from sk_assign Joe Stringer
2020-04-08 18:12 ` Martin KaFai Lau
@ 2020-04-08 23:14 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-04-08 23:14 UTC (permalink / raw)
To: Joe Stringer, bpf; +Cc: netdev, ast
On 4/8/20 5:35 AM, Joe Stringer wrote:
> In testing, we found that for request sockets the sk->sk_reuseport field
> may yet be uninitialized, which caused bpf_sk_assign() to randomly
> succeed or return -ESOCKTNOSUPPORT when handling the forward ACK in a
> three-way handshake.
>
> Fix it by only applying the reuseport check for full sockets.
>
> Fixes: cf7fbe660f2d ("bpf: Add socket assign support")
> Signed-off-by: Joe Stringer <joe@wand.net.nz>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-08 23:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 3:35 [PATCH bpf] bpf: Fix use of sk->sk_reuseport from sk_assign Joe Stringer
2020-04-08 18:12 ` Martin KaFai Lau
2020-04-08 23:14 ` Daniel Borkmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.