๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6286

Re: [PATCH net 1/1] tcp: release congestion control reference on rejection

#6286
From: Eric Dumazet
Date: Thu, 22 Oct 2026 03:53
84 lines
11811 bytes
Le mer. 21 oct. 2026 ร  20:57, Zhiling Zou <zhilinz@nebusec.ai> a รฉcrit :
>
> tcp_set_default_congestion_control() takes a reference to the selected
> algorithm before checking whether a non-init netns may select a
> restricted algorithm. When the check fails, the function returns -EPERM
> without dropping the reference.
>
> For BPF struct_ops algorithms this keeps the struct_ops map and its
> programs alive. For module-backed algorithms it leaks the module
> reference as well. A network namespace administrator can repeatedly
> trigger the rejected request after the algorithm has been loaded.
>
> Drop the reference on the rejection path.
>
> 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>
> Assisted-by: LLM
> Signed-off-by: Zhiling Zou <zhilinz@nebusec.ai>
> ---
>  net/ipv4/tcp_cong.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
> index 8e83ef81fc187..907c63af14785 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -293,6 +293,7 @@ int tcp_set_default_congestion_control(struct net *net, const char *name)
>         } else if (!net_eq(net, &init_net) &&
>                         !(ca->flags & TCP_CONG_NON_RESTRICTED)) {
>                 /* Only init netns can set default to a restricted algorithm */
> +               bpf_module_put(ca, ca->owner);
>                 ret = -EPERM;
>         } else {
>                 prev = xchg(&net->ipv4.tcp_congestion_control, ca);

Thanks for the report.

Instead of taking a reference only to drop it, please move the
restricted check before bpf_try_module_get(), as
tcp_set_congestion_control() already does:

        if (!ca) {
                ret = -ENOENT;
        } 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 {

Also for v2:

- BPF is not needed to trigger this, and the module case is the
  interesting one. Any restricted module CC already loaded by root
  (e.g. tcp_bbr, not listed in tcp_allowed_congestion_control) leaks
  a module reference on each rejected write from a non-init netns.

  module->refcnt is a plain atomic_t: after 2^31 rejected writes it
  becomes negative, and every following module_put() hits the
  WARN_ON() in module_put(). An rmmod would then hit the BUG_ON()
  in try_release_module_ref().

  BPF struct_ops use an atomic64_t refcount, so they cannot overflow

  Please describe this in the changelog instead of the
  struct_ops/OOM scenario.

- No need for a cover letter for a single trivial patch.
  Your cover letter is adding noise, any LLM is able to rebuild a POC just fine.

Please wait 24 hours before sending v2.

Thanks.

pw-bot: cr
Technical Details
Message-ID: <CAL4WiioBzbo81K2EVw8UQG6w70JS3D80GNoDndXFfcG-qAhUEw@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350369-linux-kernel-netdev=dewy.ru
References: <cover.1792607608.git.zhilinz@nebusec.ai> <2773af2572ff59055933e407a135b39bca537381.1792607608.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-350369-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/1] tcp: release congestion control reference on rejection
Date: Thu, 22 Oct 2026 05:53:57 +0200
Organization: Usenet Network
Message-ID: <CAL4WiioBzbo81K2EVw8UQG6w70JS3D80GNoDndXFfcG-qAhUEw@mail.gmail.com>
References: <cover.1792607608.git.zhilinz@nebusec.ai> <2773af2572ff59055933e407a135b39bca537381.1792607608.git.zhilinz@nebusec.ai>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="122964"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+eKKPy70QeEo+4FkWdNJpEY4v6o= sha256:h46QXryLsQZVtavUmG60aA7rPkSavPcWh2lZZq5aZfw=
	sha1:4w2S/ajdQCDL9t/NNvJBg3XcSaY= sha256:BGsFIhza90m3l4YezMt/XkYa+JjaHFFleLHISZAsXVY=
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 6958011119B; Thu, 22 Oct 2026 06:55:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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 (2048-bit key)
	header.d=kernel.org
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 LhAh36wHpd7L;
	Thu, 22 Oct 2026 06:55:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350369-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id E93B7111194; Thu, 22 Oct 2026 06:54:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 370462D2F3; Thu, 22 Oct 2026 03:54:18 +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=1792641252;
	b=VWcWD4aRYz/l+dRr/G97TFY1QUYc9v4HcELeNrjdVvfQ6puNLNNsqQL5eUzkQiQW+8nf
	 bu+ipUm5WcTK0rUziwMzkQf3Bb9grNqcNrUDOdGo6o3bXFnug1yqo3QK9N4H3YZagirKc
	 boWMflVTgUBob41fdf+WkYjdl6csqigsVMOf4K+Zh27rfpaCnelrjsxR+ri4PI/JqYV0d
	 u6ZHOC0ScXUyO18YNQP47bRfHlaSiCJ60pOV6H9BKikgEHlqI+U4skKK5UDmZGGNReHyg
	 R7e6y3e7POuOUTAvsVAQN8soGjnyyhOOswifcy+6djJjnh7QeZK1GxhzSsteYkiXklQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792641252;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Gm-Message-State:X-Received:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=xEoTQ9N/Tf+sH4oyVMEnoem256sSy7IUWX9i50eKFv8=;
	b=Tp1Qua2BQcuzZC6QON915KhXUxKmLBGQJlLlSIIDwN/TYmsNpCzqTMQn8guyp9/XtTju
	 SpSRikRTD6of9+exsSfXEHpLH+x9MHBlECbW9b4S6oHRoffnSRb/ydg3V1bhw/bi55XnN
	 D1XURs1NAdAzj5bMHFdIsLNFyCtw4tS/k4BgM8ZlwzLnhRa5aqpv06wFXByJQag6JYNuD
	 3nGkIL0nThTdYrzmvXoxShi3mdTs0Vr7pefTaPwO+YnkSLiRjJxfqUPrU3gK2g0rgT2Fe
	 DqhpgDBGJOYqBgf3/3xggoMKBp4aXgpjlnvk59ISbSaB65LOH4ZN1NX5ZnFy/7+Y5/A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=baBKQxV+;
	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 E4895606A31E;
	Thu, 22 Oct 2026 03:54:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=baBKQxV+
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792641251;
	b=n866RDxeFCZlL4yNMGShtKs8dtUIIPp5tNU56I65cNB5J0IF1KhzwHy1uTJJw5lzL7Nu
	 jnFKOEXSIIGYrW0DclmWOQ4+TptUEU+tRTvxYTacVL6RMbI2oqjqPvCM78XORcscvpTbC
	 Y0Br3pR2rTUoOPmHFGL/0jOtAhMlgU/Wu7BrlcuhX/0dXIamTukBZ0StotwWckYEgHHnU
	 rKqUa0dkzMRqSBC+zPWagSC5seUCVRk9mTb36CfwQyZbZ6nzYj6SNTwgJKO3xlFpjHj+4
	 gjGRW65sf3eJqYI53DocOHbpK5PM3+kKZR47Zm2tlICmJbjeFOIoTTTH43upQb+qmvw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792641251;
	h=Received:DKIM-Signature:Received:X-Gm-Message-State:X-Received:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=xEoTQ9N/Tf+sH4oyVMEnoem256sSy7IUWX9i50eKFv8=;
	b=derzU9HOXLN/c6AroiNoR9gz+xzjh6PXoiT/Tt3Rily4OMpvCubiiqgvzFmjsAlYPg6o
	 u+XXEmS+UeXahjLVCsUuLEpmeHkYx3HD3aF9LxC7fv9nYprgC9MCy7rZSQQ9y28ndAS4c
	 i72wHXjfY87fo5FOMycqN1OLCjOtrDtfCu4A96irshiKAf84W+3Rlu3m2xGa1SN+7D0JI
	 yV0Xp2Vf18tg2dz9IPfyrOI4mRJ6BwqxGn56CvIWoaxWCYt+5U6rGnJdOvPlCzZuKZr3Y
	 9iFa0ovDI5vAglU80VPIEXF2MklDj94pGuCxBAsSvHp1Y+rZvCgn0qwQSqg/riP2oFw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=baBKQxV+;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51911606A327
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 03:54:10 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2D451F000CD
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 03:54:09 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792641249;
	bh=xEoTQ9N/Tf+sH4oyVMEnoem256sSy7IUWX9i50eKFv8=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=baBKQxV+L2zV88aADSZl53MJEoBXHTQUWT553YgvDZ4Fub7KVSSh/iwPCIo61JpGi
	 iaUKQSnlHxkfFa89o6QfoJzwnYvbQHnxoq3JlLItBhR4KNky6ros29878rdmM3Zain
	 01zgmpKMWCm+RKOtwWlB7nj8XuQuPmW8JEkpw/9VBVXtXjPFdVKC9qwRT2Ku+9WWuE
	 /maDT98FV74H7Gyjrw0VSeuXcoNjUhwyJId6k3TxJwcxhnN3usnK7zF5XU05+qWZW2
	 8iaEI9cjUPvy3H0iQ5TKGH03ZZOm8eJWMTB0dL3PoLnWGdL9Xd5m53LJ+3yDT/NxYv
	 V68zO2A1sNp2w==
X-Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-6df7f544919so803838eaf.1
        for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 20:54:09 -0700 (PDT)
X-Gm-Message-State: AFq9FYJNxGB4cIHxfwhp62W8Dpb1XGyrBTS+FGjk35fgu4+LDApl1Qxc
	GtOOPVBL4J/6k9NXkQ0e+floeecaHAMlvVBjdfbilp8jHZca6oFCCGSuXMDC0BD7+EzhTDVTQU1
	Now25Hqln1G9DAaS9ACfpW6f2rCyH2U4=
X-Received: by 2002:a05:6820:c8b:b0:6d6:bd40:5cc9 with SMTP id
 006d021491bc7-709422cb82emr2490276eaf.90.1792641249241; Wed, 21 Oct 2026
 20:54:09 -0700 (PDT)
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-In-Reply-To: <2773af2572ff59055933e407a135b39bca537381.1792607608.git.zhilinz@nebusec.ai>
X-Gmail-Original-Message-ID: <CAL4WiioBzbo81K2EVw8UQG6w70JS3D80GNoDndXFfcG-qAhUEw@mail.gmail.com>
X-Gm-Features: AclHuK8N5ds3Fw9LF2Dx9sFZR46QYMs5QxSl65xz5Fzea10VnJ8VVtAmE9IYTNI
X-Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, ncardwell@google.com, 
	kuniyu@google.com, davem@davemloft.net, pabeni@redhat.com, horms@kernel.org, 
	jonathon.reinhart@gmail.com, vega@nebusec.ai