All of lore.kernel.org
 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 v29 2/8] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint
Date: Thu, 19 Nov 2026 05:26:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-222480@kernel.org> (raw)
In-Reply-To: <f9a5a16a7164ad9e1a09b0f58e99f0e4ab3cdb99.1795063943.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mptcp: premature or missed FIN accounting in mptcp_inq_hint()
--

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

mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint

This commit changes mptcp_inq_hint() to compute available bytes from
mptcp_data_avail() and add 1 when msk->rcv_data_fin_seq is non-zero.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 382da25320378..072725c6ab5d1 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2404,22 +2404,15 @@ 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 (READ_ONCE(msk->rcv_data_fin_seq))
> +		hint_val += 1;
>  
> -		return (unsigned int)hint_val;
> -	}
> -
> -	if (sk->sk_state == TCP_CLOSE || (sk->sk_shutdown & RCV_SHUTDOWN))
> -		return 1;
> -
> -	return 0;
> +	return (unsigned int)hint_val;
>  }

[Severity: Medium]
Can checking msk->rcv_data_fin_seq here add the FIN byte before the
in-order stream has reached DATA_FIN?

mptcp_update_rcv_data_fin() sets msk->rcv_data_fin_seq as soon as a
DATA_FIN option is parsed on any subflow, while mptcp_check_data_fin()
only sets RCV_SHUTDOWN once msk->ack_seq catches up to rcv_data_fin_seq.
If DATA_FIN arrives out of order across subflows while mptcp_data_avail()
is 0, SIOCINQ and TCP_CM_INQ will report 1, but a subsequent non-blocking
mptcp_recvmsg() will fail with -EAGAIN (or block) because RCV_SHUTDOWN is
not set yet.

Also, on an active connection that falls back to plain TCP before
receiving MP_CAPABLE and closes with 0 payload bytes,
subflow_sched_work_if_closed() records rcv_data_fin_seq as 0, so
READ_ONCE(msk->rcv_data_fin_seq) stays false and omits the FIN byte at
EOF.

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

  reply	other threads:[~2026-11-19  5:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  5:10 [PATCH mptcp-next v29 0/8] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-19  5:10 ` [PATCH mptcp-net v29 1/8] mptcp: clear rcv_data_fin_seq in mptcp_disconnect Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-net v29 2/8] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-19  5:26   ` sashiko-bot [this message]
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 3/8] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-19  5:10 ` [PATCH mptcp-next v29 4/8] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 5/8] mptcp: encapsulate CB DSN field access with helpers Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 6/8] mptcp: remove CB offset field Geliang Tang
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 7/8] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-19  5:43   ` sashiko-bot
2026-11-20 18:41   ` netdev-bot+sashiko
2026-11-19  5:10 ` [PATCH mptcp-next v29 8/8] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang

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-222480@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 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.