* [PATCH] ASoC: SOF: Add some bounds checking to firmware data
@ 2024-02-09 13:02 Dan Carpenter
2024-02-14 15:44 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-02-09 13:02 UTC (permalink / raw)
To: Pierre-Louis Bossart
Cc: Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
Daniel Baluta, Kai Vehmanen, Mark Brown, Jaroslav Kysela,
Takashi Iwai, sound-open-firmware, linux-sound, linux-kernel,
kernel-janitors
Smatch complains about "head->full_size - head->header_size" can
underflow. To some extent, we're always going to have to trust the
firmware a bit. However, it's easy enough to add a check for negatives,
and let's add a upper bounds check as well.
Fixes: d2458baa799f ("ASoC: SOF: ipc3-loader: Implement firmware parsing and loading")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
sound/soc/sof/ipc3-loader.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/sof/ipc3-loader.c b/sound/soc/sof/ipc3-loader.c
index 28218766d211..6e3ef0672110 100644
--- a/sound/soc/sof/ipc3-loader.c
+++ b/sound/soc/sof/ipc3-loader.c
@@ -148,6 +148,8 @@ static size_t sof_ipc3_fw_parse_ext_man(struct snd_sof_dev *sdev)
head = (struct sof_ext_man_header *)fw->data;
remaining = head->full_size - head->header_size;
+ if (remaining < 0 || remaining > sdev->basefw.fw->size)
+ return -EINVAL;
ext_man_size = ipc3_fw_ext_man_size(sdev, fw);
/* Assert firmware starts with extended manifest */
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: SOF: Add some bounds checking to firmware data
2024-02-09 13:02 [PATCH] ASoC: SOF: Add some bounds checking to firmware data Dan Carpenter
@ 2024-02-14 15:44 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-02-14 15:44 UTC (permalink / raw)
To: Pierre-Louis Bossart, Dan Carpenter
Cc: Liam Girdwood, Peter Ujfalusi, Bard Liao, Ranjani Sridharan,
Daniel Baluta, Kai Vehmanen, Jaroslav Kysela, Takashi Iwai,
sound-open-firmware, linux-sound, linux-kernel, kernel-janitors
On Fri, 09 Feb 2024 16:02:16 +0300, Dan Carpenter wrote:
> Smatch complains about "head->full_size - head->header_size" can
> underflow. To some extent, we're always going to have to trust the
> firmware a bit. However, it's easy enough to add a check for negatives,
> and let's add a upper bounds check as well.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: SOF: Add some bounds checking to firmware data
commit: 98f681b0f84cfc3a1d83287b77697679e0398306
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-14 15:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-09 13:02 [PATCH] ASoC: SOF: Add some bounds checking to firmware data Dan Carpenter
2024-02-14 15:44 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®