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-next v28 06/11] mptcp: add flags field to mptcp_skb_cb
Date: Tue, 17 Nov 2026 22:41:11 +0000	[thread overview]
Message-ID: <179495527130.3133.4607719757932776867@kernel.org> (raw)
In-Reply-To: <f31e23f95b08c864e69ad13f1d794795b24ead1a.1794810809.git.tanggeliang@kylinos.cn>

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

Critical: 1 · High: 0 · Medium: 0 · 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).

- [Critical] In net/mptcp/protocol.c, __mptcp_try_coalesce() used to
  refuse coalescing when `MPTCP_SKB_CB(from)->offset` was non-zero.
- [Low] The commit message says MPTCP_SKB_CB_F_OFFSET marks "skbs with a
  non-zero offset".

--

mptcp: add flags field to mptcp_skb_cb

This commit adds a flags field to struct mptcp_skb_cb and a
MPTCP_SKB_CB_F_OFFSET flag. mptcp_init_skb() sets the flag when the skb
has a non-zero offset. __mptcp_try_coalesce() now tests this flag on both
skbs instead of testing from->offset directly, as preparation for removing
the offset field later in the series.

[ ... ]

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 41fc2429d2fed..395bdcd0080c1 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -168,7 +168,8 @@ static bool __mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
>  	int limit = READ_ONCE(sk->sk_rcvbuf);
>  
>  	if (MPTCP_SKB_CB(from)->map_seq != MPTCP_SKB_CB(to)->end_seq ||
> -	    MPTCP_SKB_CB(from)->offset ||
> +	    (MPTCP_SKB_CB(from)->flags | MPTCP_SKB_CB(to)->flags) &
> +	     MPTCP_SKB_CB_F_OFFSET ||
>  	    ((to->len + from->len) > (limit >> 3)) ||
>  	    !skb_try_coalesce(to, from, fragstolen, delta))
>  		return false;

[Severity: Critical]
Can this coalesce an skb whose prefix the msk has already received?

The flag is only computed in mptcp_init_skb(). The partial packet branch
of __mptcp_move_skb() raises offset after that, leaves flags alone, and
then jumps to the coalesce attempt:

net/mptcp/protocol.c:__mptcp_move_skb() {
    ...
	/* Partial packet */
	if (after64(MPTCP_SKB_CB(skb)->end_seq, msk->ack_seq)) {
		copy_len = MPTCP_SKB_CB(skb)->end_seq - msk->ack_seq;
		MPTCP_SKB_CB(skb)->offset += msk->ack_seq -
					     MPTCP_SKB_CB(skb)->map_seq;
		MPTCP_SKB_CB(skb)->map_seq += msk->ack_seq -
					      MPTCP_SKB_CB(skb)->map_seq;
		goto insert;
	}
    ...
insert:
    ...
		tail = skb_peek_tail(&sk->sk_receive_queue);
		if (tail && mptcp_try_coalesce(sk, tail, skb))
			return true;
    ...
}

At that point from->map_seq equals the old ack_seq, which is also
tail->end_seq, and both flags are 0. Before this patch the from->offset
test refused the merge. Now skb_try_coalesce() appends all from->len bytes
to the tail, already-received prefix included.

__mptcp_recvmsg_mskq() and mptcp_read_sock() copy skb->len - offset bytes
from the tail. Wouldn't userspace then get the overlapping bytes twice in
the middle of the stream? bytes_consumed could also grow past
bytes_received, so mptcp_data_avail() could wrap.

One way to reach this is while the msk is owned by the user. In that case
mptcp_data_ready() puts subflow skbs on the backlog without advancing
msk->ack_seq. The old-data discard in subflow_check_data_avail() then
compares against a stale ack_seq.

Suppose the peer sends DSN [0,1000) on one subflow and [500,1500) on
another, either as a normal reinjection or through a crafted DSS. When the
backlog is spooled, the second skb takes the partial path: offset goes
from 0 to 500, flags stays 0, and the whole skb is coalesced into the
first one.

This looks resolved later in the series by "mptcp: remove CB offset
field". There, the partial path no longer modifies offset or map_seq, and
the from->map_seq != mptcp_end_dsn(to) check rejects the partial skb. The
window is limited to this commit and "mptcp: encapsulate CB DSN field
access with helpers".

Could this commit keep the from->offset test, or set MPTCP_SKB_CB_F_OFFSET
in the partial path? Then a bisect that lands here would not hit the
duplicated data.

> @@ -428,6 +429,7 @@ static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset,
>  	MPTCP_SKB_CB(skb)->map_seq = mptcp_subflow_get_mapped_dsn(subflow);
>  	MPTCP_SKB_CB(skb)->end_seq = MPTCP_SKB_CB(skb)->map_seq + copy_len;
>  	MPTCP_SKB_CB(skb)->offset = offset;
> +	MPTCP_SKB_CB(skb)->flags = offset ? MPTCP_SKB_CB_F_OFFSET : 0;
>  	MPTCP_SKB_CB(skb)->has_rxtstamp = has_rxtstamp;

[Severity: Low]
This isn't a bug, but the commit message says:

    Add a flags field to mptcp_skb_cb and define MPTCP_SKB_CB_F_OFFSET to
    mark skbs with a non-zero offset.

At this commit the flag only records whether offset was non-zero when
mptcp_init_skb() ran. Several places still raise MPTCP_SKB_CB(skb)->offset
later without updating flags:

- __mptcp_move_skb(), on the partial packet path
- __mptcp_ofo_queue()
- __mptcp_recvmsg_mskq(), on partial reads
- mptcp_read_sock(), on partial reads

Could the description say that the flag reflects the offset at init time?

Two smaller points. The new to->flags test goes further than the old check,
which only looked at from. It costs a few coalescing opportunities. Also,
the reason for the value TCPHDR_FLAGS_MASK + 1 is only given in the later
"mptcp: sync mptcp skb cb layout with tcp one" patch.

Both points go away once "mptcp: remove CB offset field" removes the offset
field. This is only about the wording of this intermediate commit.

[ ... ]

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

  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
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 [this message]
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=179495527130.3133.4607719757932776867@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.