9p: fix multiple NULL-pointer-dereferences
authorTomas Bortoli <tomasbortoli@gmail.com>
Fri, 27 Jul 2018 11:05:58 +0000 (13:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Sep 2018 18:04:34 +0000 (20:04 +0200)
commit 10aa14527f458e9867cf3d2cc6b8cb0f6704448b upstream.

Added checks to prevent GPFs from raising.

Link: http://lkml.kernel.org/r/20180727110558.5479-1-tomasbortoli@gmail.com
Signed-off-by: Tomas Bortoli <tomasbortoli@gmail.com>
Reported-by: syzbot+1a262da37d3bead15c39@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/9p/trans_fd.c
net/9p/trans_rdma.c
net/9p/trans_virtio.c

index c923221..2f68ffd 100644 (file)
@@ -935,7 +935,7 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
        if (err < 0)
                return err;
 
-       if (valid_ipaddr4(addr) < 0)
+       if (addr == NULL || valid_ipaddr4(addr) < 0)
                return -EINVAL;
 
        csocket = NULL;
@@ -983,6 +983,9 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)
 
        csocket = NULL;
 
+       if (addr == NULL)
+               return -EINVAL;
+
        if (strlen(addr) >= UNIX_PATH_MAX) {
                pr_err("%s (%d): address too long: %s\n",
                       __func__, task_pid_nr(current), addr);
index 52b4a2f..f42550d 100644 (file)
@@ -644,6 +644,9 @@ rdma_create_trans(struct p9_client *client, const char *addr, char *args)
        struct ib_qp_init_attr qp_attr;
        struct ib_cq_init_attr cq_attr = {};
 
+       if (addr == NULL)
+               return -EINVAL;
+
        /* Parse the transport specific mount options */
        err = parse_opts(args, &opts);
        if (err < 0)
index 669198a..6018a1c 100644 (file)
@@ -654,6 +654,9 @@ p9_virtio_create(struct p9_client *client, const char *devname, char *args)
        int ret = -ENOENT;
        int found = 0;
 
+       if (devname == NULL)
+               return -EINVAL;
+
        mutex_lock(&virtio_9p_lock);
        list_for_each_entry(chan, &virtio_chan_list, chan_list) {
                if (!strncmp(devname, chan->tag, chan->tag_len) &&