All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kyrie Wu" <kyrie.wu@mediatek.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH v8 06/14] media: mediatek: vcodec: add debug information
Date: Sat, 10 Oct 2026 08:48:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-166375@kernel.org> (raw)
In-Reply-To: <3ed92245e07d585d938b7fcbd8d49aba7d4202ac.1791619743.git.kyrie.wu@mediatek.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] media: mediatek: vcodec: UAF due to lock mismatch in debugfs iteration
--

commit 3dd0220ecce9f2ca273e1906b8312cd6795ec662
Author: Kyrie Wu <kyrie.wu@mediatek.com>

media: mediatek: vcodec: add debug information

This commit adds debug information for HEVC/AV1 output formats and 10-bit
capture formats. It updates the debugfs read function to include 10-bit
bitstream information.

> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
> index 2da11521fc7b9..a9e52a32079d3 100644
> --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
> +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
> @@ -122,9 +138,10 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
>  
>  		if (dbgfs_index[MTK_VDEC_DBGFS_PICINFO]) {
>  			curr_len = snprintf(buf + used_len, total_len - used_len,
> -					    "\treal(%dx%d)=>align(%dx%d)\n",
> +					    "\treal(%dx%d)=>align(%dx%d) 10bit(%d)\n",
>  					    ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> -					    ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> +					    ctx->picinfo.buf_w, ctx->picinfo.buf_h,
> +					    ctx->is_10bit_bitstream);

[Severity: High]
Can a concurrent release of the video device cause a use-after-free when 
accessing ctx in this debugfs read path?

In mtk_vdec_dbgfs_read(), the iteration over dbgfs_head is protected by 
dbgfs->dbgfs_lock. However, a concurrent device release calling 
mtk_vcodec_dbgfs_remove() removes and frees dbgfs_inst without acquiring 
dbgfs_lock:

drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c:mtk_vcodec_dbgfs_remove() {
    list_for_each_entry(dbgfs_inst, &vcodec_dev->dbgfs.dbgfs_head, node) {
        if (dbgfs_inst->inst_id == ctx_id) {
            ...
            list_del(&dbgfs_inst->node);
            kfree(dbgfs_inst);
            return;
        }
    }
}

Because mtk_vcodec_dbgfs_remove() does not take dbgfs_lock, 
mtk_vdec_dbgfs_read() can dereference a freed dbgfs_inst and a freed ctx 
when a user reads the debugfs file at the same time the device is closed.

Should the list removal in mtk_vcodec_dbgfs_remove() be protected by 
dbgfs_lock?

>  			used_len += curr_len;
>  		}
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791619742.git.kyrie.wu@mediatek.com?part=6

  reply	other threads:[~2026-10-10  8:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  8:35 [PATCH v8 00/14] media: mediatek: vcodec: support video decoder in mt8196 Kyrie Wu
2026-10-10  8:36 ` [PATCH v8 01/14] media: mediatek: vcodec: support vcp architecture Kyrie Wu
2026-10-10  8:36 ` [PATCH v8 02/14] media: mediatek: vcodec: add driver to support vcp Kyrie Wu
2026-10-10  8:53   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 03/14] media: mediatek: vcodec: add driver to support vcp encoder Kyrie Wu
2026-10-10  8:59   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 04/14] media: mediatek: vcodec: get different firmware ipi id Kyrie Wu
2026-10-10  8:56   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 05/14] media: mediatek: vcodec: get share memory address Kyrie Wu
2026-10-10  8:56   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 06/14] media: mediatek: vcodec: add debug information Kyrie Wu
2026-10-10  8:48   ` sashiko-bot [this message]
2026-10-10  8:36 ` [PATCH v8 07/14] media: mediatek: vcodec: send share memory address to vcp Kyrie Wu
2026-10-10  8:46   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 08/14] dt-bindings: media: mediatek,vcodec-subdev-decoder: Add MT8196 Kyrie Wu
2026-10-12  9:39   ` Krzysztof Kozlowski
2026-10-12  9:39     ` Krzysztof Kozlowski
2026-10-10  8:36 ` [PATCH v8 09/14] media: mediatek: vcodec: add decoder compatible to support mt8196 Kyrie Wu
2026-10-10  8:36 ` [PATCH v8 10/14] media: mediatek: vcodec: define MT8196 vcodec levels Kyrie Wu
2026-10-10  8:36 ` [PATCH v8 11/14] media: mediatek: vcodec: support 36bit iova address Kyrie Wu
2026-10-10  8:36 ` [PATCH v8 12/14] media: mediatek: vcodec: clean xpc status Kyrie Wu
2026-10-10  8:50   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 13/14] media: mediatek: decoder: fill av1 buffer size with picinfo Kyrie Wu
2026-10-10  8:57   ` sashiko-bot
2026-10-10  8:36 ` [PATCH v8 14/14] media: mediatek: decoder: support av1 extend vsi Kyrie Wu
2026-10-10  8:51   ` 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=sashiko-outbox-166375@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kyrie.wu@mediatek.com \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.