[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241204034946.10794-1-moyuanhao3676@163.com>
Date: Wed, 4 Dec 2024 11:49:46 +0800
From: MoYuanhao <moyuanhao3676@....com>
To: edumazet@...gle.com,
davem@...emloft.net,
dsahern@...nel.org,
kuba@...nel.org,
pabeni@...hat.com,
horms@...nel.org
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
MoYuanhao <moyuanhao3676@....com>
Subject: [PATCH net-next] tcp: Check space before adding MPTCP options
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@....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
Powered by blists - more mailing lists