Message ID | 20241204034946.10794-1-moyuanhao3676@163.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] tcp: Check space before adding MPTCP options | expand |
On Wed, Dec 4, 2024 at 5:07 AM MoYuanhao <moyuanhao3676@163.com> wrote: > > 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> > --- If this is happening, then this would be a bug, and a Fixes: tag would be needed. If this is not yet happening, but would happen in the future, this patch would hide a bug. You forgot to CC MPTCP maintainers and reviewers ? Matthieu Baerts <matttbe@kernel.org> (maintainer:NETWORKING [MPTCP]) Mat Martineau <martineau@kernel.org> (maintainer:NETWORKING [MPTCP]) Geliang Tang <geliang@kernel.org> (reviewer:NETWORKING [MPTCP]) In my opinion, we should pass @remaining to mptcp_syn_options() arguments to avoid side effects.
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; + } } }
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(-)