From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380287; b=XB9EXQeSdsnFdJEwTladuKOYo1NYotQ/hapblm+VPN1m0ogUz7O7ita0yB2sLPoRbOrL yli7AnV8LiCaDi2RD7+EtcYgP4CMFRuuRbhCkebiG9e1WPUHBUgrQkC1z9lk57KZKJeyb Blp1Rs9azQLiFfnx1BIbcPpQ24zMm6PrCJCdAwwb+x8h3cbXZ6fbrjuwAU21lF61LXJLf g4+O5OMysELCoELfP0bWWPhdrjVS3dv+sJ7yNNte+inKFi/QVZeUjYHIeexV5mvchRhXq RpbA3AkMirvDQxCoPBpbN7j9Emh33qU5+7f7xIc/smZoHnPEjUyNhahaJZ4Q6WIBh+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380287; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=d4NJAgdR36RjkLOa3WUwzVroUOgRKJRsP5sDy0+7bP4=; b=Ixnh8BgPqs3ifOOhlXnPlmOW+ekubXSp5TWThVPbwt37m3L7sv68E0Lpf1gxnhr2uezY pw6SarizmRhN7aMj/B7NMQg2LHdFFbzi4sndg/sOMahEgfsRXBCQiVk1FY6cSURU9njCS UWwmvhTiYoKIryo1vhQ6iGRAsODTKK00Yv7tyP7QDAkMpfgjOw7paqQiM8RWAOv6a+904 UrNAt5FP5KWx2hjdtk1A0lzAsufWel2+ka6hpOtphTL5lyNfaf5L38KUSUb83LJpRFOOR vr8zP4eFTp9Ywm/l/S2i4zPRFhAmaYz1ShTy6GSZq0Pc2tz/gOkla2XxAe0F1DfEmeg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=WwsZZiUG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 732CD606A322; Fri, 4 Dec 2026 10:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=WwsZZiUG Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA7CB1F000C2; Fri, 4 Dec 2026 10:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380287; bh=d4NJAgdR36RjkLOa3WUwzVroUOgRKJRsP5sDy0+7bP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WwsZZiUGYkJo3xE4NQvC4O79wRiRdt2v1Tn9ykkW4Ag4wXqxFuNkFCEEsmS5df0IZ 7crPZQVEM5mlPrjRuOE7fp/rD0aTvPf/s1OJq01Nq+LZlQ0FG5Dy0xN5KcmdDtaCOa ONoymoa3vJohBDKhkIBuf6QrUXjG00Jlhj9Kg950= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stefan Ghetu , Shengjiu Wang , Mark Brown , Sasha Levin Subject: [PATCH 7.3 207/742] ASoC: fsl_asrc_m2m: fix out-of-bounds write when draining the output FIFO Date: Fri, 4 Dec 2026 19:01:11 +0900 Message-ID: <20261204100640.581963109@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Ghetu [ Upstream commit 6b3f779dcac4ea16e232019b68650395ad55f5a2 ] asrc_read_last_fifo() checks the FIFO fill level, a number of frames, against a length in bytes, and ignores the frames already drained by previous iterations of its retry loop. With an output length close to the 512 KiB buffer size, which userspace controls through the task input size and formats, the drain writes past the end of the output buffer: 312 bytes for 10 channels of S24_LE with 8 frames left in the FIFO. Check the space needed by all drained frames in bytes. Fixes: 24a01710f627 ("ASoC: fsl_asrc_m2m: Add memory to memory function") Signed-off-by: Stefan Ghetu Reviewed-by: Shengjiu Wang Link: https://patch.msgid.link/20261116093751.138455-2-stefan.ghetu@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/fsl/fsl_asrc_m2m.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c index a90a1c8ed34d4..afb098f1ac33f 100644 --- a/sound/soc/fsl/fsl_asrc_m2m.c +++ b/sound/soc/fsl/fsl_asrc_m2m.c @@ -53,21 +53,27 @@ static void asrc_read_last_fifo(struct fsl_asrc_pair *pair, void *dma_vaddr, u32 { struct fsl_asrc *asrc = pair->asrc; enum asrc_pair_index index = pair->index; - u32 i, reg, size, t_size = 0, width; + u32 i, reg, size, t_size = 0, width, sample_bytes, frame_bytes; u32 *reg32 = NULL; u16 *reg16 = NULL; u8 *reg24 = NULL; width = snd_pcm_format_physical_width(pair->sample_format[OUT]); - if (width == 32) + if (width == 32) { reg32 = dma_vaddr + *length; - else if (width == 16) + sample_bytes = 4; + } else if (width == 16) { reg16 = dma_vaddr + *length; - else + sample_bytes = 2; + } else { reg24 = dma_vaddr + *length; + sample_bytes = 3; + } + + frame_bytes = pair->channels * sample_bytes; retry: size = asrc->get_output_fifo_size(pair); - if (size + *length > ASRC_M2M_BUFFER_SIZE) + if (*length + (t_size + size) * frame_bytes > ASRC_M2M_BUFFER_SIZE) goto end; for (i = 0; i < size * pair->channels; i++) { @@ -89,12 +95,7 @@ static void asrc_read_last_fifo(struct fsl_asrc_pair *pair, void *dma_vaddr, u32 goto retry; end: /* Update payload length */ - if (reg32) - *length += t_size * pair->channels * 4; - else if (reg16) - *length += t_size * pair->channels * 2; - else - *length += t_size * pair->channels * 3; + *length += t_size * frame_bytes; } /* config dma channel */ -- 2.53.0