From: Greg KH <gregkh@linuxfoundation.org>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: syzbot <syzbot+a7e220df5a81d1ab400e@syzkaller.appspotmail.com>,
Andrey Konovalov <andreyknvl@google.com>,
balbi@kernel.org, Dan Carpenter <dan.carpenter@oracle.com>,
Alexander Potapenko <glider@google.com>,
LKML <linux-kernel@vger.kernel.org>,
USB list <linux-usb@vger.kernel.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: KMSAN: kernel-infoleak in raw_ioctl
Date: Mon, 10 Aug 2020 13:06:16 +0200 [thread overview]
Message-ID: <20200810110616.GA2415197@kroah.com> (raw)
In-Reply-To: <CACT4Y+badWwK8L3HjYrv2nu-W+WnUfj5Pi2JsLTUMU3o2tJL9g@mail.gmail.com>
On Mon, Aug 10, 2020 at 12:21:49PM +0200, Dmitry Vyukov wrote:
> On Mon, Aug 10, 2020 at 11:57 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Aug 10, 2020 at 11:15:38AM +0200, Greg KH wrote:
> > > On Mon, Aug 10, 2020 at 11:08:33AM +0200, Greg KH wrote:
> > > > On Mon, Aug 10, 2020 at 11:00:07AM +0200, Dmitry Vyukov wrote:
> > > > > On Mon, Aug 10, 2020 at 9:46 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > > > > >
> > > > > > On Sun, Aug 09, 2020 at 09:27:18AM -0700, syzbot wrote:
> > > > > > > Hello,
> > > > > > >
> > > > > > > syzbot found the following issue on:
> > > > > > >
> > > > > > > HEAD commit: ce8056d1 wip: changed copy_from_user where instrumented
> > > > > > > git tree: https://github.com/google/kmsan.git master
> > > > > > > console output: https://syzkaller.appspot.com/x/log.txt?x=141eb8b2900000
> > > > > > > kernel config: https://syzkaller.appspot.com/x/.config?x=3afe005fb99591f
> > > > > > > dashboard link: https://syzkaller.appspot.com/bug?extid=a7e220df5a81d1ab400e
> > > > > > > compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
> > > > > > > userspace arch: i386
> > > > > > >
> > > > > > > Unfortunately, I don't have any reproducer for this issue yet.
> > > > > >
> > > > > > The irony of a kernel module written for syzbot testing, causing syzbot
> > > > > > reports....
> > > > >
> > > > > The raw gadget and KCOV are also kernel code and subject to all the
> > > > > same rules as any other kernel code from syzkaller point of view.
> > > > >
> > > > > But I think the root cause of this bug is the origin of the uninitialized-ness:
> > > > >
> > > > > Local variable ----buf.i@asix_get_phy_addr created at:
> > > > > asix_read_cmd drivers/net/usb/asix_common.c:312 [inline]
> > > > > asix_read_phy_addr drivers/net/usb/asix_common.c:295 [inline]
> > > > > asix_get_phy_addr+0x4d/0x290 drivers/net/usb/asix_common.c:314
> > > > > asix_read_cmd drivers/net/usb/asix_common.c:312 [inline]
> > > > > asix_read_phy_addr drivers/net/usb/asix_common.c:295 [inline]
> > > > > asix_get_phy_addr+0x4d/0x290 drivers/net/usb/asix_common.c:314
> > > >
> > > > read buffers sent to USB hardware are ment to be filled in by the
> > > > hardware with the data received from it, we do not zero-out those
> > > > buffers before passing the pointer there.
> > > >
> > > > Perhaps with testing frameworks like the raw usb controller, that might
> > > > cause a number of false-positives to happen?
> > >
> > > Ah, wait, that buffer is coming from the stack, which isn't allowed in
> > > the first place :(
> > >
> > > So that should be changed anyway to a dynamic allocation, I'll go write
> > > up a patch...
> >
> > Nope, my fault, the data is not coming from the stack, so all is good.
>
> My reading of the code is that asix_read_cmd returns the number of
> bytes actually read, which may be less than requested.
> This happens in __usbnet_read_cmd:
> https://elixir.bootlin.com/linux/latest/source/drivers/net/usb/usbnet.c#L2002
> So this code in asix_read_phy_addr will need produce an uninit value
> for result if <2 bytes read:
>
> u8 buf[2];
> int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf, 0);
> if (ret < 0)
> netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret);
> ret = buf[offset];
> return ret;
>
> And it looks like all of 13 uses of asix_read_cmd in
> drivers/net/usb/asix_common.c are subject to this bug as well.
Ah, yeah, and no one checks error values either, there's even a TODO
statement in the driver about that :(
Good catch, I'll point some interns at this and see if they can fix it
up, thanks!
greg k-h
next prev parent reply other threads:[~2020-08-10 11:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-09 16:27 KMSAN: kernel-infoleak in raw_ioctl syzbot
2020-08-10 7:47 ` Greg KH
2020-08-10 9:00 ` Dmitry Vyukov
2020-08-10 9:08 ` Greg KH
2020-08-10 9:15 ` Greg KH
2020-08-10 9:57 ` Greg KH
2020-08-10 10:21 ` Dmitry Vyukov
2020-08-10 11:06 ` Greg KH [this message]
2020-08-10 14:07 ` Andrey Konovalov
2020-08-10 14:17 ` Dmitry Vyukov
2020-08-19 6:33 ` syzbot
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=20200810110616.GA2415197@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=andreyknvl@google.com \
--cc=balbi@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+a7e220df5a81d1ab400e@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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).