[PATCH] 9p: fix NULL pointer dereferences

From: Tomas Bortoli
Date: Thu Jul 26 2018 - 04:11:02 EST


In p9_fd_create_tcp() and p9_fd_create_unix() it is possible to get
a NULL value in the addr parameter. Return -EINVAL in such cases.

Signed-off-by: Tomas Bortoli <tomasbortoli@xxxxxxxxx>
Reported-by: syzbot+1a262da37d3bead15c39@xxxxxxxxxxxxxxxxxxxxxxxxx
---
net/9p/trans_fd.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 964260265b13..ecfceb659d0c 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -941,6 +941,9 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
struct sockaddr_in sin_server;
struct p9_fd_opts opts;

+ if (addr == NULL)
+ return -EINVAL;
+
err = parse_opts(args, &opts);
if (err < 0)
return err;
@@ -995,6 +998,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);
--
2.11.0