From: Julia Lawall <julia.lawall@lip6.fr>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kees Cook <keescook@google.com>,
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 10:07:05 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.10.1604271005530.3100@hadrien> (raw)
In-Reply-To: <20160427080105.GI17913@mwanda>
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
next prev parent reply other threads:[~2016-04-27 8:07 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
2016-04-27 8:02 ` Dan Carpenter
2016-04-27 8:07 ` Julia Lawall [this message]
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.10.1604271005530.3100@hadrien \
--to=julia.lawall@lip6.fr \
--cc=dan.carpenter@oracle.com \
--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®