Skip to content

Commit

Permalink
DO-NOT-MERGE: mptcp: improve code coverage for CI
Browse files Browse the repository at this point in the history
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/[email protected]/ [1]

Signed-off-by: Matthieu Baerts <[email protected]>
  • Loading branch information
matttbe committed Sep 27, 2024
1 parent 454faf9 commit 9e8cb11
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4854,6 +4854,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
9 changes: 9 additions & 0 deletions net/mptcp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ config MPTCP_KUNIT_TEST

If unsure, say N.

config GCOV_PROFILE_MPTCP
bool "Enable GCOV profiling on MPTCP"
depends on GCOV_KERNEL
help
Enable GCOV profiling on MPTCP for checking which functions/lines
are executed.

If unsure, say N.

endif
5 changes: 5 additions & 0 deletions net/mptcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ mptcp_token_test-objs := token_test.o
obj-$(CONFIG_MPTCP_KUNIT_TEST) += mptcp_crypto_test.o mptcp_token_test.o

obj-$(CONFIG_BPF_SYSCALL) += bpf.o

# for GCOV coverage profiling
ifdef CONFIG_GCOV_PROFILE_MPTCP
GCOV_PROFILE := y
endif
3 changes: 2 additions & 1 deletion net/mptcp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9e8cb11

Please sign in to comment.