linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Hans Verkuil <hansverk@cisco.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Daniel Mentz <danielmentz@google.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 4/5] media: v4l2-compat-ioctl32: fix several __user annotations
Date: Tue, 17 Apr 2018 10:35:21 -0300	[thread overview]
Message-ID: <20180417103521.28e5e120@vento.lan> (raw)
In-Reply-To: <e514a081-e70a-a6fb-d083-a5cc9e985f4f@cisco.com>

Em Tue, 17 Apr 2018 15:11:10 +0200
Hans Verkuil <hansverk@cisco.com> escreveu:

> >> Be aware that the unsigned char * cast is actually a bug: it will clamp the
> >> u32 'blocks' value to a u8.
> >>
> >> Regards,
> >>
> >> 	Hans  
> > 
> > What about this approach (code untested)?  
> 
> I prefer the explicit casts. These are special situations and hiding it in
> defines makes it actually harder to follow.

There are just one special case there: USERPTR, where we force a cast
to unsigned long:

drivers/media/v4l2-core/v4l2-compat-ioctl32.c:              put_user((unsigned long)compat_ptr(p), &p64->m.userptr))
...
drivers/media/v4l2-core/v4l2-compat-ioctl32.c:                      put_user((unsigned long)compat_ptr(userptr),
drivers/media/v4l2-core/v4l2-compat-ioctl32.c-                               &p64->m.userptr))

I kept it out of the macros.

IMO, maintaining the code with the type_of() is more error-prune, as
the cast will be done the way it should. The cases where some other
cast like is needed - with is what it was done for USERPTR should
be explicit (and, btw, they should be properly documented why doing
that).

I don't remember anymore why it is casting to unsigned long,
but, based on v4l2-compliance tests, it seems that such cast works.

Thanks,
Mauro

  reply	other threads:[~2018-04-17 13:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 10:20 [PATCH 0/5] Remaining COMPILE_TEST and smatch cleanups Mauro Carvalho Chehab
2018-04-17 10:20 ` [PATCH 1/5] omap: omap-iommu.h: allow building drivers with COMPILE_TEST Mauro Carvalho Chehab
2018-04-17 10:20 ` [PATCH 2/5] media: omap3isp: Enable driver compilation on ARM " Mauro Carvalho Chehab
2018-04-17 10:20 ` [PATCH 3/5] media: omap3isp: allow it to build " Mauro Carvalho Chehab
2018-04-17 10:20 ` [PATCH 4/5] media: v4l2-compat-ioctl32: fix several __user annotations Mauro Carvalho Chehab
2018-04-17 10:33   ` Hans Verkuil
2018-04-17 10:53     ` Mauro Carvalho Chehab
2018-04-17 11:04       ` Hans Verkuil
2018-04-17 11:30         ` Mauro Carvalho Chehab
2018-04-17 13:01         ` Mauro Carvalho Chehab
2018-04-17 13:10           ` Mauro Carvalho Chehab
2018-04-17 13:58             ` Mauro Carvalho Chehab
2018-04-17 14:21               ` Mauro Carvalho Chehab
2018-04-17 13:11           ` Hans Verkuil
2018-04-17 13:35             ` Mauro Carvalho Chehab [this message]
2018-04-17 10:20 ` [PATCH 5/5] media: v4l2-compat-ioctl32: better name userspace pointers Mauro Carvalho Chehab
2018-04-17 10:37   ` Hans Verkuil
2018-04-17 10:22 ` [PATCH 0/5] Remaining COMPILE_TEST and smatch cleanups Mauro Carvalho Chehab
     [not found] ` <20180418090414.6h5q3zfm3udzscd7@valkosipuli.retiisi.org.uk>
2018-04-19 10:42   ` Mauro Carvalho Chehab
2018-04-23 14:09     ` Sakari Ailus
2018-04-23 14:37       ` Mauro Carvalho Chehab

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=20180417103521.28e5e120@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=danielmentz@google.com \
    --cc=hansverk@cisco.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=sakari.ailus@linux.intel.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;
as well as URLs for NNTP newsgroup(s).