From b97dc65f29efa9719f95ad2797c680550e891c8f Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Mon, 15 Jan 2024 15:16:03 +0100 Subject: [PATCH] DO-NOT-MERGE: mptcp: improve code coverage for CI mptcp: use kmalloc on kasan build Helps detection UaF, which apparently kasan misses with kmem_cache allocator. We also need to always set the SOCK_RCU_FREE flag, to preserved the current code leveraging SLAB_TYPESAFE_BY_RCU. This latter change will make unreachable some existing errors path, but I don't see other options. tcp: warn if tcp_done() is called on a closed socket This is an extra check mainly for the CIs: to make sure we don't call tcp_done() on an already closed socket as it happened in the past. If we do such call, better to catch the error earlier. Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Signed-off-by: Paolo Abeni --- net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1baa484d21902..2b68c13831615 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4484,6 +4484,8 @@ void tcp_done(struct sock *sk) */ req = rcu_dereference_protected(tcp_sk(sk)->fastopen_rsk, 1); + WARN_ON_ONCE(sk->sk_state == TCP_CLOSE); + if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV) TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);