mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 12:25:00 -04:00
soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
[ Upstream commit 84168d1b54e76a1bcb5192991adde5176abe02e3 ]
The code validates that segments of p_memsz bytes of a segment will fit
in the provided memory region, but does not validate that p_filesz bytes
will, which means that an incorrectly crafted ELF header might write
beyond the provided memory region.
Fixes: 051fb70fd4 ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
Reviewed-by: Sibi Sankar <sibis@codeaurora.org>
Link: https://lore.kernel.org/r/20210107233119.717173-1-bjorn.andersson@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
001c8e8364
commit
08b601cb7a
1 changed files with 8 additions and 0 deletions
|
|
@ -230,6 +230,14 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
|
|||
break;
|
||||
}
|
||||
|
||||
if (phdr->p_filesz > phdr->p_memsz) {
|
||||
dev_err(dev,
|
||||
"refusing to load segment %d with p_filesz > p_memsz\n",
|
||||
i);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
ptr = mem_region + offset;
|
||||
|
||||
if (phdr->p_filesz && phdr->p_offset < fw->size) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue