From: Dan Carpenter <dan.carpenter@oracle.com>
To: Guillaume Clement <gclement@baobob.org>
Cc: Forest Bond <forest@alittletooquiet.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: vt6655: tag data as __user in struct tagSCmdRequest
Date: Fri, 25 Jul 2014 14:52:34 +0300 [thread overview]
Message-ID: <20140725115234.GZ25880@mwanda> (raw)
In-Reply-To: <1406243260-13490-1-git-send-email-gclement@baobob.org>
On Fri, Jul 25, 2014 at 01:07:40AM +0200, Guillaume Clement wrote:
> diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
> index 501cd64..9291259 100644
> --- a/drivers/staging/vt6655/iwctl.c
> +++ b/drivers/staging/vt6655/iwctl.c
> @@ -1621,14 +1621,17 @@ int iwctl_giwauth(struct net_device *dev,
> int iwctl_siwgenie(struct net_device *dev,
> struct iw_request_info *info,
> struct iw_point *wrq,
> - char *extra)
> + char __user *extra)
> {
> PSDevice pDevice = (PSDevice)netdev_priv(dev);
> PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
> int ret = 0;
> + char length;
>
> if (wrq->length) {
> - if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
> + if (get_user(length, extra + 1))
> + return -EFAULT;
> + if ((wrq->length < 2) || (length != wrq->length)) {
> ret = -EINVAL;
> goto out;
> }
Wow, this is confusing code. The patch description isn't clear enough
that this is a bugfix patch and not just a "tag data" patch.
I don't think this is correct. We need to check the length of the input
buffer before we call get_user(). Can we return directly or do we
*need* to go to the mysteriously named "out"? Also the + 2 is lost,
this would break everything if the current code works (not necessarily a
valid assumption). Delete all my comments in the final code.
/* 2 because we skip the first byte and read length from the
second byte */
if (wrq->length < 2) {
ret = -EINVAL;
goto out;
}
ret = get_user(length, extra + 1);
if (ret)
goto out;
if (length + 2 != wrq->length) {
ret = -EINVAL;
goto out;
}
regards,
dan carpenter
next prev parent reply other threads:[~2014-07-25 11:52 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 [this message]
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
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=20140725115234.GZ25880@mwanda \
--to=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=forest@alittletooquiet.net \
--cc=gclement@baobob.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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.