Linux Documentation
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Yingjie Wang <x-professor@outlook.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"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>,
	"martineau@kernel.org" <martineau@kernel.org>,
	"geliang@kernel.org" <geliang@kernel.org>,
	"ycheng@google.com" <ycheng@google.com>,
	"weiwan@google.com" <weiwan@google.com>,
	Gang Yan <yangang@kylinos.cn>
Subject: Re: [PATCH net-next v3 2/3] mptcp: avoid wrapping blackhole timeout
Date: Fri, 20 Nov 2026 22:30:07 +0100	[thread overview]
Message-ID: <cff77c51-64d1-4cc0-9da3-41832d3015b5@kernel.org> (raw)
In-Reply-To: <33f003b094444e37f11f9328c783d8c5a42e841a.1794847474.git.x-professor@outlook.com>

Hi Yingjie,

On 16/11/2026 17:46, Yingjie Wang wrote:
> 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, any timeout above 67108
> seconds wraps. For example, 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. The sysctl input range
> is unchanged; values whose interval exceeds the cap are shortened to it.
> 
> With this patch, the same reproducer fell back to TCP without retrying
> MP_CAPABLE. The MPTCP selftests were not run; none of them sets this
> sysctl.
> 
> Fixes: 27069e7cb3d1 ("mptcp: disable active MPTCP in case of blackhole")
> Reviewed-by: Gang Yan <yangang@kylinos.cn>
> Signed-off-by: Yingjie Wang <x-professor@outlook.com>
> ---
>  net/mptcp/ctrl.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> index 63c5747f0f63..0b10e94e7f43 100644
> --- a/net/mptcp/ctrl.c
> +++ b/net/mptcp/ctrl.c
> @@ -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().
> +	 */

Same here: no need to modify the comment here.

pw-bot: cr

>  	timeout = READ_ONCE(pernet->active_disable_stamp) +
> -		  multiplier * blackhole_timeout * HZ;
> +		  min(delay, MAX_JIFFY_OFFSET);
>  
>  	return time_before(jiffies, timeout);
>  }

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2026-11-20 21:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:46 [PATCH net-next v3 0/3] tcp/mptcp: prevent blackhole timeout arithmetic wraparound Yingjie Wang
2026-11-16 16:46 ` [PATCH net-next v3 1/3] tcp: avoid wrapping Fast Open blackhole timeout Yingjie Wang
2026-11-20 21:29   ` Matthieu Baerts
2026-11-16 16:46 ` [PATCH net-next v3 2/3] mptcp: avoid wrapping " Yingjie Wang
2026-11-20 21:30   ` Matthieu Baerts [this message]
2026-11-16 16:46 ` [PATCH net-next v3 3/3] mptcp: limit blackhole_timeout to one day Yingjie Wang
2026-11-20 21:30   ` 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=cff77c51-64d1-4cc0-9da3-41832d3015b5@kernel.org \
    --to=matttbe@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=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=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