Skip to content

Commit 9da3636

Browse files
torvaldsgregkh
authored andcommitted
9p: fix slab cache name creation for real
commit a360f31 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 <osandov@fb.com> Link: https://lore.kernel.org/all/ZxafcO8KWMlXaeWE@telecaster.dhcp.thefacebook.com/ Fixes: 79efeba ("9p: Avoid creating multiple slab caches with the same name") Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Dominique Martinet <asmadeus@codewreck.org> Cc: Thorsten Leemhuis <regressions@leemhuis.info> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fc4951c commit 9da3636

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

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

0 commit comments

Comments
 (0)