From: sashiko-bot@kernel.org
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v2 1/9] media: synopsys: hdmirx: add media device infrastructure
Date: Thu, 24 Sep 2026 12:17:21 +0000 [thread overview]
Message-ID: <20260924121721.E5C961F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924-hdmirx-media-v2-1-c12f641d8b0f@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] media: synopsys: hdmirx: UAF on video device close after unbind
--
commit 19fb95033898b3ee8ada95f78f4121a10de2c8c5
Author: Gerald Loacker <gerald.loacker@wolfvision.net>
media: synopsys: hdmirx: add media device infrastructure
Initialize the media device to enable integration with HDMI bridge
devices in the video capture pipeline. This provides the foundation
for representing the hardware topology through the media controller
framework.
> diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> index 25f8ca0d6d946..f51a1619b71ec 100644
> --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
[ ... ]
> @@ -2771,6 +2778,7 @@ static int hdmirx_probe(struct platform_device *pdev)
> vb2_video_unregister_device(&hdmirx_dev->stream.vdev);
> err_unreg_v4l2_dev:
> v4l2_device_unregister(&hdmirx_dev->v4l2_dev);
> + media_device_cleanup(&hdmirx_dev->mdev);
[Severity: High]
Could this destructively clean up the media device while entities might still
be actively referencing it asynchronously due to open file descriptors?
In the error path of hdmirx_probe(), media_device_cleanup() is called which
destroys mdev->graph_mutex. Then devres automatically frees the
snps_hdmirx_dev structure containing both the video_device and media_device.
If a local user opens /dev/videoX before the probe failure and keeps the
file descriptor open, closing the file descriptor later will cause the V4L2
core to invoke v4l2_device_release().
This accesses the freed vdev structure and attempts to unregister the media
entity, locking the already destroyed and freed mdev->graph_mutex.
> err_hdl:
> v4l2_ctrl_handler_free(&hdmirx_dev->hdl);
> err_pm:
[ ... ]
> @@ -2794,6 +2802,7 @@ static void hdmirx_remove(struct platform_device *pdev)
> vb2_video_unregister_device(&hdmirx_dev->stream.vdev);
> v4l2_ctrl_handler_free(&hdmirx_dev->hdl);
> v4l2_device_unregister(&hdmirx_dev->v4l2_dev);
> + media_device_cleanup(&hdmirx_dev->mdev);
[Severity: High]
Does this code trigger a similar race condition when the driver is unbound?
If a local user opens /dev/videoX and keeps the file descriptor open while
the driver is unbound (e.g., via sysfs or hardware removal), hdmirx_remove()
completes and calls media_device_cleanup() which destroys mdev->graph_mutex.
Like in the probe error path, devres will automatically free the
snps_hdmirx_dev structure. Later, when the user closes the file descriptor,
the V4L2 core invokes v4l2_device_release() which will attempt to use the
freed structures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-hdmirx-media-v2-0-c12f641d8b0f@pengutronix.de?part=1
next prev parent reply other threads:[~2026-09-24 12:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 12:05 [PATCH v2 0/9] media: synopsys: hdmirx: support an HDMI bridge in front of the receiver Sascha Hauer
2026-09-24 12:05 ` [PATCH v2 1/9] media: synopsys: hdmirx: add media device infrastructure Sascha Hauer
2026-09-24 12:17 ` sashiko-bot [this message]
2026-09-24 12:05 ` [PATCH v2 2/9] media: synopsys: hdmirx: add media entity for video capture device Sascha Hauer
2026-09-24 12:05 ` [PATCH v2 3/9] dt-bindings: media: snps,dw-hdmi-rx: add a port for a bridge in front Sascha Hauer
2026-09-24 12:16 ` sashiko-bot
2026-09-24 16:55 ` Conor Dooley
2026-09-24 12:05 ` [PATCH v2 4/9] media: synopsys: hdmirx: add async subdevice support Sascha Hauer
2026-09-24 12:05 ` [PATCH v2 5/9] media: synopsys: hdmirx: give the signal lock wait a real timeout Sascha Hauer
2026-09-24 12:06 ` [PATCH v2 6/9] media: synopsys: hdmirx: skip the 5V detect interrupt without a GPIO Sascha Hauer
2026-09-24 12:06 ` [PATCH v2 7/9] media: v4l2-device: wait for notifications when unregistering a subdev Sascha Hauer
2026-09-24 12:14 ` sashiko-bot
2026-09-24 12:06 ` [PATCH v2 8/9] media: v4l2-subdev: notify the bridge when the source power changes Sascha Hauer
2026-09-24 12:06 ` [PATCH v2 9/9] media: synopsys: hdmirx: get the 5V state from the upstream subdev Sascha Hauer
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=20260924121721.E5C961F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
/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