From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net v2 3/4] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint
Date: Sun, 22 Nov 2026 12:21:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-227923@kernel.org> (raw)
In-Reply-To: <692168c4f75bdb59bc8a9ec9ed116674747c3898.1795348666.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: mptcp_inq_hint() compares ack_seq with unset
rcv_data_fin_seq
--
commit 91eba8ecdb62213836985c3edebbb4b735538410
Author: Geliang Tang <geliang@kernel.org>
mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint
This commit updates mptcp_inq_hint() to compute available bytes from
mptcp_data_avail() and adds a mptcp_data_fin() helper to check whether
ack_seq has passed rcv_data_fin_seq.
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 259a16068afad..7ef37f978f5b1 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -558,6 +558,21 @@ static void mptcp_check_data_fin_ack(struct sock *sk)
> }
> }
>
> +static bool mptcp_data_fin(const struct mptcp_sock *msk, u64 *seq)
> +{
> + u64 rcv_data_fin_seq;
> +
> + smp_rmb(); /* pair with smp_wmb() in mptcp_update_rcv_data_fin() */
> + rcv_data_fin_seq = READ_ONCE(msk->rcv_data_fin_seq);
> + if (!before64(READ_ONCE(msk->ack_seq), rcv_data_fin_seq)) {
> + if (seq)
> + *seq = rcv_data_fin_seq;
> +
> + return true;
> + }
> + return false;
> +}
[ ... ]
> @@ -2364,22 +2370,18 @@ 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;
> -
> - skb = skb_peek(&sk->sk_receive_queue);
> - if (skb) {
> - u64 hint_val = READ_ONCE(msk->ack_seq) - MPTCP_SKB_CB(skb)->map_seq;
> + u64 hint_val = mptcp_data_avail(msk);
>
> - if (hint_val >= INT_MAX)
> - return INT_MAX;
> + if (hint_val >= INT_MAX)
> + return INT_MAX;
>
> - return (unsigned int)hint_val;
> + if (READ_ONCE(msk->rcv_data_fin) ||
> + sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN)) {
> + if (mptcp_data_fin(msk, NULL))
> + hint_val += 1;
> }
>
> - if (sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN))
> - return 1;
> -
> - return 0;
> + return (unsigned int)hint_val;
> }
[Severity: Medium]
Can mptcp_inq_hint() call mptcp_data_fin() when msk->rcv_data_fin is false
and msk->rcv_data_fin_seq has never been set?
When a socket enters TCP_CLOSE or sets RCV_SHUTDOWN without receiving a
DATA_FIN (for example via shutdown(fd, SHUT_RD) or a peer reset),
msk->rcv_data_fin_seq is still 0. Because before64() uses signed 64-bit
modular arithmetic, !before64(msk->ack_seq, 0) tests (__s64)msk->ack_seq >= 0,
and subflow_set_remote_key() seeds msk->ack_seq from a 64-bit SHA-256 hash.
Depending on bit 63 of msk->ack_seq, mptcp_inq_hint() will either omit the
+1 EOF indication on a closed or shut-down empty socket or add a spurious
+1 while unread data is still queued after SHUT_RD. Checking
sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN) directly for
the +1, and only calling mptcp_data_fin() when READ_ONCE(msk->rcv_data_fin)
is true, would avoid comparing against an unset rcv_data_fin_seq.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795348666.git.tanggeliang@kylinos.cn?part=3
next prev parent reply other threads:[~2026-11-22 12:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 12:07 [PATCH mptcp-net v2 0/4] mptcp: fixes for SIOCINQ Geliang Tang
2026-11-22 12:07 ` [PATCH mptcp-net v2 1/4] mptcp: handle ack_seq advancing past rcv_data_fin_seq Geliang Tang
2026-11-22 12:07 ` [PATCH mptcp-net v2 2/4] mptcp: add missing memory barriers for rcv_data_fin_seq Geliang Tang
2026-11-22 12:07 ` [PATCH mptcp-net v2 3/4] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-22 12:21 ` sashiko-bot [this message]
2026-11-22 12:07 ` [PATCH mptcp-net v2 4/4] mptcp: add mptcp_inq() for SIOCINQ Geliang Tang
2026-11-22 14:26 ` [PATCH mptcp-net v2 0/4] mptcp: fixes " 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-227923@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