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]
Date: Tue, 16 Jan 2024 15:03:16 +0100
From: Hans Verkuil <hverkuil-cisco@...all.nl>
To: Benjamin Gaignard <benjamin.gaignard@...labora.com>, tfiga@...omium.org,
 m.szyprowski@...sung.com, mchehab@...nel.org
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
 kernel@...labora.com
Subject: Re: [PATCH] media: core: Refactor vb2_ioctl_create_bufs() to always
 set capabilities flags

On 15/01/2024 18:08, Benjamin Gaignard wrote:
> vb2_create_bufs() takes care of setting V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS
> flag and vb2_queue max_num_buffers field so call it instead duplicate the
> same code in vb2_ioctl_create_bufs(). Testing p->count after calling
> vb2_create_bufs() is safe since the function also check it.
> 
> Fixes: d055a76c0065 ("media: core: Report the maximum possible number of buffers for the queue")
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@...labora.com>
> ---
>  .../media/common/videobuf2/videobuf2-v4l2.c   | 23 ++++++++++---------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index 54d572c3b515..bf304a7234a0 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -1029,23 +1029,24 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
>  	int res = vb2_verify_memory_type(vdev->queue, p->memory,
>  			p->format.type);
>  
> -	p->index = vdev->queue->num_buffers;
> -	fill_buf_caps(vdev->queue, &p->capabilities);
> -	validate_memory_flags(vdev->queue, p->memory, &p->flags);
> +	if (vb2_queue_is_busy(vdev->queue, file)) {
> +		res = -EBUSY;
> +		goto failed;
> +	}
> +
> +	res = vb2_create_bufs(vdev->queue, p);
> +	if (res == 0)
> +		vdev->queue->owner = file->private_data;

This would set owner when called with p->count == 0, but that's
not what you want.

I decided to make an attempt at this myself, I'll post a patch.

Regards,

	Hans

> +
> +failed:
>  	/*
>  	 * If count == 0, then just check if memory and type are valid.
> -	 * Any -EBUSY result from vb2_verify_memory_type can be mapped to 0.
> +	 * Any -EBUSY result from vb2_verify_memory_type() or
> +	 * vb2_queue_is_busy() can be mapped to 0.
>  	 */
>  	if (p->count == 0)
>  		return res != -EBUSY ? res : 0;
> -	if (res)
> -		return res;
> -	if (vb2_queue_is_busy(vdev->queue, file))
> -		return -EBUSY;
>  
> -	res = vb2_create_bufs(vdev->queue, p);
> -	if (res == 0)
> -		vdev->queue->owner = file->private_data;
>  	return res;
>  }
>  EXPORT_SYMBOL_GPL(vb2_ioctl_create_bufs);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ