public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Malcolm Priestley <tvboxspy@gmail.com>
Cc: "Guillaume CLÉMENT" <gclement@baobob.org>,
	devel@driverdev.osuosl.org,
	"Forest Bond" <forest@alittletooquiet.net>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: vt6655: fix direct dereferencing of user pointer
Date: Sun, 27 Jul 2014 11:21:01 -0700	[thread overview]
Message-ID: <20140727182101.GA11593@kroah.com> (raw)
In-Reply-To: <53D386A9.9040001@gmail.com>

On Sat, Jul 26, 2014 at 11:44:57AM +0100, Malcolm Priestley wrote:
> On 26/07/14 10:18, Guillaume CLÉMENT wrote:
> >On Sat, Jul 26, 2014 at 10:24:30AM +0200, Guillaume CLÉMENT wrote:
> >>Hi Malcolm,
> >>
> >>On Sat, Jul 26, 2014 at 12:09:49AM +0100, Malcolm Priestley wrote:
> >>>Hi Guillaume
> >>>
> >>>On 25/07/14 13:47, Guillaume Clement wrote:
> >>>>Sparse reported that the data from tagSCmdRequest is given by
> >>>>userspace, so it should be tagged as such.
> >>>extra is not in user space
> >>>
> >>
> >>All right.
> >>
> >>This is still confusing to me because, taking the SIOCSIWGENIE ioctl as
> >>an example, in device_main.c, we have this code:
> >>
> >>rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
> >>
> >>Here the extra parameter is the last one, wrq->u.data.pointer.
> >>
> >>I was led to believe that wrq->u.data.pointer is in userspace (this was
> >>reported by sparse actually) because the pointer field in data is
> >>actually defined as __user.
> >>
> >>
> >By the way, the original code (before my patch) reads:
> >
> >	if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
> >		ret = -EINVAL;
> >		goto out;
> >	}
> >	if (wrq->length > MAX_WPA_IE_LEN) {
> >		ret = -ENOMEM;
> >		goto out;
> >	}
> >	memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
> >	if (copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)) {
> >		ret = -EFAULT;
> >		goto out;
> >	}
> >
> >Note extra[1] and later copy_from_user(x, extra, y).
> >
> >If extra is not in userspace, we should not call copy_from_user, and if
> >it is, we should not dereference it. There is definitely something fishy
> >here.
> >
> 
> I got it wrong when the iw_handler is not present a standard ioctl is called
> extra is in userspace.
> 
> Sorry for the noise.

So this patch is acceptable?

confused,

greg k-h

  reply	other threads:[~2014-07-27 18:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-24 23:07 [PATCH] staging: vt6655: tag data as __user in struct tagSCmdRequest Guillaume Clement
2014-07-25 11:52 ` Dan Carpenter
2014-07-25 12:25   ` Guillaume CLÉMENT
2014-07-25 12:33     ` Dan Carpenter
2014-07-25 12:47       ` [PATCH] staging: vt6655: fix direct dereferencing of user pointer Guillaume Clement
2014-07-25 23:09         ` Malcolm Priestley
2014-07-26  8:24           ` Guillaume CLÉMENT
2014-07-26  9:18             ` Guillaume CLÉMENT
2014-07-26 10:44               ` Malcolm Priestley
2014-07-27 18:21                 ` Greg Kroah-Hartman [this message]
2014-07-27 18:44                   ` Malcolm Priestley
2014-07-25 23:16         ` Malcolm Priestley

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=20140727182101.GA11593@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=forest@alittletooquiet.net \
    --cc=gclement@baobob.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tvboxspy@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