From: Julia Lawall <julia.lawall@lip6.fr>
To: Kees Cook <keescook@google.com>
Cc: Pengfei Wang <wpengfeinudt@gmail.com>,
"security@kernel.org" <security@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c
Date: Wed, 27 Apr 2016 07:42:04 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1604270741260.2223@localhost6.localdomain6> (raw)
In-Reply-To: <CAGXu5jLYkLpMzvwm+mFBfoaNMqkTpXhrt_c7kJN0SvQVqJqyYw@mail.gmail.com>
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?
thanks,
julia
> virtual report
> virtual org
>
> @cfu_twice@
> position p;
> identifier src;
> expression dest1, dest2, size1, size2, offset;
> @@
>
> *copy_from_user(dest1, src, size1)
> ... when != src = offset
> when != src += offset
> *copy_from_user@p(dest2, src, size2)
>
> @script:python depends on org@
> p << cfu_twice.p;
> @@
>
> cocci.print_main("potentially dangerous second copy_from_user()",p)
>
> @script:python depends on report@
> p << cfu_twice.p;
> @@
>
> coccilib.report.print_report(p[0],"potentially dangerous second
> copy_from_user()")
>
>
> It would be great to have some one go through all the reports to see
> which are legit. I'll send separate emails with the patch for
> coccicheck and the output.
>
> -Kees
>
> >
> > In function ioctl_send_fib(), the driver fetches user space data by pointer
> > arg via copy_from_user(), and this happens twice at line 81 and line 116
> > respectively. The first fetched value (stored in kfib) is used to get the
> > header and calculate the size at line 90 so as to copy the whole message
> > later at line 116, which means the copy size of the whole message is based
> > on the old value that came from the first fetch. Besides, the whole message
> > copied in the second fetch also contains the header.
> >
> > However, when the function processes the message after the second fetch at
> > line 130, it uses kfib->header.Size that came from the second fetch, which
> > might be different from the one came from the first fetch as well as
> > calculated the size to copy the message from user space to driver.
> >
> > If the kfib->header.Size is modified by a user thread under race condition
> > between the fetch operations, for example changing to a very large value,
> > this will lead to over-boundary access or other serious consequences in
> > function aac_fib_send().
> >
> > I also reported this to bugzilla,
> > https://bugzilla.kernel.org/show_bug.cgi?id=116751
> >
> > I am expecting a reply to confirm this, thank you!
> >
> >
> >
> >
> >
> > Kind regards
> > Pengfei
> >
>
>
>
> --
> Kees Cook
> Chrome OS & Brillo Security
>
next prev parent reply other threads:[~2016-04-27 5:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0484FFD3-4BAB-43B9-AD56-B4A098C3E8AE@gmail.com>
2016-04-26 22:22 ` Kees Cook
2016-04-27 5:42 ` Julia Lawall [this message]
2016-04-27 8:02 ` Dan Carpenter
2016-04-27 8:07 ` Julia Lawall
2016-04-27 16:22 ` Kees Cook
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=alpine.DEB.2.02.1604270741260.2223@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=security@kernel.org \
--cc=wpengfeinudt@gmail.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
all inboxes | Powered by JetHome®