提交 d5b7a1ec 编写于 作者: B Bjorn Andersson 提交者: Zheng Zengkai

soc: qcom: mdt_loader: Validate that p_filesz < p_memsz

stable inclusion
from stable-5.10.37
commit ab86e5145f61ad8f47a81b2d3a39ea7c6a54ad8b
bugzilla: 51868
CVE: NA

--------------------------------

[ Upstream commit 84168d1b ]

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: 051fb70f ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
Reviewed-by: NSibi Sankar <sibis@codeaurora.org>
Link: https://lore.kernel.org/r/20210107233119.717173-1-bjorn.andersson@linaro.orgSigned-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 1effa4b5
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册