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-next v22 6/8] mptcp: remove CB offset field
Date: Fri, 06 Nov 2026 12:12:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-201391@kernel.org> (raw)
In-Reply-To: <7c1d46fbe47ef7510fa106d0920580d64baa7187.1793964796.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mptcp: broken skb pull and error path in mptcp_init_skb() and
  caller
--

commit 37ab52009b6bb1043a1c621a00f409a14fa73507
Author: Paolo Abeni <pabeni@redhat.com>

mptcp: remove CB offset field

This commit replaces the per-skb MPTCP control buffer offset field with an
msk-level copied_seq counter and pulls already-consumed prefix bytes when an
skb spans a DSS mapping boundary in mptcp_init_skb().

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 74a94264111dc..cedc91accc6b4 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
[ ... ]
> @@ -415,25 +414,38 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)
>  	skb_set_owner_r(skb, sk);
>  }
>  
> -static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset,
> -			   int copy_len)
> +static bool mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset)
>  {
>  	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
>  	bool has_rxtstamp = TCP_SKB_CB(skb)->has_rxtstamp;
>  
> +	/* Detect mapping boundary: skb spans multiple mappings */
> +	if (unlikely(offset > 0 &&
> +		     before(TCP_SKB_CB(skb)->seq - subflow->ssn_offset,
> +			    subflow->map_subflow_seq))) {
> +		if (offset >= skb->len || !pskb_pull(skb, offset)) {
> +			WARN_ON_ONCE(1);
> +			sk_eat_skb(ssk, skb);
> +			return false;
> +		}
> +		offset = 0;
> +	}
> +
>  	/* the skb map_seq accounts for the skb offset:
>  	 * mptcp_subflow_get_mapped_dsn() is based on the current tp->copied_seq
>  	 * value
>  	 */
> -	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)->map_seq = mptcp_subflow_get_mapped_dsn(subflow) -
> +				     offset;
> +	MPTCP_SKB_CB(skb)->end_seq = MPTCP_SKB_CB(skb)->map_seq + skb->len;
>  	MPTCP_SKB_CB(skb)->has_rxtstamp = has_rxtstamp;
>  
>  	__skb_unlink(skb, &ssk->sk_receive_queue);
>  
>  	skb_ext_reset(skb);
>  	skb_dst_drop(skb);
> +
> +	return true;
>  }
[ ... ]
> @@ -855,7 +863,8 @@ static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk,
>  		if (offset < skb->len) {
>  			size_t len = skb->len - offset;
>  
> -			mptcp_init_skb(ssk, skb, offset, len);
> +			if (!mptcp_init_skb(ssk, skb, offset))
> +				continue;
>  
>  			if (own_msk) {
>  				mptcp_subflow_lend_fwdmem(subflow, skb);

[Severity: High]
Does jumping via continue when mptcp_init_skb() returns false evaluate an
uninitialized more_data_avail variable and corrupt tp->copied_seq?

In __mptcp_move_skbs_from_subflow(), more_data_avail is declared without an
initializer and is only assigned at the end of the do-while body:

net/mptcp/protocol.c:__mptcp_move_skbs_from_subflow() {
	...
	bool more_data_avail;
	...
	do {
		...
		if (offset < skb->len) {
			size_t len = skb->len - offset;

			if (!mptcp_init_skb(ssk, skb, offset))
				continue;
			...
			seq += len;
			...
		}
		...
		WRITE_ONCE(tp->copied_seq, seq);
		more_data_avail = mptcp_subflow_data_available(ssk);

	} while (more_data_avail);
}

When pskb_pull() fails in mptcp_init_skb() (for example, when
__pskb_pull_tail() -> pskb_expand_head(..., GFP_ATOMIC) fails under memory
pressure on a nonlinear or cloned skb), mptcp_init_skb() triggers a
WARN_ON_ONCE(1), calls sk_eat_skb(ssk, skb), and returns false.  On the first
loop iteration, continue jumps straight to while (more_data_avail) and reads
more_data_avail uninitialized.  Because sk_eat_skb() already removed the skb
while continue skips updating tp->copied_seq and calling
mptcp_subflow_data_available(ssk), a subsequent iteration will compute a
wrapped offset = seq - TCP_SKB_CB(skb)->seq >= skb->len on the next skb,
eat it, and trigger a false mptcp_dss_corruption() reset.

In addition, when pskb_pull(skb, offset) succeeds on a nonlinear skb by
expanding its head via pskb_expand_head() and pulling all skb_headlen(skb)
bytes, skb_end_offset(skb) grows without updating skb->truesize while skb->sk
is still ssk.  If that skb is later coalesced as the from skb in
mptcp_try_coalesce() -> skb_try_coalesce(), delta = from->truesize -
SKB_TRUESIZE(skb_end_offset(from)) can become smaller than from->len (or
negative), firing WARN_ON_ONCE(delta < len) and corrupting to->truesize and
sk->sk_rmem_alloc.

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

  reply	other threads:[~2026-11-06 12:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 11:36 [PATCH mptcp-next v22 0/8] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-06 11:36 ` [PATCH mptcp-net v22 1/8] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-06 11:36 ` [PATCH mptcp-next v22 2/8] selftests: mptcp: connect: check TFO SIOCINQ overflow Geliang Tang
2026-11-06 11:51   ` sashiko-bot
2026-11-06 11:36 ` [PATCH mptcp-net v22 3/8] mptcp: fix fallback dummy mapping anchor Geliang Tang
2026-11-06 11:37 ` [PATCH mptcp-next v22 4/8] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-06 11:37 ` [PATCH mptcp-next v22 5/8] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-06 11:37 ` [PATCH mptcp-next v22 6/8] mptcp: remove CB offset field Geliang Tang
2026-11-06 12:12   ` sashiko-bot [this message]
2026-11-06 11:37 ` [PATCH mptcp-next v22 7/8] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-06 12:04   ` sashiko-bot
2026-11-06 11:37 ` [PATCH mptcp-next v22 8/8] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
2026-11-06 13:59 ` [PATCH mptcp-next v22 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=sashiko-outbox-201391@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.