Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: shengjiu.wang@oss.nxp.com
Cc: robh@kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org,
	Frank.Li@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 5/5] ASoC: fsl_easrc: expose individual DAIs per conversion path
Date: Tue, 04 Aug 2026 10:12:58 +0000	[thread overview]
Message-ID: <20260804101258.C07821F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804100218.49587-6-shengjiu.wang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Calling ALSA hw_params multiple times on the same stream causes a context/pair leak in the ASRC, leading to a Use-After-Free and Denial of Service.
--

--- Patch [5]: [PATCH v3 5/5] ASoC: fsl_easrc: expose individual DAIs per conversion path ---
commit 6518fbf2be545cdd1e3224f3467d1c7ad789391e
Author: Shengjiu Wang <shengjiu.wang@nxp.com>

ASoC: fsl_easrc: expose individual DAIs per conversion path

The driver previously registered a single DAI with generic stream names,
preventing multiple independent conversion paths from being used
simultaneously. Replace the single fsl_easrc_dai instance with an array of
four DAI drivers to allow up to four independent conversion paths to be
active at the same time.

> diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
> index f1249da0658cd..17d85d4843588 100644
> --- a/sound/soc/fsl/fsl_easrc.c
> +++ b/sound/soc/fsl/fsl_easrc.c
> @@ -1589,27 +1589,99 @@ static const struct snd_soc_dai_ops fsl_easrc_dai_ops = {
>  	.hw_free	= fsl_easrc_hw_free,

[Severity: High]
This is a pre-existing issue, but if userspace repeatedly calls
SNDRV_PCM_IOCTL_HW_PARAMS on an audio stream without calling hw_free in
between, does fsl_easrc_hw_params() unconditionally request a new context?

Looking at fsl_easrc_hw_params():

sound/soc/fsl/fsl_easrc.c:fsl_easrc_hw_params() {
	...
	ret = fsl_easrc_request_context(channels, ctx);
	if (ret) {
		dev_err(dev, "failed to request context\n");
		return ret;
	}
	...
}

If this happens, fsl_easrc_request_context() finds the next available empty
slot in the easrc->pair[] array, overwrites ctx->index, and deducts channels
from easrc->channel_avail:

sound/soc/fsl/fsl_easrc.c:fsl_easrc_request_context() {
	...
	ctx->index = index;
	ctx->channels = channels;
	easrc->pair[index] = ctx;
	easrc->channel_avail -= channels;
	...
}

Because the previous index is overwritten without being freed, does
easrc->pair[old_index] permanently retain a dangling pointer to the context?

Furthermore, when the stream is closed, fsl_asrc_dma_shutdown() frees the
pair context but only clears asrc->pair[pair->index] using the latest index:

sound/soc/fsl/fsl_asrc_dma.c:fsl_asrc_dma_shutdown() {
	...
	if (asrc->pair[pair->index] == pair)
		asrc->pair[pair->index] = NULL;

	kfree(pair);
	...
}

Would subsequent operations that iterate over all easrc->pair[] slots (such
as fsl_asrc_isr() or fsl_asrc_m2m_suspend()) then dereference these dangling
pointers, resulting in a use-after-free? (It appears the older ASRC driver
shares this same design flaw in fsl_asrc_dai_hw_params).

>  };
>  
> -static struct snd_soc_dai_driver fsl_easrc_dai = {
> -	.playback = {
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804100218.49587-1-shengjiu.wang@oss.nxp.com?part=5

      reply	other threads:[~2026-08-04 10:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 10:02 [PATCH v3 0/5] ASoC: fsl_asrc/fsl_easrc: expose per-pair/context DAIs and fix DMA race shengjiu.wang
2026-08-04 10:02 ` [PATCH v3 1/5] ASoC: dt-bindings: fsl,imx-asrc: update port binding to support multiple paths shengjiu.wang
2026-08-04 14:39   ` Frank Li
2026-08-05  6:57     ` Shengjiu Wang
2026-08-05 17:06       ` Frank Li
2026-08-06  5:27         ` Shengjiu Wang
2026-08-06 16:40           ` Frank Li
2026-08-04 10:02 ` [PATCH v3 2/5] ASoC: dt-bindings: fsl,easrc: add ports binding for multiple conversion paths shengjiu.wang
2026-08-04 14:40   ` Frank Li
2026-08-04 10:02 ` [PATCH v3 3/5] ASoC: fsl_asrc/fsl_easrc: move DMA params into pair/context struct shengjiu.wang
2026-08-04 10:15   ` sashiko-bot
2026-08-04 10:02 ` [PATCH v3 4/5] ASoC: fsl_asrc: expose individual DAIs per conversion path shengjiu.wang
2026-08-04 10:20   ` sashiko-bot
2026-08-04 10:02 ` [PATCH v3 5/5] ASoC: fsl_easrc: " shengjiu.wang
2026-08-04 10:12   ` sashiko-bot [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=20260804101258.C07821F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shengjiu.wang@oss.nxp.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