Skip to content

Commit 8e368dc

Browse files
joestringerborkmann
authored andcommitted
bpf: Fix use of sk->sk_reuseport from sk_assign
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: cf7fbe6 ("bpf: Add socket assign support") Signed-off-by: Joe Stringer <joe@wand.net.nz> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/bpf/20200408033540.10339-1-joe@wand.net.nz
1 parent eb203f4 commit 8e368dc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5925,7 +5925,7 @@ BPF_CALL_3(bpf_sk_assign, struct sk_buff *, skb, struct sock *, sk, u64, flags)
59255925
return -EOPNOTSUPP;
59265926
if (unlikely(dev_net(skb->dev) != sock_net(sk)))
59275927
return -ENETUNREACH;
5928-
if (unlikely(sk->sk_reuseport))
5928+
if (unlikely(sk_fullsock(sk) && sk->sk_reuseport))
59295929
return -ESOCKTNOSUPPORT;
59305930
if (sk_is_refcounted(sk) &&
59315931
unlikely(!refcount_inc_not_zero(&sk->sk_refcnt)))

0 commit comments

Comments
 (0)