Skip to content

Commit

Permalink
DO-NOT-MERGE: mptcp: improve code coverage for CI (net)
Browse files Browse the repository at this point in the history
(only for -net)

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 <[email protected]>
Signed-off-by: Matthieu Baerts <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
Paolo Abeni authored and matttbe committed Jun 3, 2023
1 parent 677352e commit 4cf8ae5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4641,6 +4641,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);

Expand Down

0 comments on commit 4cf8ae5

Please sign in to comment.