From: netdev-bot+sashiko@kernel.org
To: geliang@kernel.org
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-net v28 01/11] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint
Date: Tue, 17 Nov 2026 22:41:09 +0000 [thread overview]
Message-ID: <179495526966.3133.1400847227803157545@kernel.org> (raw)
In-Reply-To: <ebac8e12800293fe7cfc0f2b5f88109b34df6d06.1794810809.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message gets the TCP comparison wrong for SIOCINQ.
- [Low] The From: and Signed-off-by addresses do not match.
- [Low] After this patch, MPTCP's TCP_CM_INQ cmsg no longer matches TCP
once a DATA_FIN has arrived with N > 0 bytes unread.
--
mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint
This commit changes mptcp_inq_hint() to compute the available bytes with
mptcp_data_avail() instead of ack_seq minus the head skb's map_seq. On
passive TFO connections the old formula returned INT_MAX. As a side
effect, the value reported after DATA_FIN changes from N+1 to N.
> Using mptcp_data_avail() avoids this by tracking bytes directly. This
> change also affects non-TFO connections after DATA_FIN: with N bytes
> unread, both SIOCINQ and TCP_CM_INQ now report N instead of N+1. This
> differs from TCP, which reports N+1 because the FIN consumes a sequence
> number. The EOF hint of 1 is preserved for the empty-queue case when
> the socket is closed or shutdown.
[Severity: Low]
Is the comparison with TCP accurate for SIOCINQ? TCP's SIOCINQ path is
tcp_inq(), and it subtracts the FIN:
include/net/tcp.h:tcp_inq() {
...
answ = tp->rcv_nxt - tp->copied_seq;
/* Subtract 1, if FIN was received */
if (answ && sock_flag(sk, SOCK_DONE))
answ--;
...
}
After a FIN, TCP reports N for SIOCINQ. Only TCP_CM_INQ, through
tcp_inq_hint() in net/ipv4/tcp.c, reports N+1.
Before this patch, mptcp_inq_hint() returned N+1 on both interfaces,
because mptcp_check_data_fin() bumps ack_seq by 1 for DATA_FIN. So for
SIOCINQ/FIONREAD through mptcp_ioctl(), this patch actually makes MPTCP
match TCP. Only TCP_CM_INQ is a new difference.
The same applies to the EOF hint of 1. It matches TCP only for
TCP_CM_INQ. TCP's SIOCINQ reports 0 in that state.
Could the commit message say which interface now matches TCP and which
one differs?
> Fixes: f03afb3aeb9d ("mptcp: drop __mptcp_fastopen_gen_msk_ackseq()")
> Co-developed-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
[Severity: Low]
This isn't a bug, but the author address is geliang@kernel.org and the
only author Signed-off-by uses tanggeliang@kylinos.cn. checkpatch.pl will
report this as FROM_SIGN_OFF_MISMATCH. Should a Signed-off-by with the
From: address be added, or the author address be changed to match?
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 50de5cedfd0fb..f2644e7a6a05a 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2404,22 +2404,16 @@ static bool mptcp_move_skbs(struct sock *sk)
> static unsigned int mptcp_inq_hint(const struct sock *sk)
> {
> const struct mptcp_sock *msk = mptcp_sk(sk);
> - const struct sk_buff *skb;
> + u64 hint_val = mptcp_data_avail(msk);
[Severity: Low]
Does this break TCP_CM_INQ parity with TCP once a DATA_FIN has arrived
and N > 0 bytes are still unread?
mptcp_recvmsg() builds the cmsg from this helper:
net/mptcp/protocol.c:mptcp_recvmsg() {
...
if (cmsg_flags & MPTCP_CMSG_INQ) {
unsigned int inq = mptcp_inq_hint(sk);
put_cmsg(msg, SOL_TCP, TCP_CM_INQ, sizeof(inq), &inq);
}
...
}
With this patch the helper returns bytes_received - bytes_consumed = N.
TCP's tcp_inq_hint() returns rcv_nxt - copied_seq, which is N+1 because
the FIN consumes a sequence number.
Before this patch MPTCP also returned N+1, because mptcp_check_data_fin()
does:
WRITE_ONCE(msk->ack_seq, msk->ack_seq + 1);
mptcp_inq_hint() serves both mptcp_ioctl(SIOCINQ) and the TCP_CM_INQ
cmsg. TCP uses different semantics for the two: tcp_inq() subtracts the
FIN and tcp_inq_hint() does not. One shared helper therefore cannot match
TCP on both interfaces. This patch fixes SIOCINQ but breaks TCP_CM_INQ
parity.
Would it make sense to give the cmsg path its own value? For example, it
could add 1 when hint_val > 0 and DATA_FIN has been received, so that it
matches tcp_inq_hint().
Userspace can rely on the exact +1. The mptcp_connect selftest's
do_recvmsg_cmsg() uses it to detect a pending FIN:
if (ret + 1 != (int)last_hint) {
The next patch in the series, "selftests: mptcp: connect: check TFO
SIOCINQ overflow", adds a separate branch for the new inq semantics.
>
> - skb = skb_peek(&sk->sk_receive_queue);
> - if (skb) {
> - u64 hint_val = READ_ONCE(msk->ack_seq) - MPTCP_SKB_CB(skb)->map_seq;
> + if (hint_val >= INT_MAX)
> + return INT_MAX;
[ ... ]
> - if (sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN))
> + if (!hint_val &&
> + (sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN)))
> return 1;
>
> - return 0;
> + return (unsigned int)hint_val;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794810809.git.tanggeliang%40kylinos.cn
next prev parent reply other threads:[~2026-11-17 22:41 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 6:38 [PATCH mptcp-next v28 00/11] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-16 6:38 ` [PATCH mptcp-net v28 01/11] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-17 22:41 ` netdev-bot+sashiko [this message]
2026-11-16 6:38 ` [PATCH mptcp-next v28 02/11] selftests: mptcp: connect: check TFO SIOCINQ overflow Geliang Tang
2026-11-16 6:57 ` sashiko-bot
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 6:38 ` [PATCH mptcp-net v28 03/11] mptcp: fix fallback dummy mapping anchor Geliang Tang
2026-11-16 6:38 ` [PATCH mptcp-next v28 04/11] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-16 6:38 ` [PATCH mptcp-next v28 05/11] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-16 6:38 ` [PATCH mptcp-next v28 06/11] mptcp: add flags field to mptcp_skb_cb Geliang Tang
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 6:39 ` [PATCH mptcp-next v28 07/11] mptcp: encapsulate CB DSN field access with helpers Geliang Tang
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 6:39 ` [PATCH mptcp-next v28 08/11] mptcp: remove CB offset field Geliang Tang
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 6:39 ` [PATCH mptcp-next v28 09/11] mptcp: drop data after DATA_FIN before skb init Geliang Tang
2026-11-16 7:37 ` sashiko-bot
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 6:39 ` [PATCH mptcp-next v28 10/11] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-16 8:10 ` sashiko-bot
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 6:39 ` [PATCH mptcp-next v28 11/11] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
2026-11-17 22:41 ` netdev-bot+sashiko
2026-11-16 8:33 ` [PATCH mptcp-next v28 00/11] Reduce the differences between TCP and MPTCP for TLS usage 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=179495526966.3133.1400847227803157545@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=geliang@kernel.org \
--cc=kuba@kernel.org \
--cc=mptcp@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.