All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next 3/3] mptcp: options: reset parsing in case of invalidity
Date: Thu, 03 Sep 2026 11:38:00 +0000	[thread overview]
Message-ID: <20260903113800.968991F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260903-mptcp-mib-inval-opt-v1-3-84a553c552b6@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The `break` statement inside `mptcp_get_options` incorrectly exits the `switch` statement instead of the `while` loop, causing `length` and `ptr` to become desynchronized, leading to an infinite loop, out-of-bounds reads, and MPTCP option smuggling.
--

commit 60e4bc5aa7cfc08049c3062323eeae263a824439
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: options: reset parsing in case of invalidity

When an invalid option is detected, it is safer to drop any previously
parsed MPTCP options. This ensures a fallback to TCP or a subflow reject
instead of just ignoring the currently parsed option.

> diff --git a/net/mptcp/options.c b/net/mptcp/options.c
> index aaaabcab0f8f9..b6d2e39f8464a 100644
> --- a/net/mptcp/options.c
> +++ b/net/mptcp/options.c
[ ... ]
> @@ -461,9 +456,12 @@ void mptcp_get_options(const struct sock *sk, const struct sk_buff *skb,
>  				return;
>  			if (opsize > length)
>  				return;	/* don't parse partial options */
> -			if (opcode == TCPOPT_MPTCP)
> -				mptcp_parse_option(sk, skb, ptr, opsize,
> -						   mp_opt);
> +			if (opcode == TCPOPT_MPTCP &&
> +			    !mptcp_parse_option(sk, skb, ptr, opsize, mp_opt)) {
> +				/* invalid option, drop previously parsed opt */
> +				*(u32 *)&mp_opt->status = 0;
> +				break;

[Severity: High]
Does this break statement exit the switch rather than the while loop?

If this only exits the switch block, it will skip the pointer and length
updates that occur at the end of the default case:

    ptr += opsize - 2;
    length -= opsize;

Since length is not decremented when breaking here, the while (length > 0)
loop will continue indefinitely. The ptr keeps advancing by 2 bytes on each
subsequent iteration from reading opcode and opsize. Could this lead to an
infinite loop and out-of-bounds reads into the TCP payload?

Additionally, could this allow an attacker to smuggle MPTCP options by
placing them in the TCP payload after an invalid option that triggers this
break? Because length is never updated, the parser might treat the TCP payload
as an extension of the TCP options, bypassing inspection that only checks the
TCP header.

> +			}
>  			ptr += opsize - 2;
>  			length -= opsize;
>  		}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903-mptcp-mib-inval-opt-v1-0-84a553c552b6@kernel.org?part=3

  reply	other threads:[~2026-09-03 11:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 11:24 [PATCH mptcp-next 0/3] mptcp: options: MIB for invalid & drop suboptions Matthieu Baerts (NGI0)
2026-09-03 11:24 ` [PATCH mptcp-next 1/3] mptcp: options: use a dedicated bit for csum reqd Matthieu Baerts (NGI0)
2026-09-03 11:24 ` [PATCH mptcp-next 2/3] mptcp: options: track invalid suboptions Matthieu Baerts (NGI0)
2026-09-03 11:24 ` [PATCH mptcp-next 3/3] mptcp: options: reset parsing in case of invalidity Matthieu Baerts (NGI0)
2026-09-03 11:38   ` sashiko-bot [this message]
2026-09-03 14:18     ` Matthieu Baerts
2026-09-03 12:28 ` [PATCH mptcp-next 0/3] mptcp: options: MIB for invalid & drop suboptions 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=20260903113800.968991F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=matttbe@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.