* [PATCH] soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
@ 2021-01-07 23:31 Bjorn Andersson
2021-04-08 11:18 ` Sibi Sankar
2021-04-09 16:00 ` patchwork-bot+linux-arm-msm
0 siblings, 2 replies; 3+ messages in thread
From: Bjorn Andersson @ 2021-01-07 23:31 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Siddharth Gupta; +Cc: linux-arm-msm, linux-kernel
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: 051fb70fd4ea ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
drivers/soc/qcom/mdt_loader.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index e01d18e9ad2b..5180b5996830 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -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) {
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
2021-01-07 23:31 [PATCH] soc: qcom: mdt_loader: Validate that p_filesz < p_memsz Bjorn Andersson
@ 2021-04-08 11:18 ` Sibi Sankar
2021-04-09 16:00 ` patchwork-bot+linux-arm-msm
1 sibling, 0 replies; 3+ messages in thread
From: Sibi Sankar @ 2021-04-08 11:18 UTC (permalink / raw)
To: Bjorn Andersson, Andy Gross, Siddharth Gupta; +Cc: linux-arm-msm, linux-kernel
Hey Bjorn,
Thanks for the patch!
On 1/8/21 5:01 AM, Bjorn Andersson wrote:
> 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: 051fb70fd4ea ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> drivers/soc/qcom/mdt_loader.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> index e01d18e9ad2b..5180b5996830 100644
> --- a/drivers/soc/qcom/mdt_loader.c
> +++ b/drivers/soc/qcom/mdt_loader.c
> @@ -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;
> + }
> +
Reviewed-by: Sibi Sankar <sibis@codeaurora.org>
> ptr = mem_region + offset;
>
> if (phdr->p_filesz && phdr->p_offset < fw->size) {
>
--
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc, is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
2021-01-07 23:31 [PATCH] soc: qcom: mdt_loader: Validate that p_filesz < p_memsz Bjorn Andersson
2021-04-08 11:18 ` Sibi Sankar
@ 2021-04-09 16:00 ` patchwork-bot+linux-arm-msm
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2021-04-09 16:00 UTC (permalink / raw)
To: Bjorn Andersson; +Cc: linux-arm-msm
Hello:
This patch was applied to qcom/linux.git (refs/heads/for-next):
On Thu, 7 Jan 2021 15:31:19 -0800 you wrote:
> 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: 051fb70fd4ea ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
>
> [...]
Here is the summary with links:
- soc: qcom: mdt_loader: Validate that p_filesz < p_memsz
https://git.kernel.org/qcom/c/84168d1b54e7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-09 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 23:31 [PATCH] soc: qcom: mdt_loader: Validate that p_filesz < p_memsz Bjorn Andersson
2021-04-08 11:18 ` Sibi Sankar
2021-04-09 16:00 ` patchwork-bot+linux-arm-msm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.