All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Hans Verkuil <hansverk@cisco.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Daniel Mentz <danielmentz@google.com>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] media: v4l2-compat-ioctl32: don't oops on overlay
Date: Thu, 29 Mar 2018 10:00:42 -0300	[thread overview]
Message-ID: <20180329100042.209b313c@vento.lan> (raw)
In-Reply-To: <2e9cca00-5c6d-6a22-0273-98f908a304d6@xs4all.nl>

Em Thu, 29 Mar 2018 10:40:23 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> Hi Mauro,
> 
> On 28/03/18 19:59, Mauro Carvalho Chehab wrote:
> > At put_v4l2_window32(), it tries to access kp->clips. However,
> > kp points to an userspace pointer. So, it should be obtained
> > via get_user(), otherwise it can OOPS:
> >   
> 
> <snip>
> 
> > 
> > cc: stable@vger.kernel.org
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> >  drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> > index 5198c9eeb348..4312935f1dfc 100644
> > --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> > +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> > @@ -101,7 +101,7 @@ static int get_v4l2_window32(struct v4l2_window __user *kp,
> >  static int put_v4l2_window32(struct v4l2_window __user *kp,
> >  			     struct v4l2_window32 __user *up)
> >  {
> > -	struct v4l2_clip __user *kclips = kp->clips;
> > +	struct v4l2_clip __user *kclips;
> >  	struct v4l2_clip32 __user *uclips;
> >  	compat_caddr_t p;
> >  	u32 clipcount;
> > @@ -116,6 +116,8 @@ static int put_v4l2_window32(struct v4l2_window __user *kp,
> >  	if (!clipcount)
> >  		return 0;
> >  
> > +	if (get_user(kclips, &kp->clips))
> > +		return -EFAULT;
> >  	if (get_user(p, &up->clips))
> >  		return -EFAULT;
> >  	uclips = compat_ptr(p);
> >   
> 
> Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
> 
> I have no idea why I didn't find this when I tested this with v4l2-compliance,
> but the code was certainly wrong.

I built 4.16-rc4 with KASAN enabled. Perhaps, it won't OOPS without
it. Yet, I doubt it would work without this fix.

> 
> Thank you for debugging this!

Anytime.

Thanks,
Mauro

  reply	other threads:[~2018-03-29 13:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 17:59 [PATCH] media: v4l2-compat-ioctl32: don't oops on overlay Mauro Carvalho Chehab
2018-03-28 20:16 ` Sakari Ailus
2018-03-29  6:19   ` Laurent Pinchart
2018-03-29  7:35     ` Sakari Ailus
2018-03-29  7:45       ` Laurent Pinchart
2018-03-29  8:40 ` Hans Verkuil
2018-03-29 13:00   ` Mauro Carvalho Chehab [this message]
2018-03-29 13:02     ` Hans Verkuil

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=20180329100042.209b313c@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=danielmentz@google.com \
    --cc=hansverk@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@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.