Commit 7030ab2d authored by Dominique Martinet's avatar Dominique Martinet Committed by Greg Kroah-Hartman

9p/net: put a lower bound on msize

commit 574d356b upstream.

If the requested msize is too small (either from command line argument
or from the server version reply), we won't get any work done.
If it's *really* too small, nothing will work, and this got caught by
syzbot recently (on a new kmem_cache_create_usercopy() call)

Just set a minimum msize to 4k in both code paths, until someone
complains they have a use-case for a smaller msize.

We need to check in both mount option and server reply individually
because the msize for the first version request would be unchecked
with just a global check on clnt->msize.

Signed-off-by: default avatarDominique Martinet <>
Cc: Eric Van Hensbergen <>
Cc: Latchesar Ionkov <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 0fc78fa0
......@@ -181,6 +181,12 @@ static int parse_opts(char *opts, struct p9_client *clnt)
ret = r;
if (option < 4096) {
"msize should be at least 4k\n");
ret = -EINVAL;
clnt->msize = option;
case Opt_trans:
......@@ -983,10 +989,18 @@ static int p9_client_version(struct p9_client *c)
else if (!strncmp(version, "9P2000", 6))
c->proto_version = p9_proto_legacy;
else {
"server returned an unknown version: %s\n", version);
goto error;
if (msize < 4096) {
"server returned a msize < 4096: %d\n", msize);
goto error;
if (msize < c->msize)
c->msize = msize;
......@@ -1043,6 +1057,13 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
if (clnt->msize > clnt->trans_mod->maxsize)
clnt->msize = clnt->trans_mod->maxsize;
if (clnt->msize < 4096) {
"Please specify a msize of at least 4k\n");
err = -EINVAL;
goto free_client;
err = p9_client_version(clnt);
if (err)
goto close_trans;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment