Skip to content

Commit 6a8d39e

Browse files
torvaldsgregkh
authored andcommitted
9p: fix slab cache name creation for real
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 <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Fixes: 79efebae4afc ("9p: Avoid creating multiple slab caches with the same name") Acked-by: Vlastimil Babka <[email protected]> Cc: Dominique Martinet <[email protected]> Cc: Thorsten Leemhuis <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 509c1c6 commit 6a8d39e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/9p/client.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ static int p9_client_version(struct p9_client *c)
967967
struct p9_client *p9_client_create(const char *dev_name, char *options)
968968
{
969969
int err;
970+
static atomic_t seqno = ATOMIC_INIT(0);
970971
struct p9_client *clnt;
971972
char *client_id;
972973
char *cache_name;
@@ -1027,7 +1028,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
10271028
if (err)
10281029
goto close_trans;
10291030

1030-
cache_name = kasprintf(GFP_KERNEL, "9p-fcall-cache-%s", dev_name);
1031+
cache_name = kasprintf(GFP_KERNEL,
1032+
"9p-fcall-cache-%u", atomic_inc_return(&seqno));
10311033
if (!cache_name) {
10321034
err = -ENOMEM;
10331035
goto close_trans;

0 commit comments

Comments
 (0)