All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: geliang@kernel.org
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-net v3 1/4] mptcp: handle ack_seq advancing past rcv_data_fin_seq
Date: Tue, 24 Nov 2026 15:26:32 +0000	[thread overview]
Message-ID: <179553399254.3133.1494414493820106441@kernel.org> (raw)
In-Reply-To: <84d2d4f05df024cd45c1936a3d53ea1d2797ae2a.1795396910.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] After the patch, mptcp_pending_data_fin() (protocol.c:571)
  returns true whenever ack_seq is at or after rcv_data_fin_seq, and…
- [High] Replacing the exact match with `!before64(ack_seq,
  rcv_data_fin_seq)` in mptcp_pending_data_fin() (protocol.c:571)…
- [Medium] The commit message gives a trigger the code cannot produce.
- [Low] The commit author is Geliang Tang <geliang@kernel.org>, but the
  only Signed-off-by is Geliang Tang <tanggeliang@kylinos.cn>.

--

mptcp: handle ack_seq advancing past rcv_data_fin_seq

This commit changes the check in mptcp_pending_data_fin() from
ack_seq == rcv_data_fin_seq to !before64(ack_seq, rcv_data_fin_seq). The
goal is to process a DATA_FIN even after out-of-order processing has
moved ack_seq past the DATA_FIN sequence number.

> This handles the case where
> out-of-order segments in the OFO queue advance ack_seq past
> rcv_data_fin_seq before mptcp_pending_data_fin() runs.

[Severity: Medium]
Can this happen with a compliant peer?

In get_mapping_status(), a DATA_FIN sent with a data mapping uses one
byte of sequence space, and the mapped payload is shortened by one:

net/mptcp/subflow.c:get_mapping_status() {
    ...
		data_fin_seq = mpext->data_seq + data_len - 1;
    ...
		/* Adjust for DATA_FIN using 1 byte of sequence space */
		data_len--;
    ...
}

So the mapped payload ends exactly at the DATA_FIN DSN. A DATA_FIN with
data_len == 1 maps no data at all.

ack_seq only moves to the end of mapped data. In __mptcp_move_skb():

	WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len);

and in __mptcp_ofo_queue():

	WRITE_ONCE(msk->ack_seq, end_seq);

The fallback dummy DATA_FIN in subflow_sched_work_if_closed() uses
map_seq + map_data_len, which is also where ack_seq stops.

With well-formed mappings, ack_seq reaches rcv_data_fin_seq and stops there,
so the old == test already matched. Getting ack_seq > rcv_data_fin_seq
seems to need a misbehaving peer or a forged segment. That means either
data mapped at or past its own DATA_FIN DSN, or a DATA_FIN DSN that is
already behind ack_seq.

Could the commit message describe the real trigger, ideally with a
reproducer or trace? As written, the Fixes: tag suggests a hang that
ordinary connections can hit.

> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>

[Severity: Low]
This isn't a bug, but the Author address (geliang@kernel.org) and the
Signed-off-by address (tanggeliang@kylinos.cn) differ, so checkpatch.pl will
warn with FROM_SIGN_OFF_MISMATCH. .mailmap maps both addresses to the same
person, so there is no DCO problem.

Could the sign-off use the author address, or could an in-body From: be
added?

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index d3878160f936c..1a4b921136a60 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -568,7 +568,7 @@ static bool mptcp_pending_data_fin(struct sock *sk, u64 *seq)
>  	     (TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2))) {
>  		u64 rcv_data_fin_seq = READ_ONCE(msk->rcv_data_fin_seq);
>  
> -		if (READ_ONCE(msk->ack_seq) == rcv_data_fin_seq) {
> +		if (!before64(READ_ONCE(msk->ack_seq), rcv_data_fin_seq)) {

[Severity: High]
Does the caller still assume ack_seq == rcv_data_fin_seq here?

mptcp_check_data_fin() ignores the rcv_data_fin_seq returned through *seq
and increments the current ack_seq instead:

net/mptcp/protocol.c:mptcp_check_data_fin() {
    ...
	 * If we are caught up to the sequence number of the incoming
	 * DATA_FIN, send the DATA_ACK now and do state transition.  If
    ...
	if (mptcp_pending_data_fin(sk, &rcv_data_fin_seq)) {
		WRITE_ONCE(msk->ack_seq, msk->ack_seq + 1);
		WRITE_ONCE(msk->rcv_data_fin, 0);
    ...
}

This patch only changes behaviour when ack_seq > rcv_data_fin_seq. In
that case the DATA_FIN is counted at ack_seq + 1 instead of
rcv_data_fin_seq + 1, and mptcp_send_ack() then sends that value to the
peer.

On a Linux peer, ack_update_msk() ignores a DATA_ACK beyond snd_nxt:

	if (unlikely(before64(snd_nxt, old_snd_una) ||
		     after64(new_snd_una, snd_nxt)))
		new_snd_una = old_snd_una;

So the peer's DATA_FIN can stay unacknowledged after the local side has
moved to CLOSE_WAIT, CLOSING or CLOSE. The peer then waits for its own
timeout.

If the peer does have data in flight past ack_seq, a DATA_ACK of
ack_seq + 1 acknowledges a byte that was never received. When the real
segment at the old ack_seq arrives, could mptcp_subflow_discard_data() or
the partial-packet path in __mptcp_move_skb() drop its first byte?

Any data at or past the DATA_FIN DSN also stays in the receive queue and
is counted in ack_seq and bytes_received, even though RCV_SHUTDOWN is set.

Would it be better to keep the exact-match check and validate the DSN when
it is recorded? Another option is to decide explicitly how data past the
DATA_FIN should be handled.

[Severity: High]
Does this change remove the only check on the DATA_FIN DSN sent by the
peer?

That value is stored without validation. For a zero-length segment that
carries a DSS DATA_FIN, mptcp_incoming_options() does:

	if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) {
		if (mp_opt.data_fin && mp_opt.data_len == 1 &&
		    mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
			mptcp_schedule_work((struct sock *)msk);

This path has no DSS checksum and no window check.
mptcp_update_rcv_data_fin() only refuses if rcv_data_fin is already set,
and otherwise stores the value as is:

	WRITE_ONCE(msk->rcv_data_fin_seq,
		   mptcp_expand_seq(READ_ONCE(msk->ack_seq), data_fin_seq, use_64bit));

Before this patch, the DATA_FIN only took effect when its DSN was exactly
ack_seq. After it, any DSN at or behind ack_seq takes effect right away
(for example data_seq = 0 with dsn64):

mptcp_worker()
  mptcp_check_data_fin()
    mptcp_pending_data_fin()   <- now true for any past DSN
    sets RCV_SHUTDOWN, moves to CLOSE_WAIT/CLOSING/CLOSE

A DSN ahead of ack_seq also takes effect once a single skb move jumps
past it.

Can one in-window segment on any single subflow now force what looks like
a clean EOF on the whole MPTCP connection? The application would get a
truncated stream that it cannot tell apart from a normal close.

mptcp_check_data_fin() then writes ack_seq + 1, so the DATA_ACK also
acknowledges a byte that was never received. The peer's real segment
starting at the old ack_seq would then lose its first byte.

A legitimate peer never sends a DATA_FIN DSN behind ack_seq, so the newly
accepted inputs seem to come only from misbehaving peers or injected
segments. An attacker still needs a segment the subflow will accept.
However, instead of guessing the exact DSN, roughly half the sequence
space now works.

>  			if (seq)
>  				*seq = rcv_data_fin_seq;
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795396910.git.tanggeliang%40kylinos.cn

  reply	other threads:[~2026-11-24 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  1:27 [PATCH mptcp-net v3 0/4] mptcp: fixes for SIOCINQ Geliang Tang
2026-11-23  1:27 ` [PATCH mptcp-net v3 1/4] mptcp: handle ack_seq advancing past rcv_data_fin_seq Geliang Tang
2026-11-24 15:26   ` netdev-bot+sashiko [this message]
2026-11-23  1:27 ` [PATCH mptcp-net v3 2/4] mptcp: add missing memory barriers for rcv_data_fin_seq Geliang Tang
2026-11-24 15:26   ` netdev-bot+sashiko
2026-11-23  1:27 ` [PATCH mptcp-net v3 3/4] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-24 15:26   ` netdev-bot+sashiko
2026-11-23  1:27 ` [PATCH mptcp-net v3 4/4] mptcp: add mptcp_inq() for SIOCINQ Geliang Tang
2026-11-24 15:26   ` netdev-bot+sashiko
2026-11-23  3:34 ` [PATCH mptcp-net v3 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=179553399254.3133.1494414493820106441@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.