diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2024-02-09 14:02:16 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-02-14 14:22:24 +0100 |
commit | 98f681b0f84cfc3a1d83287b77697679e0398306 (patch) | |
tree | 1d9cc2d4c9d5a34a3154aae723dc063b538e3e0e /sound | |
parent | ASoC: meson: aiu: fix function pointer type (diff) | |
download | linux-98f681b0f84cfc3a1d83287b77697679e0398306.tar.xz linux-98f681b0f84cfc3a1d83287b77697679e0398306.zip |
ASoC: SOF: Add some bounds checking to firmware data
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>
Link: https://msgid.link/r/5593d147-058c-4de3-a6f5-540ecb96f6f8@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/sof/ipc3-loader.c | 2 |
1 files changed, 2 insertions, 0 deletions
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 */ |