Skip to content

Commit e681c5a

Browse files
MoYuanhaogregkh
authored andcommitted
tcp: check space before adding MPTCP SYN options
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]>
1 parent 37a0e2b commit e681c5a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv4/tcp_output.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,10 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb,
827827
unsigned int size;
828828

829829
if (mptcp_syn_options(sk, skb, &size, &opts->mptcp)) {
830-
opts->options |= OPTION_MPTCP;
831-
remaining -= size;
830+
if (remaining >= size) {
831+
opts->options |= OPTION_MPTCP;
832+
remaining -= size;
833+
}
832834
}
833835
}
834836

0 commit comments

Comments
 (0)