linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sibi Sankar <sibis@codeaurora.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Andy Gross <agross@kernel.org>,
	Siddharth Gupta <sidgup@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soc: qcom: mdt_loader: Detect truncated read of segments
Date: Thu, 8 Apr 2021 16:31:23 +0530	[thread overview]
Message-ID: <b26cbf35-0500-1e79-9de8-de447a69f78f@codeaurora.org> (raw)
In-Reply-To: <20210107232526.716989-1-bjorn.andersson@linaro.org>


Hey Bjorn,

Thanks for the patch!

On 1/8/21 4:55 AM, Bjorn Andersson wrote:
> Given that no validation of how much data the firmware loader read in
> for a given segment truncated segment files would best case result in a
> hash verification failure, without any indication of what went wrong.
> 
> Improve this by validating that the firmware loader did return the
> amount of data requested.
> 
> Fixes: 445c2410a449 ("soc: qcom: mdt_loader: Use request_firmware_into_buf()")
> 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 24cd193dec55..e01d18e9ad2b 100644
> --- a/drivers/soc/qcom/mdt_loader.c
> +++ b/drivers/soc/qcom/mdt_loader.c
> @@ -253,6 +253,14 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
>   				break;
>   			}
>   
> +			if (seg_fw->size != phdr->p_filesz) {
> +				dev_err(dev,
> +					"failed to load segment %d from truncated file %s\n",
> +					i, fw_name);
> +				ret = -EINVAL;
> +				break;

seg_fw has to be released on error condition as well.
With ^^ fixed you can have my R-b.

Reviewed-by: Sibi Sankar <sibis@codeaurora.org>

> +			}
> +
>   			release_firmware(seg_fw);
>   		}
>   
> 

-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc, is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

      reply	other threads:[~2021-04-08 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 23:25 [PATCH] soc: qcom: mdt_loader: Detect truncated read of segments Bjorn Andersson
2021-04-08 11:01 ` Sibi Sankar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b26cbf35-0500-1e79-9de8-de447a69f78f@codeaurora.org \
    --to=sibis@codeaurora.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sidgup@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).