lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <097124ea-cf9b-425c-bb5f-a305224328f6@kernel.org>
Date: Mon, 22 Sep 2025 10:11:04 +0200
From: Hans Verkuil <hverkuil+cisco@...nel.org>
To: Jai Luthra <jai.luthra@...asonboard.com>,
 Hans Verkuil <hverkuil@...nel.org>,
 Mauro Carvalho Chehab <mchehab@...nel.org>,
 Sakari Ailus <sakari.ailus@...ux.intel.com>,
 Laurent Pinchart <laurent.pinchart@...asonboard.com>,
 Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
 Jacopo Mondi <jacopo.mondi@...asonboard.com>, linux-media@...r.kernel.org
Cc: Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
 Ricardo Ribalda <ribalda@...omium.org>, Hans de Goede <hansg@...nel.org>,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 07/10] media: v4l2-ioctl: Pass device state for
 G/S/TRY_FMT ioctls

On 19/09/2025 11:55, Jai Luthra wrote:
> Now that video device state is accepted as an argument in ioctl
> implementations across all video device drivers, populate that argument
> with the actual state data.
> 
> Pass the active state for G_FMT and S_FMT ioctls, and the try state for
> TRY_FMT ioctl to drivers that have opted to use device state for format
> storage.
> 
> Signed-off-by: Jai Luthra <jai.luthra@...asonboard.com>
> --
> Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
> Cc: Hans Verkuil <hverkuil@...nel.org>
> Cc: Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>
> Cc: Ricardo Ribalda <ribalda@...omium.org>
> Cc: Hans de Goede <hansg@...nel.org>
> Cc: Jai Luthra <jai.luthra@...asonboard.com>
> Cc: linux-media@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> ---
>  drivers/media/v4l2-core/v4l2-ioctl.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)

There is one more occurrence of this in v4l2_compat_ioctl32.c in function
ctrl_is_pointer() where vidioc_query_ext_ctrl is called.

Regards,

	Hans

> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 644f06521673ff7ce5b194335d50f0e375ca7f51..500fc20627c97ce70016f4524301835142b7bebd 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3070,6 +3070,21 @@ void v4l_printk_ioctl(const char *prefix, unsigned int cmd)
>  }
>  EXPORT_SYMBOL(v4l_printk_ioctl);
>  
> +static struct video_device_state *
> +video_device_get_state(struct video_device *vfd, struct v4l2_fh *vfh,
> +		       unsigned int cmd)
> +{
> +	switch (cmd) {
> +	default:
> +		return NULL;
> +	case VIDIOC_G_FMT:
> +	case VIDIOC_S_FMT:
> +		return vfd->state;
> +	case VIDIOC_TRY_FMT:
> +		return vfh->state;
> +	}
> +}
> +
>  static long __video_do_ioctl(struct file *file,
>  		unsigned int cmd, void *arg)
>  {
> @@ -3078,6 +3093,7 @@ static long __video_do_ioctl(struct file *file,
>  	struct mutex *lock; /* ioctl serialization mutex */
>  	const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
>  	bool write_only = false;
> +	struct video_device_state *state = NULL;
>  	struct v4l2_ioctl_info default_info;
>  	const struct v4l2_ioctl_info *info;
>  	struct v4l2_fh *vfh = file_to_v4l2_fh(file);
> @@ -3090,6 +3106,9 @@ static long __video_do_ioctl(struct file *file,
>  		return ret;
>  	}
>  
> +	if (test_bit(V4L2_FL_USES_STATE, &vfd->flags))
> +		state = video_device_get_state(vfd, vfh, cmd);
> +
>  	/*
>  	 * We need to serialize streamon/off with queueing new requests.
>  	 * These ioctls may trigger the cancellation of a streaming
> @@ -3138,11 +3157,11 @@ static long __video_do_ioctl(struct file *file,
>  
>  	write_only = _IOC_DIR(cmd) == _IOC_WRITE;
>  	if (info != &default_info) {
> -		ret = info->func(ops, file, NULL, arg);
> +		ret = info->func(ops, file, state, arg);
>  	} else if (!ops->vidioc_default) {
>  		ret = -ENOTTY;
>  	} else {
> -		ret = ops->vidioc_default(file, NULL,
> +		ret = ops->vidioc_default(file, state,
>  			v4l2_prio_check(vfd->prio, vfh->prio) >= 0,
>  			cmd, arg);
>  	}
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ