From: "Ștefan Ghețu" <stefanghetu9@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Mark Brown <broonie@kernel.org>
Cc: "Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.dev>,
"Vijendar Mukunda" <Vijendar.Mukunda@amd.com>,
"Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
sound-open-firmware@alsa-project.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
"Ștefan Ghețu" <stefanghetu9@gmail.com>
Subject: [PATCH] ASoC: SOF: ipc3: bound firmware-supplied ext header size
Date: Thu, 10 Sep 2026 00:23:53 +0300 [thread overview]
Message-ID: <20260909212353.69599-1-stefanghetu9@gmail.com> (raw)
ext_hdr->hdr.size comes straight from firmware and is used unchecked
as a read length: too large overflows the PAGE_SIZE heap allocation
in ext_data, too small underflows the size_t subtraction (hdr.size -
sizeof(*ext_hdr)), producing a read length near SIZE_MAX.
Bound hdr.size to [sizeof(*ext_hdr), PAGE_SIZE] before using it.
Signed-off-by: Ștefan Ghețu <stefanghetu9@gmail.com>
---
sound/soc/sof/ipc3.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/sound/soc/sof/ipc3.c b/sound/soc/sof/ipc3.c
index 85bb22bbe18d..6188e43726e2 100644
--- a/sound/soc/sof/ipc3.c
+++ b/sound/soc/sof/ipc3.c
@@ -598,6 +598,14 @@ static int ipc3_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 offset)
ext_hdr = ext_data;
while (ext_hdr->hdr.cmd == SOF_IPC_FW_READY) {
+ /* bound hdr.size to avoid heap overflow/underflow */
+ if (ext_hdr->hdr.size < sizeof(*ext_hdr) ||
+ ext_hdr->hdr.size > PAGE_SIZE) {
+ dev_err(sdev->dev, "invalid ext data size 0x%x\n",
+ ext_hdr->hdr.size);
+ ret = -EINVAL;
+ break;
+ }
/* read in ext structure */
snd_sof_dsp_block_read(sdev, SOF_FW_BLK_TYPE_SRAM,
offset + sizeof(*ext_hdr),
--
2.53.0
next reply other threads:[~2026-09-09 21:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 21:23 Ștefan Ghețu [this message]
2026-09-10 12:08 ` [PATCH] ASoC: SOF: ipc3: bound firmware-supplied ext header size Péter Ujfalusi
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=20260909212353.69599-1-stefanghetu9@gmail.com \
--to=stefanghetu9@gmail.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.