From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B539606E81A for ; Wed, 4 Nov 2026 19:23:53 +0000 (UTC) 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=P31HtERM Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jKb2w0Hz8z2yTQ; Thu, 05 Nov 2026 06:23:52 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793820232; cv=none; b=d+g7V0eu26J27JSnebf5fph1Swurl1iJGS7T/vI977k0Cv5GXP6jTTNGmO1Q6bIY5BQkjQSF+DNxRFNbZUnlAIxiwPy76gpHSmfs6RG75Km75cqTi6z9tuSj+jn8+SugYoF5ocTmCN24kZgQoCE+PAmLIhpcwTJhuHbUrEQmZIlf8z6S+maI0SXdIO453hTM9hFKNhV4UmIy+4o7UGdkvR7yEHTLKrDKVm2DdQLUCxhZ/bNeFzqPQxBy3HO2PD9d+8/GCq9fCDuI1XaDw3coD56w0sMeJk8vzJQX6rKawkDHWI5QH9tCnuFHiD/5xJ0vzm+AKrI3GSVBvOG0LRVWJA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793820232; c=relaxed/relaxed; bh=bxrLiMapbfHc1EZ+4ADuNXD+VcOTR1takrrVPNDTeA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KCpngeUSvlL2A8i5Ud3l9nl45BGGxc66HDcvsDlMSMGwzHLb+5B7EkX+Lb3vw0rtSG91PoVQx5jCZisLUewP/TqoFCTHPSlp0cH8HTBb7S1ZQQmmYY/Uu02aqjEmJ9uAi0fNWve/HHweD7yBQ9oPwbg9TAF1Whom0rNMnYEAdl+45mBVFUbVX/KZ+K+VNieCcF7WUCFRFVgr5hxJ517V+uGkQMhX0luWFtQZEzSuK8Vove0LO5nuGRtbSa7evGGvBs5ngd1+WpLgq+K+sMwDTQshRhfx/1NJg6pPA63JqgoJnLcndpShxDZwOk2VuogOX7Cb2nPA3gByLAFa91mxTw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=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=P31HtERM; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P31HtERM; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jKb2v18rXz2y89 for ; Thu, 05 Nov 2026 06:23:51 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 477EF60AAB; Wed, 4 Nov 2026 19:23:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C06D31F000C1; Wed, 4 Nov 2026 19:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793820229; bh=bxrLiMapbfHc1EZ+4ADuNXD+VcOTR1takrrVPNDTeA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P31HtERMFSNol745g3BnGZcUyftsO75M5cryrOhg6uEEbTLO6qd91z1whz/V2YoHZ ZlzF0+NzxGOlzGJPmN3xtmGCNUFfLbt3joPtIH3f++AsuKwEwzdZWf6PdSPxU7A5yK hFlsOXtLhO48r6ueNfnwp0RlYnnSBnRpoiWgq0lskwVIqMMuSuxexcIO+FClliWYpS hoTGOlDLQflfOhdnS0Q3JIK9G3p3uFTRqKXWRJMZ3R4KfowrbaGqQRi07M1QXljwV7 th41CQpzl4loprGAQ2TnAnPwUAVWszzRtKlAOT9RVmKV+lhjT8YsGn0BrHVgoiFo6f 9SqeE0/BUHJiw== From: Christian Brauner 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 Subject: [PATCH RESEND v2 31/51] proc: don't WARN about a name that is already registered Date: Wed, 4 Nov 2026 20:23:34 +0100 Message-ID: <20261104-work-procfs-bugfixes-v2-31-021c84d852e0@kernel.org> In-Reply-To: <20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org> References: <20261104-work-procfs-bugfixes-v2-0-021c84d852e0@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2415; i=brauner@kernel.org; h=from:subject:message-id; bh=zKPnydEa7A3MJSKUBbljFnXGgiSfil9PV1OK0LsDT40=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS9bvz0UbupS+ReqKmx550QBcPIx+fCyiSlZmydoTxvS U2b4Fm+jlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIlcZGT4n20a3HVie8QyAeOH +n67d9j9VH0TdtVtZvPnw4Ent+xues3wh797msrH+LVBAu8/HVj4xtelPai56DjDmvc933d/ZL7 3hAsA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, 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 proc_register() WARNs when the directory already has an entry of the same name and fails the registration. Callers that pick their names themselves should never get there but some take names from userspace. pktgen creates a file for each device a writer of "add_device" adds, named after the device. A device can have any name, including "pgctrl" or "kpktgend_0", the names of pktgen's own files: ip link set lo name pgctrl ip link set pgctrl up echo "add_device pgctrl" > /proc/net/pktgen/kpktgend_0 proc_dir_entry 'pktgen/pgctrl' already registered WARNING: fs/proc/generic.c:404 at proc_register+0x555/0x8b0, CPU#0: bash/241 Call Trace: proc_create_data+0x9f/0xf0 pktgen_thread_write+0xd9b/0x1780 proc_reg_write+0x1c2/0x3c0 vfs_write+0x1cd/0xfa0 The files of a network namespace belong to the root of its user namespace and none of this requires a capability. So once pktgen is loaded an unprivileged user can taint the kernel, or crash it with panic_on_warn, from namespaces of its own. pktgen itself copes with the failed registration just fine. So go back to what proc_register() did before commit 6c2f91e077f1 ("proc: use WARN() rather than printk+backtrace") and what sysfs_warn_dup() does for sysfs: report the name with pr_warn() and dump the stack. While at it, do that after dropping proc_subdir_lock instead of printing a backtrace while holding the lock that every lookup and readdir in procfs needs. Reported-by: Chris Mason Fixes: 6c2f91e077f1 ("proc: use WARN() rather than printk+backtrace") Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner (Amutable) --- fs/proc/generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 6ac9c4c13897..9e59796349e1 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -402,9 +402,10 @@ struct proc_dir_entry *proc_register(struct proc_dir_entry *dir, write_lock(&proc_subdir_lock); dp->parent = dir; if (pde_subdir_insert(dir, dp) == false) { - WARN(1, "proc_dir_entry '%s/%s' already registered\n", - dir->name, dp->name); write_unlock(&proc_subdir_lock); + pr_warn("proc_dir_entry '%s/%s' already registered\n", + dir->name, dp->name); + dump_stack(); goto out_free_inum; } write_unlock(&proc_subdir_lock); -- 2.53.0