Skip to content

Commit 2c1f97a

Browse files
Arthur MongodinPaolo Abeni
authored andcommitted
mptcp: Fix data stream corruption in the address announcement
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: stable@vger.kernel.org Suggested-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Arthur Mongodin <amongodin@randorisec.fr> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> [ Matt: the commit message has been updated: long lines splits and some clarifications. ] Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250314-net-mptcp-fix-data-stream-corr-sockopt-v1-1-122dbb249db3@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent f31b6fb commit 2c1f97a

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

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

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

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

@@ -689,6 +690,7 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct sk_buff *
689690
opts->ahmac = 0;
690691
*size -= opt_size;
691692
}
693+
opts->addr = addr;
692694
opts->suboptions |= OPTION_MPTCP_ADD_ADDR;
693695
if (!echo) {
694696
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDRTX);

0 commit comments

Comments
 (0)