Skip to content

Commit

Permalink
ASoC: SOF: Add some bounds checking to firmware data
Browse files Browse the repository at this point in the history
[ Upstream commit 98f681b0f84cfc3a1d83287b77697679e0398306 ]

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: d2458ba ("ASoC: SOF: ipc3-loader: Implement firmware parsing and loading")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://msgid.link/r/5593d147-058c-4de3-a6f5-540ecb96f6f8@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and Sasha Levin committed Mar 26, 2024
1 parent c990190 commit ced7df8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sound/soc/sof/ipc3-loader.c
Expand Up @@ -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 */
Expand Down

0 comments on commit ced7df8

Please sign in to comment.