From: asmadeus@codewreck.org
To: Dmitry Vyukov <dvyukov@google.com>
Cc: syzbot <syzbot+06472778c97ed94af66d@syzkaller.appspotmail.com>,
davem@davemloft.net, ericvh@gmail.com, glider@google.com,
kuba@kernel.org, linux-kernel@vger.kernel.org, lucho@ionkov.net,
netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com,
v9fs-developer@lists.sourceforge.net
Subject: Re: [syzbot] KMSAN: uninit-value in p9pdu_readf
Date: Mon, 11 Oct 2021 15:54:15 +0900 [thread overview]
Message-ID: <YWPfl8FFI5uKX499@codewreck.org> (raw)
In-Reply-To: <CACT4Y+bqD=EkkQB6hm+FVWVraDBChnRgqViLTqvmVrVM=1gH+w@mail.gmail.com>
Thanks for the reply,
Dmitry Vyukov wrote on Mon, Oct 11, 2021 at 07:56:05AM +0200:
> > would be 'len' in p9pdu_vreadf, which has to be set as far as I can understand:
> > > uint16_t len;
> > >
> > > errcode = p9pdu_readf(pdu, proto_version,
> > > "w", &len);
> > > if (errcode)
> > > break;
> > >
> > > *sptr = kmalloc(len + 1, GFP_NOFS);
> >
> > with relevant part of p9pdu_readf being:
> > > case 'w':{
> > > int16_t *val = va_arg(ap, int16_t *);
> > > __le16 le_val;
> > > if (pdu_read(pdu, &le_val, sizeof(le_val))) {
> > > errcode = -EFAULT;
> > > break;
> > > }
> > > *val = le16_to_cpu(le_val);
> > > }
> > > ...
> > > return errcode;
> >
> > e.g. either len or errcode should be set...
> >
> > But:
> > > Local variable ----ecode@p9_check_errors created at:
> > > p9_check_errors+0x68/0xb90 net/9p/client.c:506
> > > p9_client_rpc+0xd90/0x1410 net/9p/client.c:801
> >
> > is something totally different, p9_client_rpc happens before the
> > p9pdu_readf call in p9_client_stat, and ecode is local to
> > p9_check_errors, I don't see how it could get that far.
> >
> > Note that inspecting p9_check_errors manually, there is a case where
> > ecode is returned (indirectly through err = -ecode) without being
> > initialized,
>
> Does this connect both stacks? So the uinit is ecode, is it used in
> p9pdu_vreadf? If yes, then that's what KMSAN reported.
Hm...
Assuming that's the uninit, it'd have been propagated as the return
value as req = p9_client_rpc; passed the IS_ERR(req) check as not an
error, then passed to p9pdu_readf(&req->rc (later 'pdu')...)
That would then try to read some undefined address in pdu_read() as
memcpy(data, &pdu->sdata[pdu->offset], len)
and returning another undefined value as
sizeof(__le16) - min(pdu->size - pdu->offset, __le16)
Here magic should happen that makes this neither a success (would set
*val e.g. len in the kmalloc line that complains) or an error (would set
errcode e.g. p9pdu_vreadf() would return before reaching that line)
I guess with undefineds anything can happen and this is a valid link?
I would have assumed kmsan checks would fail sooner but I don't see what
else it could be.
> > so I will send a patch for that at least, but I have no
> > idea if that is what has been reported and it should be trivial to
> > reproduce so I do not see why syzbot does not have a reproducer -- it
> > retries running the last program that triggered the error before sending
> > the report, right?
>
> Yes.
Ok, I guess there are conditions on the undefined value to reach this
check down the road, even if the undefined return itself should be
always reproducible.
Either way Pavel Skripkin reached the same conclusion as me at roughly
the same time so I'll just go with it.
--
Dominique
next prev parent reply other threads:[~2021-10-11 6:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-10 5:48 [syzbot] KMSAN: uninit-value in p9pdu_readf syzbot
2021-10-10 8:36 ` asmadeus
2021-10-11 5:56 ` Dmitry Vyukov
2021-10-11 6:54 ` asmadeus [this message]
2021-10-11 7:02 ` Dmitry Vyukov
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=YWPfl8FFI5uKX499@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=davem@davemloft.net \
--cc=dvyukov@google.com \
--cc=ericvh@gmail.com \
--cc=glider@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=syzbot+06472778c97ed94af66d@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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).