Lorenz Bauer 8897562f67 net: Fix slab-out-of-bounds in inet[6]_steal_sock
Kumar reported a KASAN splat in tcp_v6_rcv:

  bash-5.2# ./test_progs -t btf_skc_cls_ingress
  ...
  [   51.810085] BUG: KASAN: slab-out-of-bounds in tcp_v6_rcv+0x2d7d/0x3440
  [   51.810458] Read of size 2 at addr ffff8881053f038c by task test_progs/226

The problem is that inet[6]_steal_sock accesses sk->sk_protocol without
accounting for request or timewait sockets. To fix this we can't just
check sock_common->skc_reuseport since that flag is present on timewait
sockets.

Instead, add a fullsock check to avoid the out of bands access of sk_protocol.

Fixes: 9c02bec95954 ("bpf, net: Support SO_REUSEPORT sockets with bpf_sk_assign")
Reported-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/r/20230815-bpf-next-v2-1-95126eaa4c1b@isovalent.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
2023-08-15 13:57:51 -07:00
..
2023-03-17 08:56:37 +00:00
2022-08-09 22:14:02 -07:00
2021-12-16 07:18:35 -08:00
2021-10-15 11:33:08 +01:00
2023-04-22 01:39:41 +02:00
2021-10-13 09:40:46 -07:00
2022-05-11 12:43:10 +01:00
2023-05-11 18:07:05 -07:00
2023-07-14 20:39:30 -07:00
2023-02-16 09:27:07 +01:00
2023-07-31 14:33:55 -07:00
2023-07-28 14:07:59 -07:00
2022-12-12 15:04:39 -08:00
2023-08-02 10:58:26 +01:00
2023-07-19 09:56:49 -07:00
2023-07-19 09:56:49 -07:00