From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B127860A380E for ; Mon, 2 Nov 2026 14:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=bVhxTWaR; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nzlwkTf1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=PBbW9vd5orssW5wPAFhy4fJ1NNWUPnjkdaOH9xfStLQ=; b=bVhxTWaRRdW3ab qwmIhIxNpWLp0CQqjZ+9yJGVhhTa8+DIVMD+FqEdD98A+SxGq0SVzRAuxFzYORKqYli5EN/4Bo+cs s3W3jvaNzwdO744ph8+CCJVhHEgvi77glWjWGq6ICQb51wyFJMiVXdr7BdYV9ifba4ciGcAdgkAYt xfvW4L70w+trdu89IVDkKmSC0te9P7f0NTpLikRY+I5RcLqa4HEr38TGruhmtSKcznH8hSit5NBtF Xx/rYOtk8wSkQ8/8Z7150doPzjb/KbSOnWKPBttgt90JTjP7S0d7sTzpICCn9j0vDTqajZWhe/WgQ v0W0iWGszQd9lgdhWRLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xNsvh-0000000Gm8n-1sNs; Mon, 02 Nov 2026 14:22:33 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xNsvf-0000000Gm8E-2KfZ; Mon, 02 Nov 2026 14:22:31 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5059143C6C; Mon, 2 Nov 2026 14:22:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D95AB1F00A16; Mon, 2 Nov 2026 14:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793629351; bh=PBbW9vd5orssW5wPAFhy4fJ1NNWUPnjkdaOH9xfStLQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=nzlwkTf15kz/wAHmBv8TBSldFi6uEzRKAH35yysNrDb/8c4TQ0GCZP0ASoI6HN4b+ ehOxeihtKt2HTRVjPCKuuAHd7Yek+ODFrF9sc7qm/JijqtRdS5y2myAabKFf6nxaRY 9Pas0GKbkNwOm8LlfgjzjeZcMkMcrZUeHJnggcdEQMEsZzosFpVfMgmLvRZKouwlv7 JAi2ZqGrZot0jagbs1UODwU5a1zpC6WH70gNu4gGQL2YE+NPG7eToPVeRi3etVDvtY UcK5AZNwgPpnQ1ESM5OY+AU4XnwA5+oNTxzQWf3Lr2JUxoYKEPM809nyjile28GSz9 DmBqBJEb70aSw== From: Christian Brauner Date: Mon, 02 Nov 2026 15:21:18 +0100 Subject: [PATCH RFC 03/38] netfilter: xt_recent: don't remove the proc entries under a spinlock X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261102-work-procfs-bugfixes-v1-3-59422ed3e465@kernel.org> References: <20261102-work-procfs-bugfixes-v1-0-59422ed3e465@kernel.org> In-Reply-To: <20261102-work-procfs-bugfixes-v1-0-59422ed3e465@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Jann Horn , Josef Bacik , Chris Mason , Jeff Layton , NeilBrown , Eric Dumazet , Thomas Gleixner , Al Viro , Jonathan Corbet , Christoph Hellwig , Greg Kroah-Hartman , Joel Granados , Kees Cook , Jan Kara , Jan Kara , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-um@lists.infradead.org, linux-wireless@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, ntfs3@lists.linux.dev, platform-driver-x86@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, netfilter-devel@vger.kernel.org, dri-devel@lists.freedesktop.org, ibm-acpi-devel@lists.sourceforge.net, jfs-discussion@lists.sourceforge.net, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cifs@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-usb@vger.kernel.org, samba-technical@lists.samba.org, sparclinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-doc@vger.kernel.org, linux-serial@vger.kernel.org, linux-atm-general@lists.sourceforge.net, Takashi Iwai , linux-input@vger.kernel.org, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org, linux-debuggers@vger.kernel.org, "Christian Brauner (Amutable)" , Chuck Lever , stable@vger.kernel.org X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2627; i=brauner@kernel.org; h=from:subject:message-id; bh=boUkBs9MzJMgPbYDfsAEaTT4QAw3bhdvazLBbZuX36o=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS9mJP1dtcCf06Gp9u3x217c+fnxNyHHy8FLGAsr+cWj t0U+GBRZEcpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBFXBgZOrZozFPorf+h0Kmk 8bQ8/Jz+9tqixhUCbka+M1baPWjgZ/grk3zOPFaz+iTnzmKxIH+uEl0pWY3mLRIpLJ96Q+YuEGU BAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 recent_proc_net_exit() removes the proc entries of all tables with recent_lock held. remove_proc_entry() waits until nobody calls into the entry anymore, and reading one of them takes recent_lock in recent_seq_start() while procfs has the entry pinned. So when a reader gets there while the network namespace goes away, the exit path sleeps with a spinlock held and bh disabled, waiting for a reader that spins on that very lock: BUG: sleeping function called from invalid context at kernel/sched/completion.c:116 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 12, name: kworker/u16:0 locks held by kworker/u16:0/12: 4, last CPU#2: #2: (pernet_ops_rwsem){++++}-{4:4}, at: cleanup_net+0xbf/0x860 #3: (recent_lock){+...}-{3:3}, at: recent_net_exit+0x3d/0x170 [xt_recent] Workqueue: netns cleanup_net Call Trace: wait_for_completion+0x8e/0x400 proc_entry_rundown+0x1ab/0x1f0 remove_proc_entry+0x1ab/0x530 recent_net_exit+0x9f/0x170 [xt_recent] ops_undo_list+0x271/0x8d0 cleanup_net+0x3f3/0x860 process_one_work+0x946/0x1820 BUG: scheduling while atomic: kworker/u16:0/12/0x00000202 watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [rloop:252] Call Trace: _raw_spin_lock_bh+0x7a/0x80 recent_seq_start+0x86/0x1e0 [xt_recent] seq_read_iter+0x26d/0x1230 seq_read+0x2a9/0x560 proc_reg_read+0x1c2/0x3c0 vfs_read+0x176/0xb40 __x64_sys_pread64+0x191/0x250 Tables are added and removed with recent_mutex held and that's also what recent_mt_destroy() looks at ->xt_recent under. Nothing that runs with a proc entry pinned takes it. So take recent_mutex instead. Fixes: 665e205c16c1 ("netfilter: xt_recent: fix namespace destroy path") Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner (Amutable) --- net/netfilter/xt_recent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c index 55f1f2d89952..11acb9a50d4b 100644 --- a/net/netfilter/xt_recent.c +++ b/net/netfilter/xt_recent.c @@ -652,12 +652,12 @@ static void __net_exit recent_proc_net_exit(struct net *net) * that the parent xt_recent proc entry is empty before trying to * remove it. */ - spin_lock_bh(&recent_lock); + mutex_lock(&recent_mutex); list_for_each_entry(t, &recent_net->tables, list) remove_proc_entry(t->name, recent_net->xt_recent); recent_net->xt_recent = NULL; - spin_unlock_bh(&recent_lock); + mutex_unlock(&recent_mutex); remove_proc_entry("xt_recent", net->proc_net); } -- 2.53.0