Merge tag '9p-for-4.21' of git://github.com/martinetd/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Jan 2019 20:11:01 +0000 (12:11 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Jan 2019 20:11:01 +0000 (12:11 -0800)
Pull 9p updates from Dominique Martinet:
 "Missing prototype warning fix and a syzkaller fix when a 9p server
  advertises a too small msize"

* tag '9p-for-4.21' of git://github.com/martinetd/linux:
  9p/net: put a lower bound on msize
  net/9p: include trans_common.h to fix missing prototype warning.

net/9p/client.c
net/9p/trans_common.c

index 2c9a17b9b46bb344897691d5f53c94a90e25c3c8..357214a51f13853ba1bac594f35938bdeacfd232 100644 (file)
@@ -181,6 +181,12 @@ static int parse_opts(char *opts, struct p9_client *clnt)
                                ret = r;
                                continue;
                        }
+                       if (option < 4096) {
+                               p9_debug(P9_DEBUG_ERROR,
+                                        "msize should be at least 4k\n");
+                               ret = -EINVAL;
+                               continue;
+                       }
                        clnt->msize = option;
                        break;
                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 {
+               p9_debug(P9_DEBUG_ERROR,
+                        "server returned an unknown version: %s\n", version);
                err = -EREMOTEIO;
                goto error;
        }
 
+       if (msize < 4096) {
+               p9_debug(P9_DEBUG_ERROR,
+                        "server returned a msize < 4096: %d\n", msize);
+               err = -EREMOTEIO;
+               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) {
+               p9_debug(P9_DEBUG_ERROR,
+                        "Please specify a msize of at least 4k\n");
+               err = -EINVAL;
+               goto free_client;
+       }
+
        err = p9_client_version(clnt);
        if (err)
                goto close_trans;
index b718db2085b21c8583601a3c9aa23414dc16ef3b..3dff68f05fb91a38b1e00b5ab7a3ee306265a460 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/mm.h>
 #include <linux/module.h>
+#include "trans_common.h"
 
 /**
  *  p9_release_pages - Release pages after the transaction.