From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v3 05/11] ms/mptcp: close TOCTOU race while computing rcv_wnd
Date: Mon, 16 Nov 2026 22:05:57 +0200 [thread overview]
Message-ID: <20261116204557.718500-6-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261116204557.718500-1-eva.kurchatova@virtuozzo.com>
From: Paolo Abeni <pabeni@redhat.com>
The MPTCP output path access locklessly the MPTCP-level ack_seq
in multiple times, using possibly different values for the data_ack
in the DSS option and to compute the announced rcv wnd for the same
packet.
Refactor the cote to avoid inconsistencies which may confuse the
peer. Also ensure that the MPTCP level rcv wnd is updated only when
the egress packet actually contains a DSS ack.
Fixes: fa3fe2b15031 ("mptcp: track window announced to peer")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260602-net-mptcp-misc-fixes-7-1-rc7-v2-3-856831229976@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 8ab24fdebc369c0dfb90f82c1650b1e66662bb45)
https://virtuozzo.atlassian.net/browse/VSTOR-153491
Feature: fix ms/net
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
net/mptcp/options.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index bdc2b71a89e7..51978cf24f23 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -577,7 +577,6 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
struct mptcp_ext *mpext;
unsigned int ack_size;
bool ret = false;
- u64 ack_seq;
opts->csum_reqd = READ_ONCE(msk->csum_enabled);
mpext = skb ? mptcp_get_ext(skb) : NULL;
@@ -608,14 +607,11 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
return ret;
}
- ack_seq = READ_ONCE(msk->ack_seq);
if (READ_ONCE(msk->use_64bit_ack)) {
ack_size = TCPOLEN_MPTCP_DSS_ACK64;
- opts->ext_copy.data_ack = ack_seq;
opts->ext_copy.ack64 = 1;
} else {
ack_size = TCPOLEN_MPTCP_DSS_ACK32;
- opts->ext_copy.data_ack32 = (uint32_t)ack_seq;
opts->ext_copy.ack64 = 0;
}
opts->ext_copy.use_ack = 1;
@@ -1302,19 +1298,14 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
return true;
}
-static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
+static u64 mptcp_set_rwin(struct mptcp_sock *msk, struct tcp_sock *tp,
+ struct tcphdr *th, u64 ack_seq)
{
const struct sock *ssk = (const struct sock *)tp;
- struct mptcp_subflow_context *subflow;
- u64 ack_seq, rcv_wnd_old, rcv_wnd_new;
- struct mptcp_sock *msk;
+ u64 rcv_wnd_old, rcv_wnd_new;
u32 new_win;
u64 win;
- subflow = mptcp_subflow_ctx(ssk);
- msk = mptcp_sk(subflow->conn);
-
- ack_seq = READ_ONCE(msk->ack_seq);
rcv_wnd_new = ack_seq + tp->rcv_wnd;
rcv_wnd_old = atomic64_read(&msk->rcv_wnd_sent);
@@ -1366,7 +1357,7 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
update_wspace:
WRITE_ONCE(msk->old_wspace, tp->rcv_wnd);
- subflow->rcv_wnd_sent = rcv_wnd_new;
+ return rcv_wnd_new;
}
static void mptcp_track_rwin(struct tcp_sock *tp)
@@ -1478,13 +1469,25 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
*ptr++ = mptcp_option(MPTCPOPT_DSS, len, 0, flags);
if (mpext->use_ack) {
+ struct mptcp_sock *msk;
+ u64 ack_seq;
+
+ /* DSS option is set only by mptcp_established_options,
+ * the caller is __tcp_transmit_skb() and ssk is always
+ * not NULL.
+ */
+ subflow = mptcp_subflow_ctx(ssk);
+ msk = mptcp_sk(subflow->conn);
+ ack_seq = READ_ONCE(msk->ack_seq);
if (mpext->ack64) {
- put_unaligned_be64(mpext->data_ack, ptr);
+ put_unaligned_be64(ack_seq, ptr);
ptr += 2;
} else {
- put_unaligned_be32(mpext->data_ack32, ptr);
+ put_unaligned_be32(ack_seq, ptr);
ptr += 1;
}
+ subflow->rcv_wnd_sent = mptcp_set_rwin(msk, tp, th,
+ ack_seq);
}
if (mpext->use_map) {
@@ -1712,9 +1715,6 @@ void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
i += 4;
}
}
-
- if (tp)
- mptcp_set_rwin(tp, th);
}
__be32 mptcp_get_reset_option(const struct sk_buff *skb)
--
2.56.1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-16 20:47 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 20:05 [Devel] [PATCH hci-8.1 v3 00/11] ms/mptcp: stability fixes Eva Kurchatova
2026-11-16 20:05 ` [Devel] [PATCH hci-8.1 v3 01/11] ms/mptcp: fix retransmission loop when csum is enabled Eva Kurchatova
2026-11-16 20:50 ` no-reply
2026-11-16 20:05 ` [Devel] [PATCH hci-8.1 v3 02/11] ms/mptcp: move the retrans loop to a separate helper Eva Kurchatova
2026-11-16 20:50 ` no-reply
2026-11-16 20:05 ` [Devel] [PATCH hci-8.1 v3 03/11] ms/mptcp: move the stale logic out of retrans scheduler Eva Kurchatova
2026-11-16 20:52 ` no-reply
2026-11-17 11:25 ` Konstantin Khorenko
2026-11-16 20:05 ` [Devel] [PATCH hci-8.1 v3 04/11] ms/mptcp: let the retrans scheduler do its job Eva Kurchatova
2026-11-16 20:55 ` no-reply
2026-11-16 20:05 ` Eva Kurchatova [this message]
2026-11-16 20:53 ` [Devel] [PATCH hci-8.1 v3 05/11] ms/mptcp: close TOCTOU race while computing rcv_wnd no-reply
2026-11-16 20:05 ` [Devel] [PATCH hci-8.1 v3 06/11] ms/mptcp: allow subflow rcv wnd to shrink Eva Kurchatova
2026-11-16 20:56 ` no-reply
2026-11-16 20:05 ` [Devel] [PATCH hci-8.1 v3 07/11] ms/mptcp: cleanup fallback dummy mapping generation Eva Kurchatova
2026-11-16 20:58 ` no-reply
2026-11-16 20:06 ` [Devel] [PATCH hci-8.1 v3 08/11] ms/mptcp: explicitly drop over memory limits Eva Kurchatova
2026-11-16 20:58 ` no-reply
2026-11-16 20:06 ` [Devel] [PATCH hci-8.1 v3 09/11] ms/mptcp: implemented OoO queue pruning Eva Kurchatova
2026-11-16 21:00 ` no-reply
2026-11-16 20:06 ` [Devel] [PATCH hci-8.1 v3 10/11] ms/mptcp: being below memory limit is a likely() condition Eva Kurchatova
2026-11-16 20:59 ` no-reply
2026-11-16 20:06 ` [Devel] [PATCH hci-8.1 v3 11/11] ms/mptcp: avoid pruning for OoW data Eva Kurchatova
2026-11-16 21:00 ` no-reply
2026-11-16 20:58 ` [Devel] [PATCH hci-8.1 v3 00/11] ms/mptcp: stability fixes Eva Kurchatova (Virtuozzo)
2026-11-17 11:25 ` Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116204557.718500-6-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox