From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6B0C385537 for ; Wed, 29 Apr 2026 03:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777432519; cv=none; b=anKmZUw4V8wLT+M4uTHRUEuf9gQwJ4zqRSXImT3iXwDtBT5hRuvyDusI8j/Vh6i3phFrNWDvTv5Iz2Uklh0V7RqGQRFRQHJOPAQ+bjG8TPeDqPXKR8gH0VAklpg/qFA8asm3GJ6onP9gc9W0Vbtx1/t+FpCnweWd95vtCk34tHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777432519; c=relaxed/simple; bh=PqScKcFoPPgpexhKPsSgcvCiB53igOl/DrNGGj6eMVE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JysxG73xuKZUOiJHtIBlV9TWJyIRSll/39UhcVDxFntu4qvc2pogsY3rOeMiKniol1dex9wqLlivxvNWA9X246TtFc/7CDCx6W1KIUUsv13EAMXFhDa5AV6BLLdY347uZALDBzlvxrJECEO1+v0UKdRC7ksNdiuYQitDYIiO7Xo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UyoSKuJP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UyoSKuJP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 757F4C2BCB7; Wed, 29 Apr 2026 03:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777432518; bh=PqScKcFoPPgpexhKPsSgcvCiB53igOl/DrNGGj6eMVE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UyoSKuJPYIHp4A95gcJi+VB1NyBhcON/g+p4FYn3wIZho8+01Wz4iTQokfHMVV/CZ GHMsDPuCBQisRarBORul2isa19te8QbuNqVem/9QZ4y/qRfSQZBu4ayJUEEZnJ1+WG pXndTlo1kvwJ4vScP0dB7/zpRW71iKpkrdV52gFyUQwsRixdaVD9PoLPENcXiTK12e BQz3p6FReX0V1HHUPByxTb559LYC9VKUMPjrP4NBHkFztwEYXXTypUgFtGQ2KRn8a/ EDcZ+BJDw5OmkwXm4mjPOkIojnmgEt2qZXiHkoGdBETJAYwJslXffdKJM/JlqRGeNn Aph20qS6mErUQ== Date: Wed, 29 Apr 2026 03:15:15 +0000 From: Tzung-Bi Shih To: Sergey Senozhatsky Cc: Jassi Brar , Matthias Brugger , AngeloGioacchino Del Regno , Allen-KH Cheng , YC Hung , 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 Message-ID: References: <20260428025614.1094085-1-senozhatsky@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tzung-Bi Shih