From: Yingjie Wang <x-professor@outlook.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "mptcp@lists.linux.dev" <mptcp@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"corbet@lwn.net" <corbet@lwn.net>,
"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
"rdunlap@infradead.org" <rdunlap@infradead.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"edumazet@kernel.org" <edumazet@kernel.org>,
"ncardwell@google.com" <ncardwell@google.com>,
"gang.yan@linux.dev" <gang.yan@linux.dev>,
"kuniyu@google.com" <kuniyu@google.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"horms@kernel.org" <horms@kernel.org>,
"matttbe@kernel.org" <matttbe@kernel.org>,
"martineau@kernel.org" <martineau@kernel.org>,
"geliang@kernel.org" <geliang@kernel.org>,
"ycheng@google.com" <ycheng@google.com>,
"weiwan@google.com" <weiwan@google.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Gang Yan <yangang@kylinos.cn>
Subject: [PATCH net v2 2/2] mptcp: avoid wrapping blackhole timeout
Date: Sat, 14 Nov 2026 16:12:35 +0000 [thread overview]
Message-ID: <070c69fa36f83fe47a5eb6d1434f543dabe930e7.1794672619.git.x-professor@outlook.com> (raw)
In-Reply-To: <cover.1794672619.git.x-professor@outlook.com>
mptcp_active_should_disable() calculates the active-disable interval as
multiplier * blackhole_timeout * HZ. Since all operands are 32-bit, a
large blackhole_timeout can wrap the delay even on 64-bit kernels and
make active MPTCP available again while the blackhole is still present.
For example, with HZ=1000, a timeout of 6912213 seconds and the maximum
multiplier of 64 should produce 442,381,632,000 jiffies, but the current
calculation truncates it to 512 jiffies.
This issue was found using a static analysis tool. A loopback reproducer
induced 12 MPTCP blackholes and waited 1.2 seconds before opening another
connection. In the v1 arithmetic-only test, the unpatched kernel retried
MP_CAPABLE, while the fixed kernel used TCP fallback directly. The
reproducer required neither kernel modifications nor fault injection.
Compute the interval in u64 and cap it at MAX_JIFFY_OFFSET before adding
it to the saved timestamp. The multiplier remains limited to 64, while
the separate cap keeps the delay within the safe jiffies comparison range
on 32-bit systems. Preserve the existing sysctl input range and backoff
for representable intervals.
On the v2 kernel, the loopback blackhole reproducer completed all 12
clients and the probe used TCP fallback directly instead of retrying
MP_CAPABLE.
Fixes: 27069e7cb3d1 ("mptcp: disable active MPTCP in case of blackhole")
Cc: stable@vger.kernel.org
Reviewed-by: Gang Yan <yangang@kylinos.cn>
Signed-off-by: Yingjie Wang <x-professor@outlook.com>
---
net/mptcp/ctrl.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index 63c5747f0f63..0b10e94e7f43 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -487,6 +487,7 @@ bool mptcp_active_should_disable(struct sock *ssk)
unsigned long timeout;
int disable_times;
int multiplier;
+ u64 delay;
pernet = mptcp_get_pernet(net);
blackhole_timeout = READ_ONCE(pernet->blackhole_timeout);
@@ -501,12 +502,17 @@ bool mptcp_active_should_disable(struct sock *ssk)
/* Paired with smp_mb__before_atomic() in mptcp_active_disable() */
smp_rmb();
- /* Limit timeout to max: 2^6 * initial timeout */
+ /* Limit the backoff multiplier to 64. */
multiplier = 1 << min(disable_times - 1, 6);
+ delay = (u64)multiplier * blackhole_timeout * HZ;
- /* Paired with the WRITE_ONCE() in mptcp_active_disable(). */
+ /*
+ * Cap the delay for safe jiffies comparisons on 32-bit systems.
+ * The timestamp read is paired with WRITE_ONCE() in
+ * mptcp_active_disable().
+ */
timeout = READ_ONCE(pernet->active_disable_stamp) +
- multiplier * blackhole_timeout * HZ;
+ min(delay, MAX_JIFFY_OFFSET);
return time_before(jiffies, timeout);
}
--
2.43.0
prev parent reply other threads:[~2026-11-14 16:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 16:12 [PATCH net v2 0/2] tcp/mptcp: prevent blackhole timeout arithmetic wraparound Yingjie Wang
2026-11-14 16:12 ` [PATCH net v2 1/2] tcp: avoid wrapping Fast Open blackhole timeout Yingjie Wang
2026-11-14 16:12 ` Yingjie Wang [this message]
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=070c69fa36f83fe47a5eb6d1434f543dabe930e7.1794672619.git.x-professor@outlook.com \
--to=x-professor@outlook.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gang.yan@linux.dev \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
--cc=weiwan@google.com \
--cc=yangang@kylinos.cn \
--cc=ycheng@google.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
all inboxes | Powered by JetHome®