MPTCP Linux Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net v4 3/4] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint
Date: Sat, 28 Nov 2026 11:25:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-238659@kernel.org> (raw)
In-Reply-To: <36402c6a6c41fdd1c5c4a06edbe9f95f4657e573.1795863454.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: spurious FIN byte in mptcp_inq_hint() on fallback TCP
  reset
--

commit e8009d5eaab8f8edb7310542593678227a6679d0
Author: Geliang Tang <geliang@kernel.org>

mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint

This commit updates mptcp_inq_hint() to compute readable bytes from
mptcp_data_avail() and adds a mptcp_data_fin() helper to account for a
pending FIN byte.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 52b5b6d2f1ce9..69facb6a86f04 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c

[ ... ]

> @@ -2437,22 +2443,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);
>  
> -	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 (hint_val >= INT_MAX)
> -			return INT_MAX;
> +	if (sock_flag(sk, SOCK_DONE) ||
> +	    (READ_ONCE(msk->rcv_data_fin) && mptcp_data_fin(msk, NULL)))
> +		hint_val += 1;
>  
> -		return (unsigned int)hint_val;
> -	}
> -
> -	if (sock_flag(sk, SOCK_DONE))
> -		return 1;
> -
> -	return 0;
> +	return (unsigned int)hint_val;
>  }

[Severity: Medium]
Can mptcp_inq_hint() add a spurious FIN byte when a fallback connection is
closed by a TCP RST?

On fallback, subflow_sched_work_if_closed() sets msk->rcv_data_fin whenever
the subflow enters TCP_CLOSE, including after receiving a TCP RST without a
prior FIN.  mptcp_check_data_fin() and __mptcp_subflow_error_report() both
check sock_flag(ssk, SOCK_DONE) before setting SOCK_DONE on sk, and
__mptcp_subflow_error_report() moves sk to TCP_CLOSE without clearing
msk->rcv_data_fin:

net/mptcp/protocol.c:mptcp_check_data_fin() {
    ...
		/* on fallback, also emulated after a reset: check for a FIN */
		if (!__mptcp_check_fallback(msk) ||
		    (msk->first && sock_flag(msk->first, SOCK_DONE)))
			sock_set_flag(sk, SOCK_DONE);
    ...
}

Because mptcp_inq_hint() checks msk->rcv_data_fin and mptcp_data_fin()
directly without verifying the socket state or whether a fallback subflow
actually received a FIN, TCP_CM_INQ (and mptcp_rcv_space_adjust()) will
count an extra FIN byte that was never received.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795863454.git.tanggeliang@kylinos.cn?part=3

  reply	other threads:[~2026-11-28 11:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 11:08 [PATCH mptcp-net v4 0/4] mptcp: fixes for SIOCINQ Geliang Tang
2026-11-28 11:08 ` [PATCH mptcp-net v4 1/4] mptcp: add missing memory barriers for rcv_data_fin_seq Geliang Tang
2026-11-28 11:08 ` [PATCH mptcp-net v4 2/4] mptcp: use SOCK_DONE in mptcp_inq_hint Geliang Tang
2026-11-28 11:20   ` sashiko-bot
2026-11-28 11:08 ` [PATCH mptcp-net v4 3/4] mptcp: fix TFO SIOCINQ overflow " Geliang Tang
2026-11-28 11:25   ` sashiko-bot [this message]
2026-11-28 11:08 ` [PATCH mptcp-net v4 4/4] mptcp: add mptcp_inq() for SIOCINQ Geliang Tang
2026-11-28 12:13 ` [PATCH mptcp-net v4 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-238659@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