Skip to content

Commit d97cb43

Browse files
anderssongregkh
authored andcommitted
soc: qcom: mdt_loader: Detect truncated read of segments
[ Upstream commit 0648c55 ] 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: 445c241 ("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>
1 parent ab86e51 commit d97cb43

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎drivers/soc/qcom/mdt_loader.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
261261
break;
262262
}
263263

264+
if (seg_fw->size != phdr->p_filesz) {
265+
dev_err(dev,
266+
"failed to load segment %d from truncated file %s\n",
267+
i, fw_name);
268+
release_firmware(seg_fw);
269+
ret = -EINVAL;
270+
break;
271+
}
272+
264273
release_firmware(seg_fw);
265274
}
266275

0 commit comments

Comments
 (0)