* [PATCH net-next 06/11] selftests: mptcp: check per-event MPTCP_RST_EMPTCP counters
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
@ 2026-08-12 14:55 ` Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 07/11] selftests: mptcp: connect: test name in pcap file Matthieu Baerts (NGI0)
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-08-12 14:55 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0),
Shardul Bankar, Shuah Khan, linux-kselftest
From: Shardul Bankar <shardul.b@mpiricsoftware.com>
Add named env-var expectations for each per-event MPTCP_RST_EMPTCP
counter, matching the pattern used by the existing JOIN/RST checks.
Each defaults to 0 and is checked silently on success; a mismatch prints
a check line and fails the test. Counters absent from the running
kernel are skipped silently so older kernels do not false-fail.
The JOIN-related counters (MPJoinSynAckNoMPJoin, MPJoinAckNoMPJoin,
MPJoinAckNoCtx, MPJoinNotEstablished, MPJoinNoIdFound) are checked in
chk_join_nr() on fixed namespaces; the two remaining reset counters
(MD5SigReset, DssReset) stay in chk_rst_nr().
Add a test at the end of signal_address_tests that triggers
MPJoinSynAckNoMPJoin: ns1 signals an address that is already bound on
the client (ns2), where a TCP-only mptcp_connect listener is started.
The client's MP_JOIN routes locally to the TCP listener, which responds
with a plain SYN/ACK without the MP_JOIN option, and the new counter
increments on the client side.
Other per-event counters (MD5SigReset, MPJoinAckNoMPJoin, MPJoinAckNoCtx,
DssReset, MPJoinNotEstablished, MPJoinNoIdFound) are not currently
reachable from mptcp_join.sh; the env-var hooks are in place for future
tests to set expectations explicitly.
Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Shardul Bankar <shardul.b@mpiricsoftware.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 93 +++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 7dc91fac4917..9b9fb3de9da3 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -75,6 +75,14 @@ unset join_syn_tx
unset join_create_err
unset join_bind_err
unset join_connect_err
+unset join_synack_no_mpjoin
+unset join_ack_no_mpjoin
+unset join_ack_no_ctx
+unset join_not_established
+unset join_no_id_found
+
+unset rst_md5sig
+unset rst_dss
unset fb_ns1
unset fb_ns2
@@ -1353,6 +1361,8 @@ chk_rst_nr()
local rst_tx=$1
local rst_rx=$2
local ns_invert=${3:-""}
+ local md5sig=${rst_md5sig:-0}
+ local dss=${rst_dss:-0}
local count
local ns_tx=$ns1
local ns_rx=$ns2
@@ -1389,6 +1399,21 @@ chk_rst_nr()
else
print_ok
fi
+
+ # MPTCP_RST_EMPTCP reset-event counters; default 0, gated on
+ # availability. Fixed namespaces: MD5SigReset fires on the listener
+ # (server), DssReset on the data receiver (client).
+ count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMD5SigReset")
+ if [ -n "$count" ] && [ "$count" != "$md5sig" ]; then
+ print_check "MD5SigReset"
+ fail_test "got $count MD5SigReset expected $md5sig"
+ fi
+
+ count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDssReset")
+ if [ -n "$count" ] && [ "$count" != "$dss" ]; then
+ print_check "DssReset"
+ fail_test "got $count DssReset expected $dss"
+ fi
}
chk_infi_nr()
@@ -1587,6 +1612,11 @@ chk_join_nr()
local rst_nr=${join_rst_nr:-0}
local infi_nr=${join_infi_nr:-0}
local corrupted_pkts=${join_corrupted_pkts:-0}
+ local synack_no_mpjoin=${join_synack_no_mpjoin:-0}
+ local ack_no_mpjoin=${join_ack_no_mpjoin:-0}
+ local ack_no_ctx=${join_ack_no_ctx:-0}
+ local not_established=${join_not_established:-0}
+ local no_id_found=${join_no_id_found:-0}
local rc=${KSFT_PASS}
local count
local with_cookie
@@ -1655,6 +1685,44 @@ chk_join_nr()
fail_test "got $count JOIN[s] syn rejected expected $syn_rej"
fi
+ # Per-event MPTCP_RST_EMPTCP JOIN counters; default 0, gated on
+ # availability. Fixed namespaces: the *SynAck* one fires on the
+ # client receiving the SYN/ACK, the others on the server.
+ count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinSynAckNoMPJoin")
+ if [ -n "$count" ] && [ "$count" != "$synack_no_mpjoin" ]; then
+ rc=${KSFT_FAIL}
+ print_check "synack no mpjoin"
+ fail_test "got $count JOIN[s] synack no mpjoin expected $synack_no_mpjoin"
+ fi
+
+ count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinAckNoMPJoin")
+ if [ -n "$count" ] && [ "$count" != "$ack_no_mpjoin" ]; then
+ rc=${KSFT_FAIL}
+ print_check "ack no mpjoin"
+ fail_test "got $count JOIN[s] ack no mpjoin expected $ack_no_mpjoin"
+ fi
+
+ count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinAckNoCtx")
+ if [ -n "$count" ] && [ "$count" != "$ack_no_ctx" ]; then
+ rc=${KSFT_FAIL}
+ print_check "ack no ctx"
+ fail_test "got $count JOIN[s] ack no ctx expected $ack_no_ctx"
+ fi
+
+ count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinNotEstablished")
+ if [ -n "$count" ] && [ "$count" != "$not_established" ]; then
+ rc=${KSFT_FAIL}
+ print_check "join not established"
+ fail_test "got $count JOIN[s] not established expected $not_established"
+ fi
+
+ count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinNoIdFound")
+ if [ -n "$count" ] && [ "$count" != "$no_id_found" ]; then
+ rc=${KSFT_FAIL}
+ print_check "join no id found"
+ fail_test "got $count JOIN[s] no id found expected $no_id_found"
+ fi
+
print_results "join Rx" ${rc}
join_syn_tx="${join_syn_tx:-${syn_nr}}" \
@@ -2359,6 +2427,31 @@ signal_address_tests()
chk_add_nr 4 4
fi
fi
+
+ # signalled address belongs to the client, where a TCP-only
+ # listener is bound at it: the client's MP_JOIN routes locally
+ # to the listener and receives a SYN/ACK without MP_JOIN.
+ # MPJoinSynAckNoMPJoin increments on the client side.
+ if reset "signal address, TCP-only listener on client"; then
+ local extra_bind
+ local port
+
+ pm_nl_set_limits $ns1 0 1
+ pm_nl_set_limits $ns2 1 1
+ pm_nl_add_endpoint $ns1 10.0.2.2 flags signal
+
+ port=$(get_port)
+ ip netns exec ${ns2} ./mptcp_connect -l -t -1 -p "$port" \
+ -s TCP 10.0.2.2 &
+ extra_bind=$!
+ mptcp_lib_wait_local_port_listen "$ns2" "$port"
+
+ run_tests $ns1 $ns2 10.0.1.1
+ join_synack_no_mpjoin=1 join_syn_tx=1 \
+ chk_join_nr 0 0 0
+
+ kill ${extra_bind} 2>/dev/null
+ fi
}
laminar_endp_tests()
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 07/11] selftests: mptcp: connect: test name in pcap file
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 06/11] selftests: mptcp: check per-event MPTCP_RST_EMPTCP counters Matthieu Baerts (NGI0)
@ 2026-08-12 14:55 ` Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 08/11] selftests: mptcp: simult_flow: " Matthieu Baerts (NGI0)
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-08-12 14:55 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Shuah Khan,
linux-kselftest
Even if the pcap prefix is printed in the test, it is clearer if this
prefix also include the test name: mptcp_connect.
With this, it is easily possible to find out which pcap was produced by
which test, and easily delete the right ones.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/mptcp/mptcp_connect.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index d158678fa6ab..5befd8584a4d 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -212,8 +212,8 @@ if $checksum; then
fi
if $capture; then
- rndh="${ns1:4}"
- mptcp_lib_pr_info "Packet capture files will have this prefix: ${rndh}-"
+ capprefix="mptcp_connect-${ns1:4}"
+ mptcp_lib_pr_info "pcap will have this prefix: ${capprefix}-"
fi
set_ethtool_flags() {
@@ -372,7 +372,7 @@ do_transfer()
capuser="-Z $SUDO_USER"
fi
- local capfile="${rndh}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
+ local capfile="${capprefix}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
local capopt="-i any -s 65535 -B 32768 ${capuser}"
ip netns exec ${listener_ns} tcpdump ${capopt} \
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 08/11] selftests: mptcp: simult_flow: test name in pcap file
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 06/11] selftests: mptcp: check per-event MPTCP_RST_EMPTCP counters Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 07/11] selftests: mptcp: connect: test name in pcap file Matthieu Baerts (NGI0)
@ 2026-08-12 14:55 ` Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 09/11] selftests: mptcp: pcap: drop most of the payload Matthieu Baerts (NGI0)
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-08-12 14:55 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Shuah Khan,
linux-kselftest
To be able to easily find out which pcap was produced by which test, the
selftest name is now added to the pcap file, similar to the other tests.
While at it, print the prefix name to be able to find which capture
files have been produced by which test after several runs. This prefix
was not printed anywhere before.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/mptcp/simult_flows.sh | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 7b9aabe10170..d723261bdc62 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -24,6 +24,7 @@ small=""
sout=""
cout=""
capout=""
+capprefix=""
size=0
usage() {
@@ -70,6 +71,11 @@ setup()
mptcp_lib_ns_init ns1 ns2 ns3
+ if $capture; then
+ capprefix="simult_flows-${ns1:4}"
+ mptcp_lib_pr_info "pcap will have this prefix: ${capprefix}-"
+ fi
+
ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth2 netns "$ns2"
ip link add ns2eth3 netns "$ns2" type veth peer name ns3eth1 netns "$ns3"
@@ -136,14 +142,13 @@ do_transfer()
if $capture; then
local capuser
- local rndh="${ns1:4}"
if [ -z $SUDO_USER ] ; then
capuser=""
else
capuser="-Z $SUDO_USER"
fi
- local capfile="${rndh}-${port}"
+ local capfile="${capprefix}-${port}"
local capopt="-i any -s 65535 -B 32768 ${capuser}"
ip netns exec ${ns3} tcpdump ${capopt} -w "${capfile}-listener.pcap" >> "${capout}" 2>&1 &
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 09/11] selftests: mptcp: pcap: drop most of the payload
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
` (2 preceding siblings ...)
2026-08-12 14:55 ` [PATCH net-next 08/11] selftests: mptcp: simult_flow: " Matthieu Baerts (NGI0)
@ 2026-08-12 14:55 ` Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 10/11] selftests: mptcp: fix const qualifier warnings in strchr usage Matthieu Baerts (NGI0)
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-08-12 14:55 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Shuah Khan,
linux-kselftest
Limit the size of each captured packet to 108B (IPv4 only) or 128B (a
mix of v4 and v6): this should drop most of the payload that is
generally not needed when debugging an issue.
8 bytes are left in this payload, to be able to inspect the beginning,
just in case.
Please also note that generally, this payload is usually mostly filled
with 0, except at the end. This reduces the .pcap sizes, and reduce IO
usage, which helps debugging issues.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/mptcp/mptcp_connect.sh | 2 +-
tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
tools/testing/selftests/net/mptcp/simult_flows.sh | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 5befd8584a4d..7a2a851fa0ad 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -373,7 +373,7 @@ do_transfer()
fi
local capfile="${capprefix}-${connector_ns:0:3}-${listener_ns:0:3}-${cl_proto}-${srv_proto}-${connect_addr}-${port}"
- local capopt="-i any -s 65535 -B 32768 ${capuser}"
+ local capopt="-i any -s 128 -B 32768 ${capuser}"
ip netns exec ${listener_ns} tcpdump ${capopt} \
-w "${capfile}-listener.pcap" >> "${capout}" 2>&1 &
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 9b9fb3de9da3..18ce7136a2b0 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -979,7 +979,7 @@ cond_start_capture()
capfile=$(printf "mp_join-%02u-%s.pcap" "$MPTCP_LIB_TEST_COUNTER" "$ns")
echo "Capturing traffic for test $MPTCP_LIB_TEST_COUNTER into $capfile"
- ip netns exec "$ns" tcpdump -i any -s 65535 -B 32768 $capuser -w "$capfile" > "$capout" 2>&1 &
+ ip netns exec "$ns" tcpdump -i any -s 128 -B 32768 $capuser -w "$capfile" > "$capout" 2>&1 &
cappid=$!
sleep 1
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index d723261bdc62..3ea3d1efe32e 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -149,7 +149,7 @@ do_transfer()
fi
local capfile="${capprefix}-${port}"
- local capopt="-i any -s 65535 -B 32768 ${capuser}"
+ local capopt="-i any -s 108 -B 32768 ${capuser}"
ip netns exec ${ns3} tcpdump ${capopt} -w "${capfile}-listener.pcap" >> "${capout}" 2>&1 &
local cappid_listener=$!
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 10/11] selftests: mptcp: fix const qualifier warnings in strchr usage
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
` (3 preceding siblings ...)
2026-08-12 14:55 ` [PATCH net-next 09/11] selftests: mptcp: pcap: drop most of the payload Matthieu Baerts (NGI0)
@ 2026-08-12 14:55 ` Matthieu Baerts (NGI0)
2026-08-12 14:55 ` [PATCH net-next 11/11] selftests: mptcp: diag: fix stack buffer overflow in get_subflow_info() Matthieu Baerts (NGI0)
2026-08-14 22:21 ` [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-08-12 14:55 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Shuah Khan,
linux-kselftest, Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
In mptcp_connect.c, strchr() returns a pointer to a character within
the input string, which is declared as const char *. Assigning this
return value to a non-const char * discards the const qualifier,
triggering compiler warnings:
make: Entering directory 'tools/testing/selftests/net/mptcp'
CC mptcp_connect
mptcp_connect.c: In function 'parse_cmsg_types':
mptcp_connect.c:1267:22: warning: initialization discards 'const'
qualifier from pointer target type [-Wdiscarded-qualifiers]
1267 | char *next = strchr(type, ',');
| ^~~~~~
mptcp_connect.c: In function 'parse_setsock_options':
mptcp_connect.c:1295:22: warning: initialization discards 'const'
qualifier from pointer target type [-Wdiscarded-qualifiers]
1295 | char *next = strchr(name, ',');
| ^~~~~~
make: Leaving directory 'tools/testing/selftests/net/mptcp'
Fix these warnings by declaring the 'next' variable as const char *,
as it is only used for read-only parsing.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/mptcp/mptcp_connect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index cbe573c4ab3a..ea4cb6c1bd5e 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -1264,7 +1264,7 @@ static void apply_cmsg_types(int fd, const struct cfg_cmsg_types *cmsg)
static void parse_cmsg_types(const char *type)
{
- char *next = strchr(type, ',');
+ const char *next = strchr(type, ',');
unsigned int len = 0;
cfg_cmsg_types.cmsg_enabled = 1;
@@ -1292,7 +1292,7 @@ static void parse_cmsg_types(const char *type)
static void parse_setsock_options(const char *name)
{
- char *next = strchr(name, ',');
+ const char *next = strchr(name, ',');
unsigned int len = 0;
if (next) {
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 11/11] selftests: mptcp: diag: fix stack buffer overflow in get_subflow_info()
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
` (4 preceding siblings ...)
2026-08-12 14:55 ` [PATCH net-next 10/11] selftests: mptcp: fix const qualifier warnings in strchr usage Matthieu Baerts (NGI0)
@ 2026-08-12 14:55 ` Matthieu Baerts (NGI0)
2026-08-14 22:21 ` [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-08-12 14:55 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Matthieu Baerts (NGI0), Jiangshan Yi,
Shuah Khan, linux-kselftest
From: Jiangshan Yi <yijiangshan@kylinos.cn>
get_subflow_info() parses the subflow address string with:
char saddr[64], daddr[64];
ret = sscanf(subflow_addrs, "%[^:]:%d %[^:]:%d",
saddr, &sport, daddr, &dport);
The subflow_addrs buffer holds up to 1024 bytes and is taken directly
from the command line ("-c" argument). The "%[^:]" conversions have no
maximum field width, so if the address substring before the ':' exceeds
63 bytes, sscanf() writes past the end of the 64-byte saddr/daddr stack
buffers. This overflows the stack, corrupting adjacent stack data such
as the saved return address, and can crash the tool or lead to
out-of-bounds writes controlled by user-supplied input.
Bound both string conversions to the destination buffer size by adding
an explicit maximum field width of 63 (leaving room for the terminating
NUL), so at most 63 bytes are written into each 64-byte buffer:
ret = sscanf(subflow_addrs, "%63[^:]:%d %63[^:]:%d",
saddr, &sport, daddr, &dport);
The subflow address can be passed in argument, so fixing this is helpful
when the tool is manually used.
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
To: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/mptcp/mptcp_diag.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_diag.c b/tools/testing/selftests/net/mptcp/mptcp_diag.c
index 5e222ba977e4..3b8d2c8a6216 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_diag.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_diag.c
@@ -377,7 +377,8 @@ static void get_subflow_info(char *subflow_addrs)
int ret;
int fd;
- ret = sscanf(subflow_addrs, "%[^:]:%d %[^:]:%d", saddr, &sport, daddr, &dport);
+ ret = sscanf(subflow_addrs, "%63[^:]:%d %63[^:]:%d",
+ saddr, &sport, daddr, &dport);
if (ret != 4)
die_perror("IP PORT Pairs has style problems!");
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next 00/11] mptcp: misc. features for v7.3
2026-08-12 14:55 [PATCH net-next 00/11] mptcp: misc. features for v7.3 Matthieu Baerts (NGI0)
` (5 preceding siblings ...)
2026-08-12 14:55 ` [PATCH net-next 11/11] selftests: mptcp: diag: fix stack buffer overflow in get_subflow_info() Matthieu Baerts (NGI0)
@ 2026-08-14 22:21 ` Matthieu Baerts
6 siblings, 0 replies; 8+ messages in thread
From: Matthieu Baerts @ 2026-08-14 22:21 UTC (permalink / raw)
To: Mat Martineau, Geliang Tang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, mptcp, linux-kernel, Tao Cui, Steven Rostedt,
Masami Hiramatsu, Mathieu Desnoyers, linux-trace-kernel,
Kalpan Jani, Shardul Bankar, Shuah Khan, linux-kselftest,
Jiangshan Yi
Hello,
On 12/08/2026 16:55, Matthieu Baerts (NGI0) wrote:
> This series contains a few independent new features, and small fixes for
> net-next:
I checked Sashiko [1] and Clashiko [2] reviews, and here below is a
brief summary. TL;DR: I don't think a v2 is needed, and follow-up
patches fixing pre-existing issues will be sent separately.
[1]
https://sashiko.dev/#/patchset/20260812-net-next-mptcp-misc-feat-7-3-v1-0-1905a818f6cb@kernel.org
[2]
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260812-net-next-mptcp-misc-feat-7-3-v1-0-1905a818f6cb@kernel.org
> - Patch 1: Add WARN_ON_ONCE guards around extra_subflows to catch issues
> with this counter, similar to what is done with other PM counters.
Pre-existing issues: fixes will be sent to net.
> - Patches 2-3: Follow-up patches to remove data_ack field from struct
> mptcp_ext -- now unused after recent fixes -- and makes a userspace PM
> helper static.
Pre-existing issue: a fix will be sent to net.
> - Patch 4: Honour tcp_rto_{min_us,max_ms} sysctls for MPTCP-level
> retransmit timers like with DATA_FIN's and fallback timeout.
Not needed: suggesting adding extra checks if the TCP RTO max and min
sysctl are misconfigured (min > max). There is already a check in the
code to avoid a division by 0. The rest is similar to TCP.
> - Patches 5-6: Add per-event MIB counters for MPTCP_RST_EMPTCP resets to
> help to spot such situations in production.
Patch 5: some imprecisions in the commit message, not worth a respin I
think. Plus a suggestion of adding an extra increment, but it is for a
different case, so no.
Patch 6: no need to handle the only test where the server initiates the
subflow → the goal is to check that globally these counters are not
unexpetedly incremented. Maybe MPJoinNotEstablished could be checked on
the other side as well, but this shouldn't happen with the current
selftests, and this addition can come in a follow-up patch.
> - Patches 7-9: Small pcap-related improvements in the selftests.
Patch 7: no need to differenciate the mptcp_connect_*.sh which are only
there for the CI. Someone doing the debugging and asking for pcaps will
use mptcp_connect.sh
> - Patch 10: Fix compiler warning in the selftests.
pre-existing, and not really an issue: the selftests don't try to trick
mptcp_connect
> - Patch 11: Avoid a buffer overflow when misusing the mptcp_diag tool
> from the selftests.
Small typo in the commit message, not worth a respin I think. Plus yes
it is a fix, but not worth being backported: can be a bug when this tool
designed for the selftest is used manually with a wrong address (which
is written in the commit message). Plus pre-existing issues that are not
worth fixing in a follow-up patch for this selftest tool.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 8+ messages in thread