From: sashiko-bot@kernel.org
To: "Anand Moon" <linux.amoon@gmail.com>
Cc: neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH v5 2/6] media: meson: vdec: Protect session exclusivity check with lock
Date: Mon, 25 May 2026 10:43:45 +0000 [thread overview]
Message-ID: <20260525104345.C8D501F00A3C@smtp.kernel.org> (raw)
In-Reply-To: <20260525095216.12078-3-linux.amoon@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] The patch fails to resolve the concurrent STREAMON race condition, leaving a Time-Of-Check to Time-Of-Use (TOCTOU) vulnerability.
Pre-existing issues:
- [High] Unprotected modification of `core->cur_sess` in `vdec_stop_streaming` leads to a data race.
- [High] Missing NULL check for `core->cur_sess` in interrupt handlers risks a kernel panic from spurious interrupts.
--
commit 7f55f473f3e7d75722e346666034bf541752f2d3
Author: Anand Moon <linux.amoon@gmail.com>
Subject: media: meson: vdec: Protect session exclusivity check with lock
This commit attempts to fix a race condition during concurrent STREAMON calls.
It wraps the session exclusivity check in vdec_start_streaming() with a
mutex to prevent multiple threads from bypassing the active session check
and concurrently triggering hardware initialization.
Closes: https://lore.kernel.org/all/20260521090944.F35401F00A3D@smtp.kernel.org/
> diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
> index 18a22b79e835e..e72f54af026e3 100644
> --- a/drivers/staging/media/meson/vdec/vdec.c
> +++ b/drivers/staging/media/meson/vdec/vdec.c
> @@ -286,10 +286,13 @@ static int vdec_start_streaming(struct vb2_queue *q, unsigned int count)
> struct vb2_v4l2_buffer *buf;
> int ret;
>
> + mutex_lock(&core->lock);
> if (core->cur_sess && core->cur_sess != sess) {
> + mutex_unlock(&core->lock);
> ret = -EBUSY;
> goto bufs_done;
> }
> + mutex_unlock(&core->lock);
[Severity: High]
Does this completely resolve the concurrent STREAMON race condition?
While the lock protects the check itself, it is released immediately
afterward. This leaves a window where two threads could sequentially acquire
the lock, observe core->cur_sess as NULL, and then concurrently proceed
with hardware initialization in vdec_poweron().
A later patch in the series wraps the eventual core->cur_sess = sess
assignment in the lock, but does that still leave an unprotected gap between
this check and the assignment?
[Severity: High]
This is a pre-existing issue, but does core->cur_sess need lock protection
in vdec_stop_streaming() as well?
Since V4L2 queue locks are used, STREAMON and STREAMOFF on different file
descriptors can execute concurrently. If vdec_stop_streaming() sets
core->cur_sess to NULL without acquiring core->lock, could this create a
data race on the global pointer?
[Severity: High]
This isn't a bug introduced by this patch, but is it possible for
core->cur_sess to be NULL when an interrupt fires?
Since core->cur_sess is set to NULL when no decoding session is active,
could a spurious hardware interrupt arriving during an idle period cause
a NULL pointer dereference in vdec_isr() or vdec_threaded_isr() if they
blindly dereference core->cur_sess without checking?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260525095216.12078-1-linux.amoon@gmail.com?part=2
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-05-25 10:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 9:51 [PATCH v5 0/6] media: meson: Fix memory leak in error path in vdec Anand Moon
2026-05-25 9:51 ` [PATCH v5 1/6] media: meson: vdec: Fix memory leak in error path of vdec_open Anand Moon
2026-05-25 10:27 ` sashiko-bot
2026-05-25 16:15 ` Anand Moon
2026-05-25 9:51 ` [PATCH v5 2/6] media: meson: vdec: Protect session exclusivity check with lock Anand Moon
2026-05-25 10:43 ` sashiko-bot [this message]
2026-05-25 9:51 ` [PATCH v5 3/6] media: meson: vdec: Set cur_sess before hardware vdec_poweron() Anand Moon
2026-05-25 11:20 ` sashiko-bot
2026-05-25 9:51 ` [PATCH v5 4/6] media: meson: vdec: Handle kthread error and free codec private data Anand Moon
2026-05-25 12:15 ` sashiko-bot
2026-05-25 9:51 ` [PATCH v5 5/6] media: meson: vdec: Isolate error path buffer flush to the active queue Anand Moon
2026-05-25 12:51 ` sashiko-bot
2026-05-25 9:51 ` [PATCH v5 6/6] media: meson: vdec: Cancel esparser work in error and stop paths Anand Moon
2026-05-25 13:42 ` sashiko-bot
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=20260525104345.C8D501F00A3C@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux.amoon@gmail.com \
--cc=neil.armstrong@linaro.org \
--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