[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <81a46647-c666-4475-893b-d4af043c90ea@kernel.org>
Date: Thu, 23 Oct 2025 13:36:19 +0200
From: Hans Verkuil <hverkuil+cisco@...nel.org>
To: Marek Szyprowski <m.szyprowski@...sung.com>, linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Tomasz Figa <tfiga@...omium.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Guennadi Liakhovetski <g.liakhovetski@....de>,
Benjamin Gaignard <benjamin.gaignard@...labora.com>,
Hans Verkuil <hverkuil@...nel.org>, stable@...r.kernel.org,
Shuangpeng Bai <SJB7183@....edu>
Subject: Re: [PATCH v3] media: videobuf2: forbid remove_bufs when legacy
fileio is active
On 23/10/2025 13:30, Marek Szyprowski wrote:
> vb2_ioctl_remove_bufs() call manipulates queue internal buffer list,
> potentially overwriting some pointers used by the legacy fileio access
> mode. Add a vb2_verify_memory_type() check symmetrical to
> vb2_ioctl_create_bufs() to forbid that ioctl when fileio is active to
> protect internal queue state between subsequent read/write calls.
>
> CC: stable@...r.kernel.org
> Fixes: a3293a85381e ("media: v4l2: Add REMOVE_BUFS ioctl")
> Reported-by: Shuangpeng Bai<SJB7183@....edu>
> Suggested-by: Benjamin Gaignard <benjamin.gaignard@...labora.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@...sung.com>
> ---
> drivers/media/common/videobuf2/videobuf2-v4l2.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index d911021c1bb0..a8a5b42a42d0 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -1000,13 +1000,15 @@ int vb2_ioctl_remove_bufs(struct file *file, void *priv,
> struct v4l2_remove_buffers *d)
> {
> struct video_device *vdev = video_devdata(file);
> -
> - if (vdev->queue->type != d->type)
> - return -EINVAL;
> + int res;
>
> if (d->count == 0)
> return 0;
Ah, no. This should still check d->type. So:
if (d->count == 0)
return d->type == vdev->queue->type ? 0 : -EINVAL;
Regards,
Hans
>
> + res = vb2_verify_memory_type(vdev->queue, vdev->queue->memory, d->type);
> + if (res)
> + return res;
> +
> if (vb2_queue_is_busy(vdev->queue, file))
> return -EBUSY;
>
Powered by blists - more mailing lists