]> www.infradead.org Git - users/dwmw2/linux.git/commit
firmware: cs_dsp: Fix overflow checking of wmfw header
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 27 Jun 2024 14:14:29 +0000 (15:14 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 1 Jul 2024 13:10:22 +0000 (14:10 +0100)
commit3019b86bce16fbb5bc1964f3544d0ce7d0137278
tree9385749e97180470d5ced2bcb1fd1acd3a2208f8
parent68f97fe330e01450ace63da0ce5cab676fc97f9a
firmware: cs_dsp: Fix overflow checking of wmfw header

Fix the checking that firmware file buffer is large enough for the
wmfw header, to prevent overrunning the buffer.

The original code tested that the firmware data buffer contained
enough bytes for the sums of the size of the structs

wmfw_header + wmfw_adsp1_sizes + wmfw_footer

But wmfw_adsp1_sizes is only used on ADSP1 firmware. For ADSP2 and
Halo Core the equivalent struct is wmfw_adsp2_sizes, which is
4 bytes longer. So the length check didn't guarantee that there
are enough bytes in the firmware buffer for a header with
wmfw_adsp2_sizes.

This patch splits the length check into three separate parts. Each
of the wmfw_header, wmfw_adsp?_sizes and wmfw_footer are checked
separately before they are used.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: f6bc909e7673 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
Link: https://patch.msgid.link/20240627141432.93056-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/firmware/cirrus/cs_dsp.c