From: Greg KH <gregkh@linuxfoundation.org>
To: Edward Adam Davis <eadavis@qq.com>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
syzbot+9d34f80f841e948c3fdb@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] USB: usbtmc: prevent kernel-infoleak
Date: Thu, 5 Sep 2024 16:04:31 +0200 [thread overview]
Message-ID: <2024090522-gauntlet-dropper-7590@gregkh> (raw)
In-Reply-To: <tencent_70402C916F4897E0E81EEEEACE287B726D0A@qq.com>
On Thu, Sep 05, 2024 at 09:56:53PM +0800, Edward Adam Davis wrote:
> On Wed, 4 Sep 2024 16:13:03 +0200, Greg KH wrote:
> > On Wed, Sep 04, 2024 at 04:09:15PM +0200, Greg KH wrote:
> > > On Wed, Sep 04, 2024 at 09:55:43PM +0800, Edward Adam Davis wrote:
> > > > The syzbot reported a kernel-usb-infoleak in usbtmc_write,
> > > > we need to clear the structure before filling fields.
> > >
> > > Really?
> > >
> > >
> > > >
> > > > Fixes: 4ddc645f40e9 ("usb: usbtmc: Add ioctl for vendor specific write")
> > > > Reported-and-tested-by: syzbot+9d34f80f841e948c3fdb@syzkaller.appspotmail.com
> > > > Closes: https://syzkaller.appspot.com/bug?extid=9d34f80f841e948c3fdb
> > > > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > > > ---
> > > > drivers/usb/class/usbtmc.c | 1 +
> > > > 1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> > > > index 6bd9fe565385..e9ddaa9b580d 100644
> > > > --- a/drivers/usb/class/usbtmc.c
> > > > +++ b/drivers/usb/class/usbtmc.c
> > > > @@ -759,6 +759,7 @@ static struct urb *usbtmc_create_urb(void)
> > > > usb_free_urb(urb);
> > > > return NULL;
> > > > }
> > > > + memset(dmabuf, 0, bufsize);
> > >
> > > To do this simpler, kzmalloc() above this would be nice.
> > >
> > > But, this feels odd, where is the data leaking from? This is used for
> > > both the read and write path, but where is the leak happening? A short
> > > read? If so, we need to properly truncate the buffer being sent to
> > > userspace and not send the unread data. If a short write, that makes no
> > > sense.
> A short write.
> >
> > I looked at the report and this seems to be data sent to the device, so
> > somehow we aren't setting the length to send to the device correctly.
> The length of the data passed in by the user is 3 bytes, plus a TMC header
> length of 12 bytes and an additional 3 bytes. The actual length of the
> data sent to the device is 16 bytes((3 + 12 + 3)~3 = 16).
>
> Normally, when executing copy_from_user, the 3 bytes data passed in by
> the user is written after the TMC header, which initializes the first 15
> bytes of the 16 bytes. But it is not yet clear why the 15th byte is not
> initialized. The kernel data leaked to user space reported by Syzbot
> should be it.
But why are we sending 16 bytes to the device? Is that the format of
the message it expects? If so, that's fine, just set that byte to 0.
And as the device is the thing that is getting the kernel memory, that
really isn't a big deal as we "trust" hardware once it is up and talking
to the kernel.
thanks,
greg k-h
next prev parent reply other threads:[~2024-09-05 14:04 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 9:14 [syzbot] [usb?] KMSAN: kernel-usb-infoleak in usbtmc_write syzbot
2024-09-04 12:00 ` syzbot
2024-09-04 12:47 ` Edward Adam Davis
2024-09-04 13:33 ` syzbot
2024-09-04 13:55 ` [PATCH] USB: usbtmc: prevent kernel-infoleak Edward Adam Davis
2024-09-04 14:09 ` Greg KH
2024-09-04 14:13 ` Greg KH
2024-09-05 13:56 ` Edward Adam Davis
2024-09-05 14:04 ` Greg KH [this message]
2024-09-05 14:16 ` Edward Adam Davis
2024-09-06 14:11 ` [PATCH V2] USB: usbtmc: prevent kernel-usb-infoleak Edward Adam Davis
2024-09-06 14:28 ` Alan Stern
2024-09-07 2:08 ` Edward Adam Davis
2024-09-07 14:45 ` Alan Stern
2024-09-08 0:59 ` Edward Adam Davis
2024-09-08 1:32 ` Alan Stern
2024-09-08 2:01 ` Edward Adam Davis
2024-09-08 2:20 ` [PATCH V3] " Edward Adam Davis
2024-09-08 5:20 ` Greg KH
2024-09-08 7:35 ` Edward Adam Davis
2024-09-08 7:54 ` Greg KH
2024-09-08 8:16 ` Edward Adam Davis
2024-09-08 8:33 ` Greg KH
2024-09-08 9:17 ` [PATCH v4] " Edward Adam Davis
2024-09-05 11:27 ` [syzbot] [usb?] KMSAN: kernel-usb-infoleak in usbtmc_write Edward Adam Davis
2024-09-05 15:42 ` syzbot
2024-09-05 14:21 ` Edward Adam Davis
2024-09-05 16:11 ` syzbot
2024-09-06 11:55 ` Edward Adam Davis
2024-09-06 12:29 ` syzbot
2024-09-06 12:37 ` Edward Adam Davis
2024-09-06 13:07 ` syzbot
2024-09-06 13:06 ` Edward Adam Davis
2024-09-06 13:51 ` syzbot
2024-09-06 13:52 ` Edward Adam Davis
2024-09-06 16:59 ` syzbot
2024-09-05 7:11 ` [syzbot] " syzbot
2024-09-05 8:29 ` 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=2024090522-gauntlet-dropper-7590@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+9d34f80f841e948c3fdb@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