MPTCP Linux Development
 help / color / mirror / Atom feed
* [PATCH net] tcp: check space before adding MPTCP SYN options
@ 2024-12-09 12:28 Matthieu Baerts (NGI0)
  2024-12-09 13:34 ` Eric Dumazet
  2024-12-11  2:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-12-09 12:28 UTC (permalink / raw)
  To: mptcp, Eric Dumazet, David S. Miller, David Ahern, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Florian Westphal, Christoph Paasch,
	Mat Martineau, Geliang Tang
  Cc: netdev, linux-kernel, MoYuanhao, stable, Matthieu Baerts (NGI0)

From: MoYuanhao <moyuanhao3676@163.com>

Ensure there is enough space before adding MPTCP options in
tcp_syn_options().

Without this check, 'remaining' could underflow, and causes issues. If
there is not enough space, MPTCP should not be used.

Signed-off-by: MoYuanhao <moyuanhao3676@163.com>
Fixes: cec37a6e41aa ("mptcp: Handle MP_CAPABLE options for outgoing connections")
Cc: stable@vger.kernel.org
Acked-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
[ Matt: Add Fixes, cc Stable, update Description ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/ipv4/tcp_output.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 5485a70b5fe5a6039d19f4321c3c2ec8ecc6ffea..0e5b9a654254b32907ee9739f3443791104bd611 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -883,8 +883,10 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,
 		unsigned int size;
 
 		if (mptcp_syn_options(sk, skb, &size, &opts->mptcp)) {
-			opts->options |= OPTION_MPTCP;
-			remaining -= size;
+			if (remaining >= size) {
+				opts->options |= OPTION_MPTCP;
+				remaining -= size;
+			}
 		}
 	}
 

---
base-commit: 09310cfd4ea5c3ab2c7a610420205e0a1660bf7e
change-id: 20241209-net-mptcp-check-space-syn-5694196ffb5f

Best regards,
-- 
Matthieu Baerts (NGI0) <matttbe@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] tcp: check space before adding MPTCP SYN options
  2024-12-09 12:28 [PATCH net] tcp: check space before adding MPTCP SYN options Matthieu Baerts (NGI0)
@ 2024-12-09 13:34 ` Eric Dumazet
  2024-12-11  2:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-12-09 13:34 UTC (permalink / raw)
  To: Matthieu Baerts (NGI0)
  Cc: mptcp, David S. Miller, David Ahern, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Florian Westphal, Christoph Paasch, Mat Martineau,
	Geliang Tang, netdev, linux-kernel, MoYuanhao, stable

On Mon, Dec 9, 2024 at 1:28 PM Matthieu Baerts (NGI0)
<matttbe@kernel.org> wrote:
>
> From: MoYuanhao <moyuanhao3676@163.com>
>
> Ensure there is enough space before adding MPTCP options in
> tcp_syn_options().
>
> Without this check, 'remaining' could underflow, and causes issues. If
> there is not enough space, MPTCP should not be used.
>
> Signed-off-by: MoYuanhao <moyuanhao3676@163.com>
> Fixes: cec37a6e41aa ("mptcp: Handle MP_CAPABLE options for outgoing connections")
> Cc: stable@vger.kernel.org
> Acked-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> [ Matt: Add Fixes, cc Stable, update Description ]
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] tcp: check space before adding MPTCP SYN options
  2024-12-09 12:28 [PATCH net] tcp: check space before adding MPTCP SYN options Matthieu Baerts (NGI0)
  2024-12-09 13:34 ` Eric Dumazet
@ 2024-12-11  2:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-11  2:40 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: mptcp, edumazet, davem, dsahern, kuba, pabeni, horms, fw, cpaasch,
	martineau, geliang, netdev, linux-kernel, moyuanhao3676, stable

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 09 Dec 2024 13:28:14 +0100 you wrote:
> From: MoYuanhao <moyuanhao3676@163.com>
> 
> Ensure there is enough space before adding MPTCP options in
> tcp_syn_options().
> 
> Without this check, 'remaining' could underflow, and causes issues. If
> there is not enough space, MPTCP should not be used.
> 
> [...]

Here is the summary with links:
  - [net] tcp: check space before adding MPTCP SYN options
    https://git.kernel.org/netdev/net/c/06d64ab46f19

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-11  2:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 12:28 [PATCH net] tcp: check space before adding MPTCP SYN options Matthieu Baerts (NGI0)
2024-12-09 13:34 ` Eric Dumazet
2024-12-11  2:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox