Message ID | 20221118030056.3135960-1-cuigaosheng1@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 3420fdb8ae99f0a08d78d2b80f42a71971cf478d |
Headers | show |
Series | [v2] ASoC: amd: acp: Fix possible UAF in acp_dma_open | expand |
On Fri, 18 Nov 2022 11:00:56 +0800, Gaosheng Cui wrote: > Smatch report warning as follows: > > sound/soc/amd/acp/acp-platform.c:199 acp_dma_open() warn: > '&stream->list' not removed from list > > If snd_pcm_hw_constraint_integer() fails in acp_dma_open(), > stream will be freed, but stream->list will not be removed from > adata->stream_list, then list traversal may cause UAF. > > [...] Applied to broonie/sound.git for-next Thanks! [1/1] ASoC: amd: acp: Fix possible UAF in acp_dma_open commit: 3420fdb8ae99f0a08d78d2b80f42a71971cf478d All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-platform.c index 85a81add4ef9..447612a7a762 100644 --- a/sound/soc/amd/acp/acp-platform.c +++ b/sound/soc/amd/acp/acp-platform.c @@ -184,10 +184,6 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_subs stream->substream = substream; - spin_lock_irq(&adata->acp_lock); - list_add_tail(&stream->list, &adata->stream_list); - spin_unlock_irq(&adata->acp_lock); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) runtime->hw = acp_pcm_hardware_playback; else @@ -203,6 +199,10 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_subs writel(1, ACP_EXTERNAL_INTR_ENB(adata)); + spin_lock_irq(&adata->acp_lock); + list_add_tail(&stream->list, &adata->stream_list); + spin_unlock_irq(&adata->acp_lock); + return ret; }
Smatch report warning as follows: sound/soc/amd/acp/acp-platform.c:199 acp_dma_open() warn: '&stream->list' not removed from list If snd_pcm_hw_constraint_integer() fails in acp_dma_open(), stream will be freed, but stream->list will not be removed from adata->stream_list, then list traversal may cause UAF. Fix by adding the newly allocated stream to the list once it's fully initialised. Fixes: 7929985cfe36 ("ASoC: amd: acp: Initialize list to store acp_stream during pcm_open") Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> --- v2: - Fix by adding the newly allocated stream to the list once it's fully initialised. v1: - Fix by removeing it from adata->stream_list before free(). sound/soc/amd/acp/acp-platform.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)