mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-08 10:25:20 +02:00
platform/x86/intel/ifs: Validate image size
[ Upstream commit 25a76dbb36
]
Perform additional validation prior to loading IFS image.
Error out if the size of the file being loaded doesn't match the size
specified in the header.
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Link: https://lore.kernel.org/r/20231005195137.3117166-6-jithu.joseph@intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
8464e99e38
commit
14dde93c31
|
@ -260,6 +260,7 @@ int ifs_load_firmware(struct device *dev)
|
||||||
{
|
{
|
||||||
const struct ifs_test_caps *test = ifs_get_test_caps(dev);
|
const struct ifs_test_caps *test = ifs_get_test_caps(dev);
|
||||||
struct ifs_data *ifsd = ifs_get_data(dev);
|
struct ifs_data *ifsd = ifs_get_data(dev);
|
||||||
|
unsigned int expected_size;
|
||||||
const struct firmware *fw;
|
const struct firmware *fw;
|
||||||
char scan_path[64];
|
char scan_path[64];
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
@ -274,6 +275,13 @@ int ifs_load_firmware(struct device *dev)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expected_size = ((struct microcode_header_intel *)fw->data)->totalsize;
|
||||||
|
if (fw->size != expected_size) {
|
||||||
|
dev_err(dev, "File size mismatch (expected %u, actual %zu). Corrupted IFS image.\n",
|
||||||
|
expected_size, fw->size);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data);
|
ret = image_sanity_check(dev, (struct microcode_header_intel *)fw->data);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto release;
|
goto release;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user