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>,
"joel.granados@kernel.org" <joel.granados@kernel.org>
Subject: [PATCH net-next v4 2/2] mptcp: avoid wrapping blackhole timeout
Date: Mon, 23 Nov 2026 09:04:36 +0000 [thread overview]
Message-ID: <61910493c920d138cd33da5ae5fc7947a64fba05.1795424547.git.x-professor@outlook.com> (raw)
In-Reply-To: <cover.1795424546.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.
With HZ=1000 and the maximum multiplier of 64, a timeout of 67109 seconds
should produce 4,294,976,000 jiffies (about 50 days), but the calculation
truncates it to 8,704 jiffies (8.7 seconds).
This issue was found using a static analysis tool. It was confirmed with
a loopback reproducer that induces 12 MPTCP blackholes and opens another
connection 10 seconds later: with a 67109 second timeout, the unpatched
kernel retried MP_CAPABLE. The reproducer needs neither kernel
modifications nor error injection.
Compute the interval in u64 and cap it at MAX_JIFFY_OFFSET before adding
it to the saved timestamp. On 32-bit kernels, the cap keeps the interval
within the range that time_before() can compare, limiting the longest
backoff to about 12.4 days at HZ=1000.
Also limit the writable initial timeout to one day, matching
tcp_fastopen_blackhole_timeout_sec. Writes above 86400 seconds, which
were previously accepted, now fail with -EINVAL and leave the current
value unchanged. The default remains 3600 seconds, and zero still
disables blackhole detection.
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Yingjie Wang <x-professor@outlook.com>
---
Changes since v3:
- Combine the arithmetic fix and one-day input limit, as requested
by Matthieu; name the bound one_day_secs.
- Drop Fixes, as requested by Matthieu.
- Leave the existing comments unchanged, as requested by Matthieu.
- Drop Gang Yan's Reviewed-by because it covered only the arithmetic
fix; retain Eric's Suggested-by for the input limit.
- Move the test notes below the separator, as requested by Eric.
- Rebase on current net-next.
Testing: the loopback reproducer fell back to TCP without retrying
MP_CAPABLE, and the sysctl accepted 86400 and rejected 86401. The
MPTCP selftests were not run.
Documentation/networking/mptcp-sysctl.rst | 1 +
net/mptcp/ctrl.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/Documentation/networking/mptcp-sysctl.rst b/Documentation/networking/mptcp-sysctl.rst
index b9b5f58e0625..ca00253c8ae9 100644
--- a/Documentation/networking/mptcp-sysctl.rst
+++ b/Documentation/networking/mptcp-sysctl.rst
@@ -63,6 +63,7 @@ blackhole_timeout - INTEGER (seconds)
blackhole issue goes away.
0 to disable the blackhole detection. This is a per-namespace sysctl.
+ The maximum value is one day (86400 seconds).
Default: 3600
diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
index 164f79b9deb0..11472e20fa6f 100644
--- a/net/mptcp/ctrl.c
+++ b/net/mptcp/ctrl.c
@@ -20,6 +20,7 @@ static int mptcp_pernet_id;
#ifdef CONFIG_SYSCTL
static int mptcp_pm_type_max = __MPTCP_PM_TYPE_MAX;
+static int one_day_secs = 24 * 3600;
#endif
struct mptcp_pernet {
@@ -350,6 +351,7 @@ static struct ctl_table mptcp_sysctl_table[] = {
.mode = 0644,
.proc_handler = proc_blackhole_detect_timeout,
.extra1 = SYSCTL_ZERO,
+ .extra2 = &one_day_secs,
},
{
.procname = "syn_retrans_before_tcp_fallback",
@@ -487,6 +489,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);
@@ -503,10 +506,11 @@ bool mptcp_active_should_disable(struct sock *ssk)
/* Limit timeout to max: 2^6 * initial timeout */
multiplier = 1 << min(disable_times - 1, 6);
+ delay = (u64)multiplier * blackhole_timeout * HZ;
/* Paired with the 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
next prev parent reply other threads:[~2026-11-23 9:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 9:04 [PATCH net-next v4 0/2] tcp/mptcp: prevent blackhole timeout arithmetic wraparound Yingjie Wang
2026-11-23 9:04 ` [PATCH net-next v4 1/2] tcp: avoid wrapping Fast Open blackhole timeout Yingjie Wang
2026-11-23 9:04 ` Yingjie Wang [this message]
2026-11-23 9:57 ` [PATCH net-next v4 0/2] tcp/mptcp: prevent blackhole timeout arithmetic wraparound Eric Dumazet
2026-11-23 10:15 ` Joel Granados
2026-11-23 10:18 ` Matthieu Baerts
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=61910493c920d138cd33da5ae5fc7947a64fba05.1795424547.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=joel.granados@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=weiwan@google.com \
--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®