public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] staging: ft1000: add a range check in ft1000_ioctl()
Date: Sun, 05 May 2013 14:23:43 +0000	[thread overview]
Message-ID: <20130505142256.GC4686@mwanda> (raw)
In-Reply-To: <20130503071728.GA29653@elgon.mountain>

On Fri, May 03, 2013 at 01:11:21PM +0530, devendra.aaru wrote:
> On Fri, May 3, 2013 at 12:47 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > msglen comes from get_user() so we need to check that it's not too
> > large.
> >
> > The first element of "pioctl_dpram" is a short which holds the size of
> > the data the user wants.  I have chosen a limit which lets us fill the
> > rest of the struct.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > msglen is also apparently network endian?  My guess is that we should
> > just delete this code instead of trying to fix it.
> >
> > diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
> > index 3251d2e..e0056c9 100644
> > --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
> > +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
> > @@ -703,6 +703,8 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
> >                         break;
> >                 msglen = htons(msglen);
> >                  //DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen);
> > +               if (msglen > sizeof(*pioctl_dpram) - sizeof(short))
> > +                       msglen = sizeof(*pioctl_dpram) - sizeof(short);
> 
> doing this may be wrong too? because its in network endian format.
> does deleting msglen = htons(msglen)
> and adding your change makes sense?

Yeah.  Probably my patch doesn't make sense by itself.

It's hard to say what the right thing is here without having a way
to test it or knowing what userspace does.

I do suspect that the right thing is to just delete this code.

regards,
dan carpenter


      parent reply	other threads:[~2013-05-05 14:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03  7:17 [patch] staging: ft1000: add a range check in ft1000_ioctl() Dan Carpenter
2013-05-03  7:53 ` devendra.aaru
2013-05-05 14:23 ` Dan Carpenter [this message]

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=20130505142256.GC4686@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox