All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org,
	Daniel Mentz <danielmentz@google.com>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH 11/12] v4l2-compat-ioctl32.c: don't copy back the result for certain errors
Date: Mon, 29 Jan 2018 11:02:56 +0100	[thread overview]
Message-ID: <460b8543-8f5b-e5e6-9f4b-578b38695d60@xs4all.nl> (raw)
In-Reply-To: <20180129095608.d3opjq5zkp72u43e@valkosipuli.retiisi.org.uk>

On 01/29/2018 10:56 AM, Sakari Ailus wrote:
> Hi Hans,
> 
> On Fri, Jan 26, 2018 at 01:43:26PM +0100, Hans Verkuil wrote:
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> Some ioctls need to copy back the result even if the ioctl returned
>> an error. However, don't do this for the error codes -ENOTTY, -EFAULT
>> and -ENOIOCTLCMD. It makes no sense in those cases.
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> 
> Shouldn't such a change be made to video_usercopy() as well? Doesn't need
> to be in this set though.

Good point. I'll add that for v2. This is not actually a bug as such, but
it's just weird to copy back results if the ioctl wasn't implemented at all.

I realize that I need to drop the -EFAULT check: if you call VIDIOC_G_EXT_CTRLS
with an incorrect userspace buffer for the payload, then the control framework
will set error_idx to the index of the control with the wrong buffer. So you do
need to copy back the data in case of -EFAULT.

I can also drop -ENOIOCTLCMD since video_usercopy() converts that to -ENOTTY.

Regards,

	Hans

> 
>> ---
>>  drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
>> index 790473b45a21..2aa9b43daf60 100644
>> --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
>> +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
>> @@ -966,6 +966,9 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
>>  		set_fs(old_fs);
>>  	}
>>  
>> +	if (err == -ENOTTY || err == -EFAULT || err == -ENOIOCTLCMD)
>> +		return err;
>> +
>>  	/* Special case: even after an error we need to put the
>>  	   results back for these ioctls since the error_idx will
>>  	   contain information on which control failed. */
> 

  reply	other threads:[~2018-01-29 10:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 12:43 [PATCH 00/12] v4l2-compat-ioctl32.c: remove set_fs(KERNEL_DS) Hans Verkuil
2018-01-26 12:43 ` [PATCH 01/12] vivid: fix module load error when enabling fb and no_error_inj=1 Hans Verkuil
2018-01-26 14:43   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 02/12] v4l2-ioctl.c: use check_fmt for enum/g/s/try_fmt Hans Verkuil
2018-01-26 14:41   ` Sakari Ailus
2018-01-29 10:09     ` Hans Verkuil
2018-01-29 20:57       ` Sakari Ailus
2018-01-30  8:44     ` Hans Verkuil
2018-01-30 11:14       ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 03/12] v4l2-compat-ioctl32.c: add missing VIDIOC_PREPARE_BUF Hans Verkuil
2018-01-26 14:43   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 04/12] v4l2-compat-ioctl32.c: fix the indentation Hans Verkuil
2018-01-26 14:57   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 05/12] v4l2-compat-ioctl32.c: move 'helper' functions to __get/put_v4l2_format32 Hans Verkuil
2018-01-26 15:20   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 06/12] v4l2-compat-ioctl32.c: avoid sizeof(type) Hans Verkuil
2018-01-26 15:35   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 07/12] v4l2-compat-ioctl32.c: copy m.userptr in put_v4l2_plane32 Hans Verkuil
2018-01-26 16:15   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 08/12] v4l2-compat-ioctl32.c: fix ctrl_is_pointer Hans Verkuil
2018-01-27 23:18   ` Sakari Ailus
2018-01-29 14:11     ` Mauro Carvalho Chehab
2018-01-26 12:43 ` [PATCH 09/12] v4l2-compat-ioctl32.c: copy clip list in put_v4l2_window32 Hans Verkuil
2018-01-29  9:47   ` Sakari Ailus
2018-01-29 14:13     ` Mauro Carvalho Chehab
2018-01-29 21:00       ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 10/12] v4l2-compat-ioctl32.c: drop pr_info for unknown buffer type Hans Verkuil
2018-01-29  9:48   ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 11/12] v4l2-compat-ioctl32.c: don't copy back the result for certain errors Hans Verkuil
2018-01-29  9:56   ` Sakari Ailus
2018-01-29 10:02     ` Hans Verkuil [this message]
2018-01-29 21:01       ` Sakari Ailus
2018-01-26 12:43 ` [PATCH 12/12] v4l2-compat-ioctl32.c: refactor, fix security bug in compat ioctl32 Hans Verkuil
2018-01-29 15:14   ` Mauro Carvalho Chehab
2018-01-29 17:06   ` Sakari Ailus
2018-01-29 17:41     ` Hans Verkuil
2018-01-29 21:14       ` Sakari Ailus
2018-01-30  9:37     ` 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=460b8543-8f5b-e5e6-9f4b-578b38695d60@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=danielmentz@google.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    /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.