All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Julia Lawall <julia.lawall@lip6.fr>
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 11:02:43 +0300	[thread overview]
Message-ID: <20160427080105.GI17913@mwanda> (raw)
In-Reply-To: <alpine.DEB.2.02.1604270741260.2223@localhost6.localdomain6>

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.

regards,
dan carpenter

  reply	other threads:[~2016-04-27  8:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0484FFD3-4BAB-43B9-AD56-B4A098C3E8AE@gmail.com>
2016-04-26 22:22 ` Double-Fetch bug in Linux-4.5/drivers/scsi/aacraid/commctrl.c Kees Cook
2016-04-27  5:42   ` Julia Lawall
2016-04-27  8:02     ` Dan Carpenter [this message]
2016-04-27  8:07       ` Julia Lawall
2016-04-27 16:22         ` Kees Cook
2016-04-26 12:35 Pengfei Wang
2016-04-26 14:46 ` James Bottomley
     [not found]   ` <56AE387A-9CCB-4524-A3FB-1DCA24D816E0@gmail.com>
2016-07-07 13:00     ` Pengfei Wang
2016-07-07 22:43       ` David Carroll
2016-07-08  9:24         ` Pengfei Wang

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=20160427080105.GI17913@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.