bpf: Fix use of sk->sk_reuseport from sk_assign

[ upstream commit 8e368dc72e86ad1e1a612416f32d5ad22dca88bc ]

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.

BUG=b/171890773
TEST=compile
SOURCE=UPSTREAM(8e368dc72e86ad1e1a612416f32d5ad22dca88bc)

Fixes: cf7fbe660f2d ("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
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Change-Id: I998046c3688bc8a7bc61e1b8fc620881bba052ad
Reviewed-on: https://cos-review.googlesource.com/c/third_party/kernel/+/8212
Reviewed-by: Roy Yang <royyang@google.com>
Tested-by: Roy Yang <royyang@google.com>
1 file changed