Skip to content

Commit 6338857

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 aec735c commit 6338857

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
@@ -6172,7 +6172,10 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
61726172
delta = from->truesize - SKB_TRUESIZE(skb_end_offset(from));
61736173
}
61746174

6175-
WARN_ON_ONCE(delta < len);
6175+
if (WARN_ON_ONCE(delta < len))
6176+
pr_err("skb len %d delta %d truesize %d headlen %d end %d\n",
6177+
len, delta, from->truesize, skb_headlen(from),
6178+
skb_end_offset(from));
61766179

61776180
memcpy(to_shinfo->frags + to_shinfo->nr_frags,
61786181
from_shinfo->frags,

net/ipv4/tcp.c

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

5001+
WARN_ON_ONCE(sk->sk_state == TCP_CLOSE);
5002+
50015003
if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)
50025004
TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);
50035005

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
@@ -999,7 +999,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
999999
}
10001000

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

10041005
set_fully_established:
10051006
if (mp_opt->deny_join_id0)

0 commit comments

Comments
 (0)