From 596d46cda065112444c7208c4b3d987aa060f030 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Tue, 27 Aug 2024 05:50:43 +0000 Subject: [PATCH] DO-NOT-MERGE: mptcp: improve code coverage for CI (net) (only for -net) 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. mptcp: warn in case of bogus mpc option on established client sk As discussed on [1], an additional check is done to catch local software bug. This patch is supposed to land only in our tree, for both 'export' and 'export-net' branches, because the warning could be triggered by bugged / malicious peer. We want it in our tree for our CI to detect internal bugs. Link: https://lore.kernel.org/all/20240215-mptcp-fix-bogus-pr-warn-v1-1-d14c10312820@kernel.org/ [1] Signed-off-by: Matthieu Baerts --- net/ipv4/tcp.c | 2 ++ net/mptcp/options.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index e03a342c9162b..e7399816c3c74 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4593,6 +4593,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); diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 370c3836b7712..66eab2cdb702d 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -983,7 +983,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, WRITE_ONCE(msk->pm.remote_deny_join_id0, true); if (unlikely(!READ_ONCE(msk->pm.server_side))) - pr_warn_once("bogus mpc option on established client sk"); + /* DO-NOT-MERGE: use WARN i/o pr_warn: only for MPTCP export */ + WARN_ONCE(1, "bogus mpc option on established client sk"); set_fully_established: mptcp_data_lock((struct sock *)msk);