[Linux-kernel-mentees] [PATCH net] net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid
asmadeus at codewreck.org
Mon Oct 12 07:59:10 UTC 2020
Anant Thazhemadam wrote on Mon, Oct 12, 2020:
> 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.
I'm not sure I agree a fully zeroed address is faulty but I agree we can
probably refuse it given userspace can't pass useful abstract addresses
Just one nitpick but this is otherwise fine - good catch!
> Reported-by: syzbot+75d51fe5bf4ebe988518 at syzkaller.appspotmail.com
> Tested-by: syzbot+75d51fe5bf4ebe988518 at syzkaller.appspotmail.com
> Signed-off-by: Anant Thazhemadam <anant.thazhemadam at gmail.com>
> net/9p/trans_fd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
> index c0762a302162..8f528e783a6c 100644
> --- a/net/9p/trans_fd.c
> +++ b/net/9p/trans_fd.c
> @@ -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))
Since we don't care about the actual length here, how about checking for
That'll spare a strlen() call in the valid case.
Well, I guess it doesn't really matter -- I'll queue this up anyway and
update if you resend.
More information about the Linux-kernel-mentees