[PATCH 0/2] soc: qcom: mdt_loader: Fix integer overflows in segment bounds checks
From: Abel Vesa
Date: Sat Dec 05 2026 - 17:26:24 EST
Sashiko reported that the segment bounds check in
qcom_mdt_load_no_init() can be bypassed on 32-bit platforms, where
offset + p_memsz is computed in 32 bits and can wrap around, letting a
crafted firmware image zero memory beyond the end of the memory region.
Patch 1 fixes that by doing the check in 64 bits, which also covers the
offset getting truncated with LPAE.
While looking at it, qcom_mdt_read_metadata() turned out to have similar
issues: it copies the ELF header using a size taken from the image
without checking it against the size of the firmware, which reads out
of bounds on any platform, and its other size computations can wrap on
32-bit. Patch 2 fixes these.
Prepared with help from an LLM-based assistant.
Signed-off-by: Abel Vesa <abel.vesa@xxxxxxxxxxxxxxxx>
---
Abel Vesa (2):
soc: qcom: mdt_loader: Fix segment bounds check overflow on 32-bit
soc: qcom: mdt_loader: Validate metadata sizes against the firmware
drivers/soc/qcom/mdt_loader.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
---
base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
change-id: 20261205-mdt-loader-overflow-fa009fc16041
Best regards,
--
Abel