From: netdev-bot+sashiko@kernel.org
To: geliang@kernel.org
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-next v27 7/8] mptcp: sync mptcp skb cb layout with tcp one
Date: Mon, 16 Nov 2026 03:44:28 +0000 [thread overview]
Message-ID: <179480066832.3133.5753040360348134145@kernel.org> (raw)
In-Reply-To: <67a345724d8dfd927d8adb63fe851d096da4c8de.1794663678.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 2
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] mptcp: use of offset-shifted map_seq instead of mptcp_dsn() in
OoO queue
- [Medium] This patch hides a receive-path bug fix inside what its
message describes as a CB-layout change.
- [Medium] mptcp: copied_seq offset underflow in recv path for data after
DATA_FIN
- [Low] The commit message does not say why the MPTCP CB must match
tcp_skb_cb's layout, and it overstates one change.
- [Low] MPTCP_SKB_CB_F_OFFSET (0x0100, net/mptcp/protocol.h) is the same
bit as TCPHDR_AE (BIT(8), include/net/tcp.h:1105).
--
mptcp: sync mptcp skb cb layout with tcp one
This commit shrinks the MPTCP skb CB map_seq and end_seq fields to u32. It
also adds a map_seq64 field with the full 64-bit DSN and moves flags so it
lines up with tcp_skb_cb's tcp_flags, with build-time offset checks in
mptcp_proto_init(). Most receive path sequence comparisons now use the
32-bit before()/after() helpers.
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index f4ab3bdd368f2..44f4a680a4bdb 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -167,14 +167,14 @@ 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_end_dsn(to) ||
> + if (MPTCP_SKB_CB(from)->map_seq64 != mptcp_end_dsn(to) ||
> (MPTCP_SKB_CB(from)->flags | MPTCP_SKB_CB(to)->flags) &
> MPTCP_SKB_CB_F_OFFSET ||
[Severity: Low]
The commit message says:
"__mptcp_try_coalesce() gains a map_seq64 contiguity check to ensure
skbs are truly adjacent in the 64-bit DSN space."
Is "gains" accurate here? The removed line shows that the parent commit
already compared a u64 map_seq against mptcp_end_dsn(to). This hunk only
renames the field to map_seq64.
The message also doesn't say why the MPTCP CB has to match the
tcp_skb_cb layout. Nothing in this patch, or in the rest of the series,
reads TCP_SKB_CB() on msk receive queue skbs.
The CHK_CB_FIELD() checks only cover offsets, not meaning. For skbs with
MPTCP_SKB_CB_F_OFFSET set, end_seq is not map_seq + skb->len, which is
different from TCP's end_seq.
Could the commit message describe the intended consumer of this layout
guarantee?
[ ... ]
> @@ -495,8 +498,8 @@ static bool __mptcp_move_skb(struct sock *sk, struct sk_buff *skb)
> }
>
> /* Partial packet */
> - if (after64(MPTCP_SKB_CB(skb)->end_seq, msk->ack_seq)) {
> - copy_len = mptcp_end_dsn(skb) - msk->ack_seq;
> + if (after64(mptcp_end_dsn(skb), msk->ack_seq)) {
> + copy_len = (u32)mptcp_end_dsn(skb) - (u32)msk->ack_seq;
> goto insert;
> }
[Severity: Medium]
This hunk is more than a width change. It switches the partial packet test
from end_seq to mptcp_end_dsn(). That looks like a fix for a regression
added earlier in this series by "mptcp: remove CB offset field".
In that parent commit, mptcp_init_skb() does:
MPTCP_SKB_CB(skb)->map_seq = mptcp_subflow_get_mapped_dsn(subflow) -
offset;
MPTCP_SKB_CB(skb)->end_seq = MPTCP_SKB_CB(skb)->map_seq + copy_len;
Its caller, __mptcp_move_skbs_from_subflow(), passes copy_len as
skb->len - offset. So end_seq trails the real end DSN by offset, while
mptcp_end_dsn() returns map_seq + skb->len.
In the parent commit, take an skb with offset=1000, copy_len=100, dsn=5000
and msk->ack_seq=5050. Then end_seq is 4100 and mptcp_end_dsn() is 5100.
after64(4100, 5050) is false, so the skb falls through to "Completely old
data". It is counted as MPTCP_MIB_DUPDATA and dropped, even though
[5050, 5100) is new data.
The subflow has already advanced tp->copied_seq and TCP-acked those bytes.
Doesn't that stall the MPTCP stream until the peer reinjects at the MPTCP
level?
offset > 0 happens with a partially overlapping TCP retransmission. dsn
below ack_seq happens when the same range already arrived on another
subflow, so both are normal in lossy multipath setups.
The final tree after this patch is correct, but the intermediate commit is
not bisect safe. Should this hunk be folded into "mptcp: remove CB offset
field", or at least be called out in this commit message?
[ ... ]
> @@ -4885,11 +4887,23 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
> return work_done;
> }
>
> +#define CHK_CB_FIELD(mptcp_field, tcp_field) \
> + ({ \
> + BUILD_BUG_ON(offsetof(struct mptcp_skb_cb, mptcp_field) != \
> + offsetof(struct tcp_skb_cb, tcp_field)); \
> + BUILD_BUG_ON(offsetofend(struct mptcp_skb_cb, mptcp_field) != \
> + offsetofend(struct tcp_skb_cb, tcp_field)); \
> + })
> +
> void __init mptcp_proto_init(void)
> {
> struct mptcp_delegated_action *delegated;
> int cpu;
>
> + CHK_CB_FIELD(map_seq, seq);
> + CHK_CB_FIELD(end_seq, end_seq);
> + CHK_CB_FIELD(flags, tcp_flags);
[Severity: Low]
This doesn't look like a bug today, but there is a bit clash in this alias.
net/mptcp/protocol.h has:
#define MPTCP_SKB_CB_F_OFFSET 0x0100
include/net/tcp.h has:
#define TCPHDR_AE BIT(8)
TCPHDR_AE is part of both TCPHDR_FLAGS_MASK and TCPHDR_ACE.
CHK_CB_FIELD(flags, tcp_flags) makes mptcp_skb_cb.flags an intentional
alias of tcp_skb_cb.tcp_flags. mptcp_init_skb() sets MPTCP_SKB_CB_F_OFFSET
whenever offset is non-zero. Any code that later reads
TCP_SKB_CB(skb)->tcp_flags on an msk receive queue skb would then see the
AccECN AE bit set.
No current code reads tcp_flags on msk skbs. Would it make sense to move
MPTCP_SKB_CB_F_OFFSET to a bit outside TCPHDR_FLAGS_MASK, or to document
the overlap?
[ ... ]
> @@ -359,18 +360,18 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)
> while (*p) {
> parent = *p;
> skb1 = rb_to_skb(parent);
> - if (before64(seq, MPTCP_SKB_CB(skb1)->map_seq)) {
> + if (before(seq, MPTCP_SKB_CB(skb1)->map_seq)) {
> p = &parent->rb_left;
> continue;
> }
> - if (before64(seq, mptcp_end_dsn(skb1))) {
> - if (!after64(end_seq, mptcp_end_dsn(skb1))) {
> + if (before(seq, (u32)mptcp_end_dsn(skb1))) {
> + if (!after((u32)end_seq, (u32)mptcp_end_dsn(skb1))) {
> /* All the bits are present. Drop. */
> mptcp_drop(sk, skb);
> MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_DUPDATA);
> return;
> }
> - if (after64(seq, MPTCP_SKB_CB(skb1)->map_seq)) {
> + if (after(seq, MPTCP_SKB_CB(skb1)->map_seq)) {
> /* partial overlap:
> * | skb |
> * | skb1 |
[Severity: High]
mptcp_init_skb() sets map_seq64 to mptcp_subflow_get_mapped_dsn()
minus offset. So whenever MPTCP_SKB_CB_F_OFFSET is set,
MPTCP_SKB_CB(skb)->map_seq is (u32)mptcp_dsn(skb) - offset, not the
first DSN the skb actually carries. The offset prefix is not part of
this mapping. When the skb spans two DSS mappings, it can belong to an
earlier mapping that was already consumed on another subflow.
mptcp_data_queue_ofo() already uses (u32)mptcp_dsn(skb) for the
incoming seq and (u32)mptcp_end_dsn(skb1) for the right edge. The rbtree
walk, however, still compares seq against MPTCP_SKB_CB(skb1)->map_seq
for the left edge. Isn't that comparing two different things?
Take an skb1 in the OoO queue with offset=1000, dsn 6000 and end dsn
6100, so its map_seq is 5000. A new OoO skb carrying [5500, 5600) fails
the left branch test and passes before(seq, end dsn of skb1). Since 5600
is not after 6100, it is dropped as MPTCP_MIB_DUPDATA, but those bytes
are not in skb1.
If the new skb instead carries [5500, 6200), after(seq, map_seq) sends
it into the right subtree of skb1 even though its DSN is lower. Once
msk->ack_seq reaches 5500, __mptcp_ofo_queue() stops at skb1, because
after((u32)mptcp_dsn(skb1), ack_seq) is true. It never reaches the skb
holding 5500. The subflow has already TCP-acked that data, so doesn't
the msk receive side stall here?
mptcp_prune_ofo_queue() has the same problem when it compares
MPTCP_SKB_CB(in_skb)->map_seq with MPTCP_SKB_CB(skb)->map_seq. The stop
condition ends up shifted by the offset of either skb.
The removed lines already used map_seq here, so this probably comes
from "mptcp: remove CB offset field" earlier in the series. Since this
patch rewrites exactly these comparisons, should they use
(u32)mptcp_dsn() on both sides instead?
[ ... ]
> @@ -2212,7 +2214,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
> int copied = 0;
>
> skb_queue_walk_safe(&sk->sk_receive_queue, skb, tmp) {
> - u64 offset = *seq - MPTCP_SKB_CB(skb)->map_seq;
> + u32 offset = (u32)(*seq) - MPTCP_SKB_CB(skb)->map_seq;
> u32 data_len = skb->len - offset;
> u32 count;
> int err;
[Severity: Medium]
The commit message justifies the 32-bit offset here by saying that
copied_seq always falls inside or at the edge of the head skb. Does
that still hold after a DATA_FIN?
mptcp_check_data_fin() advances msk->ack_seq by one for the DATA_FIN,
clears msk->rcv_data_fin and sets RCV_SHUTDOWN. It leaves
msk->copied_seq at rcv_data_fin_seq. Neither subflow_check_data_avail()
nor __mptcp_move_skb() rejects a mapping at or beyond the DATA_FIN DSN,
so a peer can send data at rcv_data_fin_seq + 1. That matches
dsn == msk->ack_seq in __mptcp_move_skb(), bumps bytes_received and
ack_seq, and puts the skb on sk_receive_queue with map_seq one past
copied_seq.
The offset here then becomes 0xffffffff, so mptcp_eat_recv_skb() frees
the skb without updating bytes_consumed or copied_seq.
mptcp_recv_skb() does the same. After that, mptcp_data_avail() never
goes back to zero. SIOCINQ reports unread data after EOF, and
__mptcp_close() aborts through mptcp_do_fastclose() instead of closing
cleanly.
It gets worse if that skb starts at rcv_data_fin_seq and
mptcp_init_skb() sees offset == 1 because the first byte was discarded.
Then map_seq equals (u32)copied_seq, and the offset here is 0 instead
of 1. The discarded byte is copied to userspace, and bytes_consumed
ends up one larger than bytes_received, so mptcp_data_avail() wraps to
U64_MAX.
Separately, while rcv_data_fin is set, an in-sequence skb that spans
past rcv_data_fin_seq moves ack_seq beyond it. The
ack_seq == rcv_data_fin_seq test in mptcp_pending_data_fin() then
never matches.
As far as I can tell the old u64 offset wrapped the same way, so part
of this may predate the series. Still, this patch now relies on the
invariant for its safety argument. Should __mptcp_move_skb() drop or
trim data mapped beyond the DATA_FIN DSN, or is there another place
where this is meant to be enforced?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794663678.git.tanggeliang%40kylinos.cn
next prev parent reply other threads:[~2026-11-16 3:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 14:00 [PATCH mptcp-next v27 0/8] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-14 14:00 ` [PATCH mptcp-next v27 1/8] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-16 3:44 ` netdev-bot+sashiko
2026-11-14 14:00 ` [PATCH mptcp-next v27 2/8] selftests: mptcp: connect: check TFO SIOCINQ overflow Geliang Tang
2026-11-16 3:44 ` netdev-bot+sashiko
2026-11-14 14:00 ` [PATCH mptcp-next v27 3/8] mptcp: fix fallback dummy mapping anchor Geliang Tang
2026-11-14 14:01 ` [PATCH mptcp-next v27 4/8] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-14 14:01 ` [PATCH mptcp-next v27 5/8] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-16 3:44 ` netdev-bot+sashiko
2026-11-14 14:01 ` [PATCH mptcp-next v27 6/8] mptcp: remove CB offset field Geliang Tang
2026-11-14 14:29 ` sashiko-bot
2026-11-16 3:44 ` netdev-bot+sashiko
2026-11-14 14:01 ` [PATCH mptcp-next v27 7/8] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-14 14:41 ` sashiko-bot
2026-11-16 3:44 ` netdev-bot+sashiko [this message]
2026-11-14 14:01 ` [PATCH mptcp-next v27 8/8] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
2026-11-16 3:44 ` netdev-bot+sashiko
2026-11-14 15:52 ` [PATCH mptcp-next v27 0/8] 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=179480066832.3133.5753040360348134145@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.