Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Benjamin Gaignard <benjamin.gaignard@collabora.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Tomasz Figa <tfiga@chromium.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Hans Verkuil <hverkuil@kernel.org>,
	stable@vger.kernel.org, Shuangpeng Bai <SJB7183@psu.edu>
Subject: Re: [PATCH v2] media: videobuf2: forbid remove_bufs when legacy fileio is active
Date: Mon, 20 Oct 2025 18:03:29 +0200	[thread overview]
Message-ID: <d71a32f1-dbce-42e3-88f5-7c0628e05528@collabora.com> (raw)
In-Reply-To: <20251020160121.1985354-1-m.szyprowski@samsung.com>


Le 20/10/2025 à 18:01, Marek Szyprowski a écrit :
> 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@vger.kernel.org
> Fixes: a3293a85381e ("media: v4l2: Add REMOVE_BUFS ioctl")
> Reported-by: Shuangpeng Bai<SJB7183@psu.edu>
> Suggested-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Thanks for the patch.

Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>

> ---
> v2:
> - dropped a change to vb2_ioctl_create_bufs(), as it is already handled
>    by the vb2_verify_memory_type() call
> - replaced queue->type check in vb2_ioctl_remove_bufs() by a call to
>    vb2_verify_memory_type() which covers all cases
>
> v1: https://lore.kernel.org/all/20251016111154.993949-1-m.szyprowski@samsung.com/
> ---
>   drivers/media/common/videobuf2/videobuf2-v4l2.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> index d911021c1bb0..0de7490292fe 100644
> --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
> +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
> @@ -1000,9 +1000,11 @@ int vb2_ioctl_remove_bufs(struct file *file, void *priv,
>   			  struct v4l2_remove_buffers *d)
>   {
>   	struct video_device *vdev = video_devdata(file);
> +	int res;
>   
> -	if (vdev->queue->type != d->type)
> -		return -EINVAL;
> +	res = vb2_verify_memory_type(vdev->queue, vdev->queue->memory, d->type);
> +	if (res)
> +		return res;
>   
>   	if (d->count == 0)
>   		return 0;

  reply	other threads:[~2025-10-20 16:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20251020160135eucas1p29eb8517e240f188f102e77713f85e29d@eucas1p2.samsung.com>
2025-10-20 16:01 ` [PATCH v2] media: videobuf2: forbid remove_bufs when legacy fileio is active Marek Szyprowski
2025-10-20 16:03   ` Benjamin Gaignard [this message]
2025-10-21  9:56   ` Hans Verkuil
2025-10-23  9:01     ` Hans Verkuil
2025-10-23 10:54       ` 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=d71a32f1-dbce-42e3-88f5-7c0628e05528@collabora.com \
    --to=benjamin.gaignard@collabora.com \
    --cc=SJB7183@psu.edu \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tfiga@chromium.org \
    /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