Skip to content

Commit f66019a

Browse files
committed
DO-NOT-MERGE: mptcp: improve code coverage for CI
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] net: debug patch for WARNING in skb_try_coalesce Patch from Paolo Abeni. See ticket 572 on GH. Signed-off-by: Matthieu Baerts <[email protected]>
1 parent 1d43ee1 commit f66019a

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

net/core/skbuff.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6125,7 +6125,10 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
61256125
delta = from->truesize - SKB_TRUESIZE(skb_end_offset(from));
61266126
}
61276127

6128-
WARN_ON_ONCE(delta < len);
6128+
if (WARN_ON_ONCE(delta < len))
6129+
pr_err("skb len %d delta %d truesize %d headlen %d end %d\n",
6130+
len, delta, from->truesize, skb_headlen(from),
6131+
skb_end_offset(from));
61296132

61306133
memcpy(to_shinfo->frags + to_shinfo->nr_frags,
61316134
from_shinfo->frags,

net/ipv4/tcp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4946,6 +4946,8 @@ void tcp_done(struct sock *sk)
49464946
*/
49474947
req = rcu_dereference_protected(tcp_sk(sk)->fastopen_rsk, 1);
49484948

4949+
WARN_ON_ONCE(sk->sk_state == TCP_CLOSE);
4950+
49494951
if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)
49504952
TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
49514953

net/mptcp/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@ config MPTCP_KUNIT_TEST
3636

3737
If unsure, say N.
3838

39+
config GCOV_PROFILE_MPTCP
40+
bool "Enable GCOV profiling on MPTCP"
41+
depends on GCOV_KERNEL
42+
help
43+
Enable GCOV profiling on MPTCP for checking which functions/lines
44+
are executed.
45+
46+
If unsure, say N.
47+
3948
endif

net/mptcp/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ mptcp_token_test-objs := token_test.o
1313
obj-$(CONFIG_MPTCP_KUNIT_TEST) += mptcp_crypto_test.o mptcp_token_test.o
1414

1515
obj-$(CONFIG_BPF_SYSCALL) += bpf.o
16+
17+
# for GCOV coverage profiling
18+
ifdef CONFIG_GCOV_PROFILE_MPTCP
19+
GCOV_PROFILE := y
20+
endif

net/mptcp/options.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
989989
WRITE_ONCE(msk->pm.remote_deny_join_id0, true);
990990

991991
if (unlikely(!READ_ONCE(msk->pm.server_side)))
992-
pr_warn_once("bogus mpc option on established client sk");
992+
/* DO-NOT-MERGE: use WARN i/o pr_warn: only for MPTCP export */
993+
WARN_ONCE(1, "bogus mpc option on established client sk");
993994

994995
set_fully_established:
995996
mptcp_data_lock((struct sock *)msk);

0 commit comments

Comments
 (0)