From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23EBE186294; Fri, 15 Nov 2024 06:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731653524; cv=none; b=rDW53ElEjT45rmzSM1HOH6/D/QDL1yj9rPtLp8IjrQoMPxUzJHr2eBFQ7tRf8ggNT2cWFeX5hL3ilhzw/zt3a39QSILBuJF+xXrqnKhGZm6xYML7TUSdcvPldzvf0V6aLnvwVteDzvzYuDk8AW0bGhT/lVfDlkoniRAcQUECFG4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731653524; c=relaxed/simple; bh=8OiAnDm9+o7KNmmX8m5zoEbBDhLj4vLgrH8TtDz5H/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=McMeUvurDBu67Q49Dt/TR73grmjNd7tB9hlSOGRhxZfklhIudDojyH0JRc4N4YQixf8312EGM4FcwLVj+/Lj6S6dPKPwYBUZTDN3KrAcHg/I/uVbIiJc5uRzX/tF0hlqP1Jl3MIwg0yWzykAicPR3rxCV8N1gX2bcAk8r8/kGrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OIhVL/lT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OIhVL/lT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 948D6C4CECF; Fri, 15 Nov 2024 06:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1731653524; bh=8OiAnDm9+o7KNmmX8m5zoEbBDhLj4vLgrH8TtDz5H/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIhVL/lTSVRKKGH/y6yz22FRBxfIWkHfnyygItVW/f6bU0N2+YcLqEZlL1HDtf4XD xUZlaxpo0YGe8T+5w2MkGeEnSIG8wbCXz8Sgna2rpQh+Uqup5FFQoSN6tCA/T5Ig/J VIfWzBUOOWNcPEmEHTmvu/xcLa5YPfJBTt7py0X4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vlastimil Babka , Dominique Martinet , Thorsten Leemhuis , Linus Torvalds , Omar Sandoval Subject: [PATCH 6.6 48/48] 9p: fix slab cache name creation for real Date: Fri, 15 Nov 2024 07:38:37 +0100 Message-ID: <20241115063724.696145094@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241115063722.962047137@linuxfoundation.org> References: <20241115063722.962047137@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Torvalds commit a360f311f57a36e96d88fa8086b749159714dcd2 upstream. This was attempted by using the dev_name in the slab cache name, but as Omar Sandoval pointed out, that can be an arbitrary string, eg something like "/dev/root". Which in turn trips verify_dirent_name(), which fails if a filename contains a slash. So just make it use a sequence counter, and make it an atomic_t to avoid any possible races or locking issues. Reported-and-tested-by: Omar Sandoval Link: https://lore.kernel.org/all/ZxafcO8KWMlXaeWE@telecaster.dhcp.thefacebook.com/ Fixes: 79efebae4afc ("9p: Avoid creating multiple slab caches with the same name") Acked-by: Vlastimil Babka Cc: Dominique Martinet Cc: Thorsten Leemhuis Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- net/9p/client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/9p/client.c +++ b/net/9p/client.c @@ -976,6 +976,7 @@ error: struct p9_client *p9_client_create(const char *dev_name, char *options) { int err; + static atomic_t seqno = ATOMIC_INIT(0); struct p9_client *clnt; char *client_id; char *cache_name; @@ -1035,7 +1036,8 @@ struct p9_client *p9_client_create(const if (err) goto close_trans; - cache_name = kasprintf(GFP_KERNEL, "9p-fcall-cache-%s", dev_name); + cache_name = kasprintf(GFP_KERNEL, + "9p-fcall-cache-%u", atomic_inc_return(&seqno)); if (!cache_name) { err = -ENOMEM; goto close_trans;