From: Anant Thazhemadam <anant.thazhemadam@gmail.com>
To: Dominique Martinet <asmadeus@codewreck.org>
Cc: lucho@ionkov.net,
syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com,
ericvh@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kuba@kernel.org,
v9fs-developer@lists.sourceforge.net,
linux-kernel-mentees@lists.linuxfoundation.org,
davem@davemloft.net
Subject: Re: [Linux-kernel-mentees] [PATCH net] net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid
Date: Mon, 12 Oct 2020 14:47:50 +0530 [thread overview]
Message-ID: <147004bd-5cff-6240-218d-ebd80a9b48a1@gmail.com> (raw)
In-Reply-To: <20201012075910.GA17745@nautica>
On 12-10-2020 13:29, Dominique Martinet wrote:
> 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
> here.
Understood. It's probably a better that I modify the commit message a little and
send a v2 so it becomes more accurate.
> Just one nitpick but this is otherwise fine - good catch!
Thank you!
>
>> Reported-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
>> Tested-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
>> Signed-off-by: Anant Thazhemadam <anant.thazhemadam@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
> addr[0] directly?
> That'll spare a strlen() call in the valid case.
>
You mentioned how a fully zeroed address isn't exactly faulty. By extension, wouldn't that
mean that an address that simply begins with a 0 isn't faulty as well?
This is an interesting point, because if the condition is modified to checking for addr[0] directly,
addresses that simply begin with 0 (but have more non-zero content following) wouldn't be
copied over either, right?
In the end, it comes down to what you define as a "valid" value that sun_path can have.
We've already agreed that a fully zeroed address wouldn't qualify as a valid value for sun_path.
Are addresses that aren't fully zeroed, but only begin with a 0 also to be considered as an
unacceptable value for sun_path?
Thanks,
Anant
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next prev parent reply other threads:[~2020-10-12 9:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 4:24 [Linux-kernel-mentees] [PATCH net] net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid Anant Thazhemadam
2020-10-12 7:59 ` Dominique Martinet
2020-10-12 9:17 ` Anant Thazhemadam [this message]
2020-10-12 10:40 ` Dominique Martinet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=147004bd-5cff-6240-218d-ebd80a9b48a1@gmail.com \
--to=anant.thazhemadam@gmail.com \
--cc=asmadeus@codewreck.org \
--cc=davem@davemloft.net \
--cc=ericvh@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).