mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] tcp: Check space before adding MPTCP options
@ 2024-12-04  8:58 MoYuanhao
  2024-12-04 11:01 ` Matthieu Baerts
  0 siblings, 1 reply; 8+ messages in thread
From: MoYuanhao @ 2024-12-04  8:58 UTC (permalink / raw)
  To: edumazet, davem, dsahern, kuba, pabeni, horms
  Cc: netdev, linux-kernel, matttbe, martineau, geliang, MoYuanhao

Ensure enough space before adding MPTCP options in tcp_syn_options()
Added a check to verify sufficient remaining space
before inserting MPTCP options in SYN packets.
This prevents issues when space is insufficient.

Signed-off-by: MoYuanhao <moyuanhao3676@163.com>
---
 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 5485a70b5fe5..0e5b9a654254 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;
+			}
 		}
 	}
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH net-next] tcp: Check space before adding MPTCP options
@ 2024-12-04  3:49 MoYuanhao
  2024-12-04  7:35 ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: MoYuanhao @ 2024-12-04  3:49 UTC (permalink / raw)
  To: edumazet, davem, dsahern, kuba, pabeni, horms
  Cc: netdev, linux-kernel, MoYuanhao

Ensure enough space before adding MPTCP options in tcp_syn_options()
Added a check to verify sufficient remaining space
before inserting MPTCP options in SYN packets.
This prevents issues when space is insufficient.

Signed-off-by: MoYuanhao <moyuanhao3676@163.com>
---
 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 5485a70b5fe5..0e5b9a654254 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;
+			}
 		}
 	}
 
-- 
2.25.1


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

end of thread, other threads:[~2024-12-05 10:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-04  8:58 [PATCH net-next] tcp: Check space before adding MPTCP options MoYuanhao
2024-12-04 11:01 ` Matthieu Baerts
2024-12-05  7:31   ` Mo Yuanhao
2024-12-05  7:54     ` Eric Dumazet
2024-12-05  9:24       ` Matthieu Baerts
2024-12-05 10:13         ` MoYuanhao
  -- strict thread matches above, loose matches on Subject: below --
2024-12-04  3:49 MoYuanhao
2024-12-04  7:35 ` Eric Dumazet

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

all inboxes | Powered by JetHome®