🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8461

Re: [PATCH net v2 1/1] tcp: check congestion control restriction first

#8461
From: Jiayuan Chen
Date: Thu, 29 Oct 2026 04:51
57 lines
10569 bytes
On 10/27/26 12:46 PM, Zhiling Zou wrote:
> tcp_set_default_congestion_control() takes a reference to an algorithm
> before checking whether a non-init network namespace may select it. A
> rejected request returns -EPERM without dropping the reference.
>
> This affects module-backed algorithms too; BPF is not required. For
> example, after root loads tcp_bbr, a user with CAP_NET_ADMIN in a
> non-init network namespace can repeatedly request it as the default
> although it is not in tcp_allowed_congestion_control. Each rejected
> write leaks a module reference. Since module->refcnt is an atomic_t,
> 2^31 such writes can make it negative; later module_put() calls warn,
> and rmmod can hit the BUG_ON() in try_release_module_ref().
>
> Check the namespace restriction before acquiring the reference, as
> tcp_set_congestion_control() already does.
>
> Fixes: 8d432592f30f ("net: Only allow init netns to set default tcp cong to a restricted algo")
> Cc: stable@vger.kernel.org
> Reported-by: Vega <vega@nebusec.ai>
> Suggested-by: Eric Dumazet <edumazet@kernel.org>
> Assisted-by: LLM
> Signed-off-by: Zhiling Zou <zhilinz@nebusec.ai>


Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>


> ---
> changes in v2:
>    - Check the namespace restriction before bpf_try_module_get(), following
>      tcp_set_congestion_control().
>    - Describe the module-backed reference leak and module refcount overflow.
>
>   net/ipv4/tcp_cong.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
> index 8e83ef81fc187..e3f462f161dd6 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -288,12 +288,12 @@ int tcp_set_default_congestion_control(struct net *net, const char *name)
>   	ca = tcp_ca_find_autoload(name);
>   	if (!ca) {
>   		ret = -ENOENT;
> -	} else if (!bpf_try_module_get(ca, ca->owner)) {
> -		ret = -EBUSY;
>   	} else if (!net_eq(net, &init_net) &&
>   			!(ca->flags & TCP_CONG_NON_RESTRICTED)) {
>   		/* Only init netns can set default to a restricted algorithm */
>   		ret = -EPERM;
> +	} else if (!bpf_try_module_get(ca, ca->owner)) {
> +		ret = -EBUSY;
>   	} else {
>   		prev = xchg(&net->ipv4.tcp_congestion_control, ca);
>   		if (prev)
Technical Details
Message-ID: <ab2efe2e-0d49-4fed-8fa0-b90f21d97aba@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353162-linux-kernel-netdev=dewy.ru
References: <71c142b2d45af6a2fe7fc6cd4a5ca52c53afbe23.1793075984.git.zhilinz@nebusec.ai>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353162-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/1] tcp: check congestion control restriction
 first
Date: Thu, 29 Oct 2026 12:51:41 +0800
Organization: Usenet Network
Message-ID: <ab2efe2e-0d49-4fed-8fa0-b90f21d97aba@linux.dev>
References: <71c142b2d45af6a2fe7fc6cd4a5ca52c53afbe23.1793075984.git.zhilinz@nebusec.ai>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1937973"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0mV+MTP3zMlvMU8dve8EgXFyvVc= sha256:PHqSWc0nEw6cGMOTbHGOU52uJf1jZDn45BG3xQAx/fI=
	sha1:Pxvn9ibBVztpOyrV8btis+X5waM= sha256:HBm1cBDCtiPuUJ409V3WkB4vYPssm7STIAvhqke/kYw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 08468125C57; Thu, 29 Oct 2026 07:56:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.051
X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	HK_RANDOM_FROM=0.999, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Lfrh57LvHJU9;
	Thu, 29 Oct 2026 07:56:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353162-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id CE152125C53; Thu, 29 Oct 2026 07:56:28 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B75C5206FC; Thu, 29 Oct 2026 04:51:56 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793249514;
	b=l2+uZSLcA3fpY4sDhYnC1SZzb/O8lOFJSpK4bl54FD0bzrnz6iTUeLOMCM4MbMh4y0NX
	 UvjR9y6TF8MTAhiEJQtfya/5M0+XaJrU9p05ZXqg2+VUQCzbU8diQ1yA4OxTm1wnSikTR
	 TNKGj5ccwqAU0jHJDsHYxNpvt8ui/DeIUPfiKCvXPN4bzq9qGgW5C7fzipvYsmjucK1Tr
	 DqAGRo8weMbvHofFm02jbrLe8x7lPAhx68/VBufk6iYKLr4N/bOeBtnDShdy5i0NGiAU+
	 hqfUCTur8P1WmScNZXxsqmK2/FF1sXyMVkr0Jf3Wot9fO2idVYT9zSwcS4UpUUuINrg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793249514;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:Cc:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=0l4+RNVQgirAlckpa+gpMeTlfb3AsXJyJI/7a/hfeUk=;
	b=ZxIgzIxa47j9/DvJ6+RXViFtty1iTilBVEdbDAee03Jum4PVE16S/Xuwms3VWYm5HqYn
	 kTvjZTf5uYcrAIadjXd5mBuqqrOHb/rFLWcvhxcQuslQ11jnBh+CCPIljRqLUXO7rt1XA
	 6O2gk8/6bwMvzOXIS4y1gITjst0sOqM8RG8Kud6YMifKlWIburYIP0FEbknnb6yYKrQGm
	 GtIBk24E85szV8DI+bPGcFnIhxDVZcf8Q0taUUOsD+wKHn0yajjx7UF7dioISW28y+lcB
	 Wpg55FYL5Q4LGFTZNomYiQT7UK648UcAcR2FSZpOv+YZS+MmmG8iiYgBosWxIXd9c6Q==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=YC6UQVDb;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E616606A320;
	Thu, 29 Oct 2026 04:51:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=YC6UQVDb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.145
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793249511;
	b=4tZdBCs2hHXn1W6aBnofkGPZTvYRZamIbTHxXZFWTcsVn/B6WpYm7wP6RC8NFOElUrM3
	 aAgk9tTs+v8w5xF5TmWrMuzbYUJV6taGwTgRdmLmPufyWl/v9AlqljvWjqu+APZGQhSZv
	 bAE+LeL1kNRjz7zEZ7nP8jc66Y2DVLX+Ijrwj6Fc/fvhihApqRWgTc7jTwHvQKFL22SQg
	 DCTLMyLdboWuJkngLnqS+9leBn0CnKLxN+N66MlBGeoA9riLlNmLhEFC69eQRTqzo0ohG
	 54AWrhfSt/1UU0jlQlEktK0beY99mtNfQixWw9j6M/BKsaFVUu0MhSj8q5mslrWQQog==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793249511;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent:
	 Subject:To:Cc:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=0l4+RNVQgirAlckpa+gpMeTlfb3AsXJyJI/7a/hfeUk=;
	b=AIY37lKp6tgeUdEl4AzGV06I5t8QY0ZlYLTWedMv1RHChRpfe3hsW/eFFlPDpOZJWaxI
	 HIOBTCnF48Jdue9Ie+p4tRFAmBEab0RBBxb0ta06r/VhRu7n3N9MrlA0tMCIUrgzAjPbB
	 PuCq9iTXMU5sOt8IYkdJ7fRLl2fKgS27hLax8pO8pKMf/KdoFP67goz2PpBf6a9oGep9d
	 taeIn0fmbJugETyr1eeLhQBQGykVsjFuyoX1QxHeBPKmMy4anZLmwKF1JrHJFdi2lsL15
	 /Rkr8CWJa+01ymZxtYJQoqRk41qIWWobv1aJ0ufStWO2lY98u2CmlesGHY8K89sVaeA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=YC6UQVDb;
	arc=none smtp.remote-ip=95.215.58.145
X-Received: from mta1.migadu.com (out-145.mta1.migadu.com [95.215.58.145])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05381606A31C
	for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 04:51:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 05381606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=ISQGa3N2A4RKzakpfsS7Fx2EllnFI1gjln/ybfEj23g=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793249507; v=1; x=1793854307;
 b=YC6UQVDbig99mhtjuvNlhefo6EeGew7pB1Y6wO+b32Y+1cCsUFWodX4eYKcZ521F/fmR4D6O
 JJqDvpRmxuAkSUvNc/a8d/kJUmaCA1M1vm/gHIp+5ubjgahjFzIty0aBWwwTmwW8UILhb06vs76
 ZEm82BCW8NeXY72wTl8pjuKI=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 133843d937483977;
	Thu, 29 Oct 2026 04:51:47 +0000
X-Mizu-Trace-ID: 133843d937483977
X-Migadu-Flow: FLOW_OUT
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: ncardwell@google.com, kuniyu@google.com, davem@davemloft.net,
 pabeni@redhat.com, horms@kernel.org, jonathon.reinhart@gmail.com,
 vega@nebusec.ai
X-In-Reply-To: <71c142b2d45af6a2fe7fc6cd4a5ca52c53afbe23.1793075984.git.zhilinz@nebusec.ai>