lkml.org 
[lkml]   [2021]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 167/323] soc: qcom: mdt_loader: Detect truncated read of segments
    Date
    From: Bjorn Andersson <bjorn.andersson@linaro.org>

    [ Upstream commit 0648c55e3a21ccd816e99b6600d6199fbf39d23a ]

    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()")
    Reviewed-by: Sibi Sankar <sibis@codeaurora.org>
    Link: https://lore.kernel.org/r/20210107232526.716989-1-bjorn.andersson@linaro.org
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/soc/qcom/mdt_loader.c | 9 +++++++++
    1 file changed, 9 insertions(+)

    diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
    index 17cba12cdf61..9155b1c75cfb 100644
    --- a/drivers/soc/qcom/mdt_loader.c
    +++ b/drivers/soc/qcom/mdt_loader.c
    @@ -193,6 +193,15 @@ 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);
    + release_firmware(seg_fw);
    + ret = -EINVAL;
    + break;
    + }
    +
    release_firmware(seg_fw);
    }

    --
    2.30.2


    \
     
     \ /
      Last update: 2021-05-20 12:45    [W:4.086 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site