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>
Subject: [PATCH net-next v3 0/3] tcp/mptcp: prevent blackhole timeout arithmetic wraparound
Date: Mon, 16 Nov 2026 16:46:41 +0000 [thread overview]
Message-ID: <cover.1794847474.git.x-professor@outlook.com> (raw)
The TCP Fast Open and MPTCP blackhole handlers multiply writable timeout
sysctl values before adding the result to a jiffies timestamp. The
multiplication is performed in 32-bit unsigned arithmetic, so a large
value can wrap into a short delay even on 64-bit kernels.
With HZ=1000 and the maximum multiplier of 64, any timeout above 67108
seconds wraps; 67109 seconds becomes 8,704 jiffies (8.7 seconds) instead
of about 50 days. Patches 1 and 2 compute the delay in u64 and cap it at
MAX_JIFFY_OFFSET before adding it to the saved timestamp. Patch 1 also
limits the TCP sysctl to one day.
Patch 3 applies the same one-day limit to net.mptcp.blackhole_timeout,
following Eric's comment that the two sysctls should behave consistently
and Matthieu's agreement.
Both limits reject values that were previously accepted, so the series
targets net-next and is not intended for stable.
Changes since v2:
- Target net-next and drop Cc: stable, as requested by Eric. Keep the
Fixes tags.
- Move version history and earlier test results to the cover letter.
The commit messages describe the problem, the fix, and how the final
code was validated.
- Use 67109 seconds as the example and reproducer timeout. It is inside
the one-day limit and still wraps at the 64-fold backoff with HZ=1000.
- Mention in the changelogs that writes above the limit now fail.
- Add patch 3, limiting net.mptcp.blackhole_timeout to one day.
- Patches 1 and 2 have the same code as in v2. Gang Yan's Reviewed-by is
kept on patch 2.
v2: https://lore.kernel.org/r/cover.1794672619.git.x-professor@outlook.com
v1: https://lore.kernel.org/r/cover.1794325665.git.x-professor@outlook.com
Testing on net-next 7ccc5e05043b, x86-64, HZ=1000. The loopback
reproducers induce 12 TFO or MPTCP blackholes and then open a probe
connection:
- Timeout 67109 seconds, probe after 10 seconds: the unpatched kernel
retried active TFO (1.056 s, TCPFastOpenActiveFail +1) and MP_CAPABLE
(3.053 s, MPCapableSYNTXDisabled +0). With a 5 second wait it still
skipped both, matching the wrapped 8.7 second interval. The v3 kernel
skipped both after 10 seconds (0.000 s; +0 and +1).
- Timeout 6912213 seconds, probe after 1.2 seconds: the unpatched kernel
retried both. On a test kernel with patches 1 and 2 applied and only
the TCP input limit removed, both remained disabled.
- On the v3 kernel, both sysctls accept 0, 1, 3600, 86399 and 86400 and
reject -1, 86401, 6912213 and INT_MAX with EINVAL, leaving the previous
value unchanged, in the initial and in a new network namespace.
Defaults are unchanged. With 86400 second timeouts, the reproducers
still disabled active TFO and MPTCP.
- The affected objects build with W=1 on x86-64 and i386 at each patch.
The 32-bit behaviour of the MAX_JIFFY_OFFSET cap was checked by i386
builds and arithmetic, not at runtime. The TCP and MPTCP selftests were
not run locally; none of them sets these sysctls.
The issues were found using a static analysis tool.
Yingjie Wang (3):
tcp: avoid wrapping Fast Open blackhole timeout
mptcp: avoid wrapping blackhole timeout
mptcp: limit blackhole_timeout to one day
Documentation/networking/ip-sysctl.rst | 1 +
Documentation/networking/mptcp-sysctl.rst | 1 +
net/ipv4/sysctl_net_ipv4.c | 1 +
net/ipv4/tcp_fastopen.c | 12 +++++++++---
net/mptcp/ctrl.c | 14 +++++++++++---
5 files changed, 23 insertions(+), 6 deletions(-)
base-commit: 7ccc5e05043b1bb84326b19a2b05938d8f7a2ae6
--
2.43.0
next reply other threads:[~2026-11-16 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:46 Yingjie Wang [this message]
2026-11-16 16:46 ` [PATCH net-next v3 1/3] tcp: avoid wrapping Fast Open blackhole timeout Yingjie Wang
2026-11-16 16:46 ` [PATCH net-next v3 2/3] mptcp: avoid wrapping " Yingjie Wang
2026-11-16 16:46 ` [PATCH net-next v3 3/3] mptcp: limit blackhole_timeout to one day Yingjie Wang
2026-11-16 19:11 ` [PATCH net-next v3 0/3] tcp/mptcp: prevent blackhole timeout arithmetic wraparound MPTCP CI
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=cover.1794847474.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.