From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Allen-KH Cheng <Allen-KH.Cheng@mediatek.com>,
YC Hung <yc.hung@mediatek.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] mailbox: mtk-adsp: fix UAF during device teardown
Date: Wed, 29 Apr 2026 03:15:15 +0000 [thread overview]
Message-ID: <afF3w2QS8P-8LPMt@google.com> (raw)
In-Reply-To: <20260428025614.1094085-1-senozhatsky@chromium.org>
On Tue, Apr 28, 2026 at 11:55:44AM +0900, Sergey Senozhatsky wrote:
> When the SOF audio driver fails to initialize (e.g. firmware boot
> timeout), its devres unwind frees the snd_sof_dev object that the
> mailbox client (mtk-adsp-ipc) reaches via chan->cl->rx_callback.
> The mtk-adsp-mailbox shutdown clears the mailbox command registers
> but leaves the IRQ line unmasked, so a late interrupt can still
> queue a threaded handler after mbox_free_channel() had cleared
> chan->cl, and mbox_chan_received_data() would then trigger UAF:
>
> BUG: KASAN: slab-use-after-free in sof_ipc3_validate_fw_version
> sof_ipc3_validate_fw_version
> sof_ipc3_do_rx_work
> sof_ipc3_rx_msg
> mt8196_dsp_handle_request
> mtk_adsp_ipc_recv
> mbox_chan_received_data
> mtk_adsp_mbox_isr
> irq_thread_fn
> Freed by task ...:
> kfree
> devres_release_all
> really_probe
> ... (sof-audio-of-mt8196 probe failure)
>
> The crash was observed roughly three seconds after the failed probe.
>
> disable_irq() in shutdown and enable_irq() in startup. disable_irq()
> also waits for any in-flight interrupts, so by the time
> mbox_free_channel() proceeds to clear chan->cl no rx_callback can run.
>
> In addition, request the IRQ with IRQF_NO_AUTOEN so it stays masked
> between probe and the first client bind — otherwise an early interrupt
> can crash on chan->cl == NULL in mbox_chan_received_data().
>
> Fixes: af2dfa96c52d ("mailbox: mediatek: add support for adsp mailbox controller")
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
prev parent reply other threads:[~2026-04-29 3:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 2:55 [PATCH] mailbox: mtk-adsp: fix UAF during device teardown Sergey Senozhatsky
2026-04-29 3:15 ` Tzung-Bi Shih [this message]
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=afF3w2QS8P-8LPMt@google.com \
--to=tzungbi@kernel.org \
--cc=Allen-KH.Cheng@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=jassisinghbrar@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=yc.hung@mediatek.com \
/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