diff options
| author | Atul Akella <atul.akella@gmail.com> | 2026-10-05 11:25:17 +0000 |
|---|---|---|
| committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2026-11-02 11:11:33 -0600 |
| commit | 695aa66b8e278af935b98a2dca5b5b9f10a71eb9 (patch) | |
| tree | 4bc0cb707434ca1f2eda76ee5de60eff534a80e7 /scripts/Makefile.thinlto | |
| parent | 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 (diff) | |
| download | linux-next-695aa66b8e278af935b98a2dca5b5b9f10a71eb9.tar.gz linux-next-695aa66b8e278af935b98a2dca5b5b9f10a71eb9.zip | |
remoteproc: mtk_scp: Fix bounds check in mt8183_scp_da_to_va()
mt8183_scp_da_to_va() translates a device address to a pointer into
SCP SRAM or DRAM. Its bounds check is wrong in two ways:
- offset is an int but is assigned from a u64. For the DRAM window,
da = dma_addr + 0x100000010 is truncated to offset 0x10 and passes
the check. There is also no da >= dma_addr check, so a da below
dma_addr wraps in the u64 subtraction and can truncate to a small
positive offset.
- (offset + len) is computed in size_t and wraps for a large len.
With offset = 0x100 and len = (size_t)-0x80, the sum is 0x80 and
the check passes.
da and len come from the firmware's ELF program headers
(p_paddr/p_memsz) via rproc_da_to_va(), and the returned pointer is
then written to by the ELF loader, so a malformed firmware image can
make the loader write outside the intended region.
Use a u64 offset, check da >= dma_addr before subtracting, and
compare len against the remaining window size instead of adding it
to offset.
Fixes: 63c13d61eafe ("remoteproc/mediatek: add SCP support for mt8183")
Cc: stable@vger.kernel.org
Signed-off-by: Atul Akella <atul.akella@gmail.com>
Link: https://lore.kernel.org/r/2e32034b79ea7cad99b7ea9edfb8b2ad64f5096b.1791198233.git.atul.akella@gmail.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
