From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v6 3/7] selftests: mptcp: connect: check TFO SIOCINQ overflow
Date: Thu, 05 Nov 2026 06:55:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-198640@kernel.org> (raw)
In-Reply-To: <da22fd79c625e4eed90e83cf91bdddcb165a4a78.1793860134.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] selftests: mptcp: commit message mismatch on polling remotesock in main_loop_s()
- [Medium] selftests: mptcp: SIOCINQ check in main_loop_s() races with TFO third ACK
--
commit d076cef4545cfcddd6e28fb675be9a4054df1b3b
Author: Geliang Tang <geliang@kernel.org>
selftests: mptcp: connect: check TFO SIOCINQ overflow
This commit adds a SIOCINQ check in mptcp_connect's server mode when the
MPTFO socket option is enabled to detect TFO SIOCINQ overflow regressions.
> selftests: mptcp: connect: check TFO SIOCINQ overflow
>
> Add a check in mptcp_connect's server mode to detect TFO SIOCINQ overflow.
> When a TFO connection is accepted, poll for data to arrive, then check if
> SIOCINQ returns INT_MAX. This detects the regression where mptcp_inq_hint()
> incorrectly returns INT_MAX for passive TFO connections.
>
> The check runs when the MPTFO sockopt is set. It polls the accepted socket
> for up to one second, then uses ioctl(SIOCINQ) to verify the available
> byte count. If SIOCINQ returns INT_MAX, the test fails.
>
> This test verifies the fix in the preceding commit "mptcp: fix TFO SIOCINQ
> overflow in mptcp_inq_hint".
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
[Severity: Medium]
Does the commit message match the actual code in main_loop_s()? The commit
message states in two places that the test polls the accepted socket for up to
one second before calling ioctl(SIOCINQ), whereas main_loop_s() in
tools/testing/selftests/net/mptcp/mptcp_connect.c invokes ioctl(remotesock,
SIOCINQ, &avail) directly without calling poll().
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index 178d98d91fea2..83db495704fec 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -1207,6 +1207,17 @@ int main_loop_s(int listensock)
> check_sockaddr(pf, &ss, salen);
> check_getpeername(remotesock, &ss, salen);
>
> + if (cfg_sockopt_types.mptfo) {
> + int avail;
> +
> + if (ioctl(remotesock, SIOCINQ, &avail) == 0 &&
> + avail == INT_MAX) {
> + fprintf(stderr, "TFO SIOCINQ overflow\n");
> + close(remotesock);
> + return 1;
> + }
> + }
[Severity: Medium]
Can this SIOCINQ check in main_loop_s() race with the TFO third ACK and miss
the overflow regression on unfixed kernels?
When a passive MPTCP Fast Open SYN+data packet with a valid cookie arrives in
tcp_conn_request(), the child msk is created via:
tcp_try_fastopen()
-> tcp_fastopen_create_child()
-> subflow_syn_recv_sock()
-> mptcp_sk_clone_init()
At that point mp_opt->suboptions only has OPTION_MPTCP_MPC_SYN (not
OPTION_MPTCP_MPC_ACK), leaving msk->ack_seq at 0. Next, af_ops->send_synack()
calls subflow_prep_synack() -> mptcp_fastopen_subflow_synack_set_params() in
net/mptcp/fastopen.c:
MPTCP_SKB_CB(skb)->map_seq = -skb->len;
MPTCP_SKB_CB(skb)->end_seq = 0;
...
__skb_queue_tail(&sk->sk_receive_queue, skb);
Then tcp_fastopen_create_child() immediately adds the child socket to the
listener accept queue via inet_csk_reqsk_queue_add() and wakes the listener via
sk->sk_data_ready().
Before the client receives the SYN-ACK and replies with the third ACK carrying
OPTION_MPTCP_MPC_ACK, msk->ack_seq is still 0. If main_loop_s() accepts the
socket and calls ioctl(remotesock, SIOCINQ, &avail) before the third ACK is
processed, even an unfixed mptcp_inq_hint() computes:
READ_ONCE(msk->ack_seq) - MPTCP_SKB_CB(skb)->map_seq = 0 - (-skb->len) = skb->len
rather than overflowing to INT_MAX. The overflow to subflow->iasn + skb->len >=
INT_MAX only occurs after the server processes the third ACK in:
tcp_rcv_state_process()
-> tcp_data_queue()
-> mptcp_incoming_options()
-> check_fully_established()
-> __mptcp_subflow_fully_established()
-> subflow_set_remote_key()
which sets WRITE_ONCE(msk->ack_seq, subflow->iasn) in net/mptcp/subflow.c.
Note also that simply polling POLLIN on remotesock would return immediately
because mptcp_fastopen_subflow_synack_set_params() already queued the SYN data
onto sk_receive_queue prior to accept().
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1793860134.git.tanggeliang@kylinos.cn?part=3
next prev parent reply other threads:[~2026-11-05 6:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 6:37 [PATCH mptcp-next v6 0/7] prepare interfaces for kTLS and sockmap support Geliang Tang
2026-11-05 6:37 ` [PATCH mptcp-next v6 1/7] mptcp: update mptcp_check_readable Geliang Tang
2026-11-05 6:37 ` [PATCH mptcp-net v6 2/7] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-06 19:53 ` netdev-bot+sashiko
2026-11-05 6:37 ` [PATCH mptcp-next v6 3/7] selftests: mptcp: connect: check TFO SIOCINQ overflow Geliang Tang
2026-11-05 6:55 ` sashiko-bot [this message]
2026-11-06 19:53 ` netdev-bot+sashiko
2026-11-05 6:38 ` [PATCH mptcp-next v6 4/7] mptcp: implement peek_len for proto_ops Geliang Tang
2026-11-06 19:53 ` netdev-bot+sashiko
2026-11-05 6:38 ` [PATCH mptcp-next v6 5/7] mptcp: add sendmsg_locked to proto_ops Geliang Tang
2026-11-06 19:53 ` netdev-bot+sashiko
2026-11-05 6:38 ` [PATCH mptcp-next v6 6/7] mptcp: track app-limited state in mptcp_sendmsg Geliang Tang
2026-11-06 19:53 ` netdev-bot+sashiko
2026-11-05 6:38 ` [PATCH mptcp-next v6 7/7] selftests: mptcp: sockopt: check app_limited Geliang Tang
2026-11-06 19:53 ` netdev-bot+sashiko
2026-11-05 8:36 ` [PATCH mptcp-next v6 0/7] prepare interfaces for kTLS and sockmap support MPTCP CI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-198640@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=geliang@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox