Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1388763

Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c

From Julia Lawall <julia.lawall@lip6.fr>
Newsgroups linux.kernel
Subject Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c
Date 2016-04-27 10:10 +0200
Message-ID <rssHM-6hy-17@gated-at.bofh.it> (permalink)
References <rsjEt-7bd-13@gated-at.bofh.it> <rsjEt-7bd-11@gated-at.bofh.it> <rsqwh-46L-1@gated-at.bofh.it> <rssHM-6hy-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On Wed, 27 Apr 2016, Dan Carpenter wrote:

> On Wed, Apr 27, 2016 at 07:42:04AM +0200, Julia Lawall wrote:
> >
> >
> > On Tue, 26 Apr 2016, Kees Cook wrote:
> >
> > > On Mon, Apr 25, 2016 at 7:50 AM, Pengfei Wang <wpengfeinudt@gmail.com> wrote:
> > > > Hello,
> > > >
> > > > I found this Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c
> > > > when I was examining the source code.
> > >
> > > Thanks for these reports! I wrote a coccinelle script to find these,
> > > but it requires some manual checking. For what it's worth, it found
> > > your report as well:
> > >
> > > ./drivers/scsi/aacraid/commctrl.c:116:5-19: potentially dangerous
> > > second copy_from_user()
> > >
> > > So I should probably get this added to the coccicheck run... Maybe it
> > > can get some clean up from Julia. :)
> >
> > I looked a bit at the results, and didn't see anything obvious.  What is
> > the problem, exactly, and what would be a characteristic of a false
> > positive?
> >
>
>
> 	copy_from_user(dest, src, sizeof(dest));
>
> 	if (dest.extra > MAX_SIZE)
> 		return -EINVAL;
>
> 	copy_from_user(dest, src, sizeof(dest) + dest.extra);
>
> 	for (i = 0; i < dest.extra; i++) {
> 		dest.foo[i] = xxx;
>
>
> We get dest.extra from the user, we verify the size, then we copy more
> data from the user but that over writes dest.extra again.  We use
> dest.extra a second time without checking that it's still <= MAX_SIZE.

OK, so the problem is when data that was checked on the first copy is used
after the second copy?  It would probably be possible to get rid of a lot
of false positives with that.

thanks,
julia

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c Kees Cook <keescook@google.com> - 2016-04-27 00:30 +0200
  Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c Julia Lawall <julia.lawall@lip6.fr> - 2016-04-27 07:50 +0200
    Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c Dan Carpenter <dan.carpenter@oracle.com> - 2016-04-27 10:10 +0200
      Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c Julia Lawall <julia.lawall@lip6.fr> - 2016-04-27 10:10 +0200
        Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c Kees Cook <keescook@google.com> - 2016-04-27 18:30 +0200

csiph-web