Skip to content

Commit a360f31

Browse files
committed
9p: fix slab cache name creation for real
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: 79efeba ("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]>
1 parent d129377 commit a360f31

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
@@ -977,6 +977,7 @@ static int p9_client_version(struct p9_client *c)
977977
struct p9_client *p9_client_create(const char *dev_name, char *options)
978978
{
979979
int err;
980+
static atomic_t seqno = ATOMIC_INIT(0);
980981
struct p9_client *clnt;
981982
char *client_id;
982983
char *cache_name;
@@ -1036,7 +1037,8 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
10361037
if (err)
10371038
goto close_trans;
10381039

1039-
cache_name = kasprintf(GFP_KERNEL, "9p-fcall-cache-%s", dev_name);
1040+
cache_name = kasprintf(GFP_KERNEL,
1041+
"9p-fcall-cache-%u", atomic_inc_return(&seqno));
10401042
if (!cache_name) {
10411043
err = -ENOMEM;
10421044
goto close_trans;

0 commit comments

Comments
 (0)