Skip to content

Commit 4375eee

Browse files
Arthur Mongodingregkh
authored andcommitted
mptcp: Fix data stream corruption in the address announcement
commit 2c1f97a52cb827a5f2768e67a9dddffae1ed47ab upstream. Because of the size restriction in the TCP options space, the MPTCP ADD_ADDR option is exclusive and cannot be sent with other MPTCP ones. For this reason, in the linked mptcp_out_options structure, group of fields linked to different options are part of the same union. There is a case where the mptcp_pm_add_addr_signal() function can modify opts->addr, but not ended up sending an ADD_ADDR. Later on, back in mptcp_established_options, other options will be sent, but with unexpected data written in other fields due to the union, e.g. in opts->ext_copy. This could lead to a data stream corruption in the next packet. Using an intermediate variable, prevents from corrupting previously established DSS option. The assignment of the ADD_ADDR option parameters is now done once we are sure this ADD_ADDR option can be set in the packet, e.g. after having dropped other suboptions. Fixes: 1bff1e4 ("mptcp: optimize out option generation") Cc: [email protected] Suggested-by: Paolo Abeni <[email protected]> Signed-off-by: Arthur Mongodin <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> [ Matt: the commit message has been updated: long lines splits and some clarifications. ] Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/20250314-net-mptcp-fix-data-stream-corr-sockopt-v1-1-122dbb249db3@kernel.org Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 19e85e0 commit 4375eee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/mptcp/options.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
649649
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
650650
bool drop_other_suboptions = false;
651651
unsigned int opt_size = *size;
652+
struct mptcp_addr_info addr;
652653
bool echo;
653654
int len;
654655

@@ -657,7 +658,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
657658
*/
658659
if (!mptcp_pm_should_add_signal(msk) ||
659660
(opts->suboptions & (OPTION_MPTCP_MPJ_ACK | OPTION_MPTCP_MPC_ACK)) ||
660-
!mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &opts->addr,
661+
!mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &addr,
661662
&echo, &drop_other_suboptions))
662663
return false;
663664

@@ -670,7 +671,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
670671
else if (opts->suboptions & OPTION_MPTCP_DSS)
671672
return false;
672673

673-
len = mptcp_add_addr_len(opts->addr.family, echo, !!opts->addr.port);
674+
len = mptcp_add_addr_len(addr.family, echo, !!addr.port);
674675
if (remaining < len)
675676
return false;
676677

@@ -687,6 +688,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
687688
opts->ahmac = 0;
688689
*size -= opt_size;
689690
}
691+
opts->addr = addr;
690692
opts->suboptions |= OPTION_MPTCP_ADD_ADDR;
691693
if (!echo) {
692694
opts->ahmac = add_addr_generate_hmac(msk->local_key,

0 commit comments

Comments
 (0)