capsule: Put a check for image index before the update
authorSughosh Ganu <sughosh.ganu@linaro.org>
Fri, 15 Apr 2022 05:59:36 +0000 (11:29 +0530)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 15 Apr 2022 08:43:18 +0000 (10:43 +0200)
commit7cf06f09cc516c276ce7ad5f2c7c2b0a5110dd34
treeb6e5b941c0aa651933a29f4b20443ed0406b6632
parent1ea06bc929ad1ce3350e2184ad81872c87d9fad4
capsule: Put a check for image index before the update

The current capsule update code compares the image GUID value in the
capsule header with the image GUID value obtained from the
GetImageInfo function of the Firmware Management Protocol(FMP). This
comparison is done to ascertain if the FMP's SetImage function can be
called for the update. Make this checking more robust by comparing the
image_index value passed through the capsule with that returned by the
FMP's GetImageInfo function. This protects against the scenario of the
firmware being updated in a wrong partition/location on the storage
device if an incorrect value has been passed through the capsule,
since the image_index is used to determine the location of the update
on the storage device.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_capsule.c