From: netdev-bot+sashiko@kernel.org
To: x-professor@outlook.com
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
linux-kernel@vger.kernel.org, corbet@lwn.net,
skhan@linuxfoundation.org, rdunlap@infradead.org,
linux-doc@vger.kernel.org, edumazet@kernel.org,
ncardwell@google.com, gang.yan@linux.dev, kuniyu@google.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, matttbe@kernel.org, martineau@kernel.org,
geliang@kernel.org, ycheng@google.com, weiwan@google.com,
stable@vger.kernel.org, yangang@kylinos.cn
Subject: Re: [PATCH net v2 2/2] mptcp: avoid wrapping blackhole timeout
Date: Mon, 16 Nov 2026 05:21:44 +0000 [thread overview]
Message-ID: <179480650425.3133.15313880518132043396@kernel.org> (raw)
In-Reply-To: <070c69fa36f83fe47a5eb6d1434f543dabe930e7.1794672619.git.x-professor@outlook.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message body refers to earlier revisions of this
patch: "In the v1 arithmetic-only test, the unpatched kernel retried…
- [Low] mptcp_active_should_disable() (net/mptcp/ctrl.c:514-515) now
silently clamps the disable interval to MAX_JIFFY_OFFSET.
--
mptcp: avoid wrapping blackhole timeout
This commit computes the active-disable interval in
mptcp_active_should_disable() in u64, so multiplier * blackhole_timeout *
HZ no longer wraps in 32-bit arithmetic. The result is capped at
MAX_JIFFY_OFFSET before it is added to active_disable_stamp.
> 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.
[ ... ]
> On the v2 kernel, the loopback blackhole reproducer completed all 12
> clients and the probe used TCP fallback directly instead of retrying
> MP_CAPABLE.
[Severity: Low]
This isn't a bug, but the changelog refers to earlier revisions of the
patch ("In the v1 arithmetic-only test" and "On the v2 kernel"). After the
patch is merged, v1 and v2 mean nothing in git log. This is also tagged
for stable, so backporters will read it without the mailing list thread.
Could the reproducer results be described once, against the final code,
with the per-version history moved below the --- line?
The numbers themselves check out. 64 * 6912213 * 1000 = 442,381,632,000,
which is 512 mod 2^32. With 12 blackholes the multiplier is
1 << min(11, 6) = 64, and a 1.2 second wait is longer than 512 jiffies at
HZ=1000.
> diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> index 63c5747f0f63c..0b10e94e7f43c 100644
> --- a/net/mptcp/ctrl.c
> +++ b/net/mptcp/ctrl.c
[ ... ]
> @@ -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);
[Severity: Low]
On 32-bit kernels MAX_JIFFY_OFFSET is ((LONG_MAX >> 1) - 1), which is
0x3ffffffe jiffies, or about 12.4 days at HZ=1000. Does this clamp
silently shorten blackhole_timeout values that the sysctl still accepts?
The sysctl entry only sets a lower bound:
net/mptcp/ctrl.c:mptcp_sysctl_table[] {
...
{
.procname = "blackhole_timeout",
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_blackhole_detect_timeout,
.extra1 = SYSCTL_ZERO,
},
...
}
So values up to INT_MAX are accepted. Anything above about 1,073,741
seconds is cut short even on the first blackhole (multiplier 1). Smaller
values stop doubling before they reach the 64x factor.
time_before() handles deltas up to LONG_MAX, so the cap is half of what
the comparison can take. The old code compared intervals between 2^30 and
2^31-1 jiffies correctly, and those are now shortened.
For example, take HZ=1000, blackhole_timeout = 2000000 and a first
blackhole. The old code disabled active MPTCP for 2e9 jiffies (about 23
days). The new code disables it for 1,073,741,822 jiffies (about 12.4
days).
The commit message says:
Preserve the existing sysctl input range and backoff
for representable intervals.
But this interval is representable and still gets shortened.
Documentation/networking/mptcp-sysctl.rst, and the zh_CN translation,
still describe blackhole_timeout as an initial period that will "grow
exponentially", with no upper bound mentioned.
Should the clamp be documented, or should the sysctl get an upper bound
that matches it?
64-bit kernels are not affected, because MAX_JIFFY_OFFSET there is far
above 64 * INT_MAX * HZ.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794672619.git.x-professor%40outlook.com
next prev parent reply other threads:[~2026-11-16 5:21 UTC|newest]
Thread overview: 6+ 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-16 5:21 ` netdev-bot+sashiko
2026-11-14 16:12 ` [PATCH net v2 2/2] mptcp: avoid wrapping " Yingjie Wang
2026-11-16 5:21 ` netdev-bot+sashiko [this message]
2026-11-15 8:24 ` [PATCH net v2 0/2] tcp/mptcp: prevent blackhole timeout arithmetic wraparound Eric Dumazet
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=179480650425.3133.15313880518132043396@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--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=x-professor@outlook.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®