Skip to content

Commit cd572d5

Browse files
committed
mptcp: Fix data stream corruption in the address announcement
bugfix related to other mptcp CVEs commit-author Arthur Mongodin <[email protected]> commit 2c1f97a 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]> (cherry picked from commit 2c1f97a) Signed-off-by: Jonathan Maple <[email protected]>
1 parent f0f5398 commit cd572d5

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
@@ -652,6 +652,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
652652
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
653653
bool drop_other_suboptions = false;
654654
unsigned int opt_size = *size;
655+
struct mptcp_addr_info addr;
655656
bool echo;
656657
int len;
657658

@@ -660,7 +661,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
660661
*/
661662
if (!mptcp_pm_should_add_signal(msk) ||
662663
(opts->suboptions & (OPTION_MPTCP_MPJ_ACK | OPTION_MPTCP_MPC_ACK)) ||
663-
!mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &opts->addr,
664+
!mptcp_pm_add_addr_signal(msk, skb, opt_size, remaining, &addr,
664665
&echo, &drop_other_suboptions))
665666
return false;
666667

@@ -673,7 +674,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
673674
else if (opts->suboptions & OPTION_MPTCP_DSS)
674675
return false;
675676

676-
len = mptcp_add_addr_len(opts->addr.family, echo, !!opts->addr.port);
677+
len = mptcp_add_addr_len(addr.family, echo, !!addr.port);
677678
if (remaining < len)
678679
return false;
679680

@@ -690,6 +691,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
690691
opts->ahmac = 0;
691692
*size -= opt_size;
692693
}
694+
opts->addr = addr;
693695
opts->suboptions |= OPTION_MPTCP_ADD_ADDR;
694696
if (!echo) {
695697
opts->ahmac = add_addr_generate_hmac(msk->local_key,

0 commit comments

Comments
 (0)