Skip to content

Commit

Permalink
net: 9p: initialize sun_server.sun_path to have addr's value only whe…
Browse files Browse the repository at this point in the history
…n addr is valid

[ Upstream commit 7ca1db2 ]

In p9_fd_create_unix, checking is performed to see if the addr (passed
as an argument) is NULL or not.
However, no check is performed to see if addr is a valid address, i.e.,
it doesn't entirely consist of only 0's.
The initialization of sun_server.sun_path to be equal to this faulty
addr value leads to an uninitialized variable, as detected by KMSAN.
Checking for this (faulty addr) and returning a negative error number
appropriately, resolves this issue.

Link: http://lkml.kernel.org/r/20201012042404.2508-1-anant.thazhemadam@gmail.com
Reported-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
Tested-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
thazhemadam authored and gregkh committed Nov 5, 2020
1 parent 4c59583 commit 07f5e25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/9p/trans_fd.c
Expand Up @@ -1023,7 +1023,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)

csocket = NULL;

if (addr == NULL)
if (!addr || !strlen(addr))
return -EINVAL;

if (strlen(addr) >= UNIX_PATH_MAX) {
Expand Down

0 comments on commit 07f5e25

Please sign in to comment.