tcp/mptcp: prevent blackhole timeout arithmetic wraparound
Subsystems (6)
v2 cover tcp/mptcp: prevent blackhole timeout arithmetic wraparound
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 a 64-bit kernel.
With HZ=1000, a timeout of 6912213 seconds and the maximum multiplier of 64 should produce 442,381,632,000 jiffies, but the current calculations truncate the result to 512 jiffies. Both patches compute the delay in u64 and cap it at MAX_JIFFY_OFFSET before adding it to the saved timestamp.
The issues were found using a static analysis tool. In the v1 arithmetic A/B tests, loopback reproducers induced 12 blackholes, waited 1.2 seconds, and then made a new connection:
TFO: base probe 1.026 s, TCPFastOpenActiveFail +1;
fixed probe 0.000 s, TCPFastOpenActiveFail +0.
MPTCP: base probe 3.087 s, MPCapableSYNTXDisabled +0;
fixed probe 0.000 s, MPCapableSYNTXDisabled +1.
The TFO counter records another failed active Fast Open attempt. The MPTCP counter records a connection that skips MP_CAPABLE and falls back to TCP while active MPTCP is disabled.
Changes since v1:
- Add a reasonable upper bound for the TCP Fast Open sysctl, as requested by Kuniyuki Iwashima. This version proposes one day (86400 seconds), using the existing IPv4 one_day_secs bound, and documents that limit. Keep the existing MPTCP sysctl input range.
- Clarify that the multiplier is limited to 64 and the final delay is separately capped for safe jiffies comparisons on 32-bit systems, addressing Gang Yan's comment. Keep the READ_ONCE/WRITE_ONCE pairing annotations next to the timestamp reads.
- Identify the original runtime results as v1 evidence in both commits.
- Retain Gang Yan's Reviewed-by tag on the unchanged MPTCP arithmetic fix.
v1: https://lore.kernel.org/r/[email protected]
On the final v2 x86-64 HZ=1000 kernel, TCP accepts 86400 and rejects 86401; MPTCP still accepts 86401 and INT_MAX. Boundary tests also cover zero, negative and oversized values, failed-write preservation, defaults, and network namespace isolation. The large timeout used in the v1 TFO test is now rejected by the TCP sysctl limit.
The MPTCP blackhole test was rerun on this v2 kernel: all 12 clients completed, and the probe used TCP fallback directly (0.000 s, MPCapableSYNTXDisabled +1). The full x86-64 kernel build and affected object builds on x86-64 and i386 passed. The upstream TCP and MPTCP selftest suites were not run. Full allyesconfig/allmodconfig W=1 builds stopped at warnings promoted to
errors in unchanged lockdep, coda, and x86 callthunks code; the affected objects passed W=1 KCFLAGS=-Werror in both configurations.
The patches are independent and have separate Fixes tags.
Yingjie Wang (2):
tcp: avoid wrapping Fast Open blackhole timeout
mptcp: avoid wrapping blackhole timeout
Documentation/networking/ip-sysctl.rst | 1 + net/ipv4/sysctl_net_ipv4.c | 1 + net/ipv4/tcp_fastopen.c | 12 +++++++++--- net/mptcp/ctrl.c | 12 +++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-)
base-commit: 30c71476d842b094651bd7712f6c8ee8716147d0
Signature · 1 line
2.43.0
PATCH v2 1/2 tcp: avoid wrapping Fast Open blackhole timeout
tcp_fastopen_active_should_disable() calculates the active-disable interval as multiplier * tfo_bh_timeout * HZ. Since all operands are 32-bit, a large tcp_fastopen_blackhole_timeout_sec can wrap the delay even on 64-bit kernels and re-enable active Fast Open too soon.
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 Fast Open blackholes and waited 1.2 seconds before opening another connection. In the v1 arithmetic-only test, the unpatched kernel retried active Fast Open, while the fixed kernel used a regular TCP handshake. The reproducer required neither kernel modifications nor fault injection. The input limit added here rejects that large setting.
Compute the interval in u64 and cap it at MAX_JIFFY_OFFSET before adding it to the saved timestamp. Also limit the writable initial timeout to one day, so the exponential backoff does not start from an impractically long period. Even at this limit, a 64-fold backoff with HZ=1000 exceeds the 32-bit range, so the wider calculation and jiffies cap are still needed.
On the v2 kernel, the sysctl accepts 86400 seconds and rejects 86401, leaving the previous value unchanged.
--- Documentation/networking/ip-sysctl.rst | 1 + net/ipv4/sysctl_net_ipv4.c | 1 + net/ipv4/tcp_fastopen.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-)
Documentation/networking/ip-sysctl.rst +1 -0
@@ -1055,6 +1055,7 @@ tcp_fastopen_blackhole_timeout_sec - INTEGER get detected right after Fastopen is re-enabled and will reset to initial value when the blackhole issue goes away. 0 to disable the blackhole detection. + The maximum value is one day (86400 seconds). By default, it is set to 0 (feature is disabled).
net/ipv4/sysctl_net_ipv4.c +1 -0
@@ -1152,6 +1152,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_tfo_blackhole_detect_timeout, .extra1 = SYSCTL_ZERO, + .extra2 = &one_day_secs, },#ifdef CONFIG_IP_ROUTE_MULTIPATH {
net/ipv4/tcp_fastopen.c +9 -3
@@ -613,6 +613,7 @@ bool tcp_fastopen_active_should_disable(struct sock *sk)unsigned long timeout;int tfo_da_times;int multiplier; +u64 delay;if (!tfo_bh_timeout)return false;
@@ -624,12 +625,17 @@ bool tcp_fastopen_active_should_disable(struct sock *sk)/* Paired with smp_mb__before_atomic() in tcp_fastopen_active_disable() */ smp_rmb (); -/* Limit timeout to max: 2^6 * initial timeout */ +/* Limit the backoff multiplier to 64. */ multiplier =1 <<min (tfo_da_times -1 ,6 ); + delay = (u64 )multiplier * tfo_bh_timeout *HZ ; -/* Paired with the WRITE_ONCE() in tcp_fastopen_active_disable(). */ +/* +* Cap the delay for safe jiffies comparisons on 32-bit systems. +* The timestamp read is paired with WRITE_ONCE() in +* tcp_fastopen_active_disable(). +*/ timeout =READ_ONCE (sock_net (sk)->ipv4.tfo_active_disable_stamp) + - multiplier * tfo_bh_timeout *HZ ; +min (delay,MAX_JIFFY_OFFSET );if (time_before (jiffies, timeout))return true;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net v2 1/2] tcp: avoid wrapping Fast Open blackhole timeout
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The patch adds a new upper bound, .extra2 = &one_day_secs (86400), to net.ipv4.tcp_fastopen_blackhole_timeout_sec in…
- [Low] The commit body of "tcp: avoid wrapping Fast Open blackhole timeout" refers to patch revisions: 'In the v1 arithmetic-only test,…
--
tcp: avoid wrapping Fast Open blackhole timeout
This commit computes the Fast Open active-disable interval in tcp_fastopen_active_should_disable() as a u64 and caps it at MAX_JIFFY_OFFSET, so the delay can no longer wrap. It also limits tcp_fastopen_blackhole_timeout_sec to 86400 seconds and documents the new limit in ip-sysctl.rst.
Quoted 6 lines
This issue was found using a static analysis tool. A loopback reproducer induced 12 Fast Open blackholes and waited 1.2 seconds before opening another connection. In the v1 arithmetic-only test, the unpatched kernel retried active Fast Open, while the fixed kernel used a regular TCP handshake. The reproducer required neither kernel modifications nor fault injection. The input limit added here rejects that large setting.
[ ... ]
Quoted 2 lines
On the v2 kernel, the sysctl accepts 86400 seconds and rejects 86401, leaving the previous value unchanged.
[Severity: Low]
This isn't a bug, but these sentences mention patch revisions (v1 and v2). Could this revision history go below the --- line instead? Once the patch is merged, v1 and v2 won't mean anything in git history.
The wording also suggests that the only functional test of the arithmetic fix (the 6912213 second timeout) was run on v1. The submitted code now rejects that input, and the only v2 test described is the sysctl range check.
The arithmetic fix still matters within the new limit. At HZ=1000, 64 * 86400 * 1000 = 5,529,600,000. In 32-bit math that wraps to 1,234,632,704 jiffies, which is about 14.3 days instead of 64 days.
Could the changelog describe a test of the submitted code on that path?
The companion MPTCP patch in this series uses the same v1/v2 wording.
net/ipv4/sysctl_net_ipv4.c static const struct ctl_table ipv4_net_table[] = { · line 1156
Quoted 10 lines
net/ipv4/sysctl_net_ipv4.c +1
-0@@ -1152,6 +1152,7 @@ static const struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_tfo_blackhole_detect_timeout, .extra1 = SYSCTL_ZERO, + .extra2 = &one_day_secs, },
[Severity: Medium]
Is this new upper bound needed for the overflow fix? The patch is also tagged Cc: stable.
proc_tfo_blackhole_detect_timeout() calls proc_dointvec_minmax(), so extra2 is enforced:
net/ipv4/sysctl_net_ipv4.c:proc_tfo_blackhole_detect_timeout() {
...
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (write && ret == 0)
atomic_set(&net->ipv4.tfo_active_disable_times, 0);
...
}Before this patch, any non-negative int was accepted, such as 172800 or 604800. Now those writes fail with -EINVAL. The stored value stays as it was, and the tfo_active_disable_times reset is skipped.
At boot, the stored value is the per-netns default of 0 from tcp_sk_init(). If sysctl.conf has a multi-day value, would Fast Open blackhole detection stay disabled after a stable update?
The u64 calculation and the cap in tcp_fastopen_active_should_disable() already seem to handle every int input:
delay = (u64)multiplier * tfo_bh_timeout * HZ; ... min(delay, MAX_JIFFY_OFFSET);
tfo_bh_timeout is at most 2^31-1, multiplier is at most 64, and HZ is at most a little over 1000. The product stays below 2^48, and the cap covers both 32-bit and 64-bit kernels. So the one day limit looks like a policy change, not part of the fix.
The commit message mentions the limit. It doesn't say that values accepted before will now be rejected.
The companion patch in this series, "mptcp: avoid wrapping blackhole timeout", makes the same arithmetic fix and says "Preserve the existing sysctl input range". So the two patches treat the input range differently.
Could the bound be dropped here? Or could it move to a separate patch, without Cc: stable, whose changelog describes the narrower range?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794672619.git.x-professor%40outlook.com
PATCH v2 2/2 mptcp: avoid wrapping blackhole timeout
In reply to Yingjie Wangmptcp_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.
--- net/mptcp/ctrl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/mptcp/ctrl.c +9 -3
@@ -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); }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net v2 2/2] mptcp: avoid wrapping blackhole timeout
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…
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.
Quoted 5 lines
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.
[ ... ]
Quoted 3 lines
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.
Quoted 4 lines
net/mptcp/ctrl.c +0
-0
[ ... ]
Quoted 8 lines
net/mptcp/ctrl.c +2
-1@@ -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 ;
net/mptcp/ctrl.c bool mptcp_active_should_disable(struct sock *ssk) · line 515
Quoted 10 lines
net/mptcp/ctrl.c +6
-2-/* 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.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794672619.git.x-professor%40outlook.com
Hi Yingjie,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/43616523087
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/64364d4b6c68
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1211446
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Eric Dumazet
maintainerQuoted 24 lines · Yingjie Wang
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 a 64-bit kernel.
With HZ=1000, a timeout of 6912213 seconds and the maximum multiplier of 64 should produce 442,381,632,000 jiffies, but the current calculations truncate the result to 512 jiffies. Both patches compute the delay in u64 and cap it at
MAX_JIFFY_OFFSETbefore adding it to the saved timestamp.The issues were found using a static analysis tool. In the v1 arithmetic A/B tests, loopback reproducers induced 12 blackholes, waited 1.2 seconds, and then made a new connection:
TFO: base probe 1.026 s, TCPFastOpenActiveFail +1;
fixed probe 0.000 s, TCPFastOpenActiveFail +0.
MPTCP: base probe 3.087 s, MPCapableSYNTXDisabled +0;
fixed probe 0.000 s, MPCapableSYNTXDisabled +1.The TFO counter records another failed active Fast Open attempt. The MPTCP counter records a connection that skips
MP_CAPABLEand falls back to TCP while active MPTCP is disabled.
Quoted 6 lines
Changes since v1:
- Add a reasonable upper bound for the TCP Fast Open sysctl, as requested by Kuniyuki Iwashima. This version proposes one day (86400 seconds), using the existing IPv4
one_day_secsbound, and documents that limit. Keep the existing MPTCP sysctl input range.
The one day limit, the u64 computation and the clamp look fine to me for the TCP side: with HZ=1000, 64 * 86400 * HZ still does not fit in 32 bits, and 32-bit kernels need the interval to stay below 2^31 jiffies for time_before().
Why is MPTCP left alone? Kuniyuki's remark applies equally to net.mptcp.blackhole_timeout: nobody needs a multi-day initial timeout there either. I will let MPTCP maintainers decide, but having the two sysctls behave differently looks odd.
Quoted 5 lines
- Clarify that the multiplier is limited to 64 and the final delay is separately capped for safe jiffies comparisons on 32-bit systems, addressing Gang Yan's comment. Keep the READ_ONCE/WRITE_ONCE pairing annotations next to the timestamp reads.
- Identify the original runtime results as v1 evidence in both commits.
Please do not do that. The changelog of each patch should describe the problem and the fix. Version history and test notes ("In the v1 arithmetic-only test...", "On the v2 kernel...") belong in the cover letter or after the --- marker, not in the commit message.
Quoted 19 lines
- Retain Gang Yan's Reviewed-by tag on the unchanged MPTCP arithmetic fix.
v1: https://lore.kernel.org/r/[email protected]
On the final v2 x86-64 HZ=1000 kernel, TCP accepts 86400 and rejects 86401; MPTCP still accepts 86401 and
INT_MAX. Boundary tests also cover zero, negative and oversized values, failed-write preservation, defaults, and network namespace isolation. The large timeout used in the v1 TFO test is now rejected by the TCP sysctl limit.The MPTCP blackhole test was rerun on this v2 kernel: all 12 clients completed, and the probe used TCP fallback directly (0.000 s, MPCapableSYNTXDisabled +1). The full x86-64 kernel build and affected object builds on x86-64 and i386 passed. The upstream TCP and MPTCP selftest suites were not run. Full allyesconfig/allmodconfig W=1 builds stopped at warnings promoted to
errors in unchanged lockdep, coda, and x86 callthunks code; the affected objects passed W=1 KCFLAGS=-Werror in both configurations.
Quoted 1 line
The patches are independent and have separate Fixes tags.
About the Fixes/stable tags:
This needs an admin to set a timeout nobody would use, and the only consequence is that active TFO (or MPTCP) is retried sooner than requested.
Also patch 1 now makes the TCP sysctl reject values that were accepted before. I do not think we want that in stable trees.
Please drop the Cc: stable and target net-next.
Thanks.
Quoted 16 lines
Yingjie Wang (2):
tcp: avoid wrapping Fast Open blackhole timeout
mptcp: avoid wrapping blackhole timeoutDocumentation/networking/ip-sysctl.rst | 1 + net/ipv4/sysctl_net_ipv4.c | 1 + net/ipv4/tcp_fastopen.c | 12 +++++++++--- net/mptcp/ctrl.c | 12 +++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-)base-commit:
30c71476d842b094651bd7712f6c8ee8716147d0--
2.43.0
Matthieu Baerts
maintainerHi Eric, Yingjie,
Quoted 37 lines · Eric Dumazet
Quoted 24 lines · Yingjie Wang
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 a 64-bit kernel.
With HZ=1000, a timeout of 6912213 seconds and the maximum multiplier of 64 should produce 442,381,632,000 jiffies, but the current calculations truncate the result to 512 jiffies. Both patches compute the delay in u64 and cap it at
MAX_JIFFY_OFFSETbefore adding it to the saved timestamp.The issues were found using a static analysis tool. In the v1 arithmetic A/B tests, loopback reproducers induced 12 blackholes, waited 1.2 seconds, and then made a new connection:
TFO: base probe 1.026 s, TCPFastOpenActiveFail +1;
fixed probe 0.000 s, TCPFastOpenActiveFail +0.
MPTCP: base probe 3.087 s, MPCapableSYNTXDisabled +0;
fixed probe 0.000 s, MPCapableSYNTXDisabled +1.The TFO counter records another failed active Fast Open attempt. The MPTCP counter records a connection that skips
MP_CAPABLEand falls back to TCP while active MPTCP is disabled.Quoted 6 lines
Changes since v1:
- Add a reasonable upper bound for the TCP Fast Open sysctl, as requested by Kuniyuki Iwashima. This version proposes one day (86400 seconds), using the existing IPv4
one_day_secsbound, and documents that limit. Keep the existing MPTCP sysctl input range.The one day limit, the u64 computation and the clamp look fine to me for the TCP side: with HZ=1000, 64 * 86400 * HZ still does not fit in 32 bits, and 32-bit kernels need the interval to stay below 2^31 jiffies for
time_before().
Quoted 4 lines
Why is MPTCP left alone? Kuniyuki's remark applies equally to net.mptcp.blackhole_timeout: nobody needs a multi-day initial timeout there either. I will let MPTCP maintainers decide, but having the two sysctls behave differently looks odd.
I agree with Eric: these two "blackhole" sysctl knobs are similar, and the behaviour shouldn't differentiate then.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.