Skip to content

Commit

Permalink
tcp: check space before adding MPTCP SYN options
Browse files Browse the repository at this point in the history
commit 06d64ab upstream.

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 <[email protected]>
Fixes: cec37a6 ("mptcp: Handle MP_CAPABLE options for outgoing connections")
Cc: [email protected]
Acked-by: Matthieu Baerts (NGI0) <[email protected]>
[ Matt: Add Fixes, cc Stable, update Description ]
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
MoYuanhao authored and gregkh committed Dec 19, 2024
1 parent 37a0e2b commit e681c5a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,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;
}
}
}

Expand Down

0 comments on commit e681c5a

Please sign in to comment.