Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Yingjie Wang
Mon, 23 Nov 2026 09:04
[PATCH net-next v4 2/2] mptcp: avoid wrapping blackhole timeout
Author: Yingjie Wang
Date: Mon, 23 Nov 2026 09:04
Date: Mon, 23 Nov 2026 09:04
107 lines
22461 bytes
22461 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads