boot: add checks for invalid splash images in UKI
A malformed bmp with 8bits depth but smaller color
map would cause out of bounds reads. This is not a real
problem as the image is signed, but better to be safe.
Reported on yeswehack.com as:
YWH-PGM9780-135
Follow-up for 0fa2cac4f0
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
82d96837db
commit
186032e1ed
@@ -119,6 +119,12 @@ static EFI_STATUS bmp_parse_header(
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Ensure there can be no OOB accesses in bmp_to_blt() due to malformed images (e.g.: color depth 8
|
||||
* but smaller color map) via map[*in]. */
|
||||
if (IN_SET(dib->depth, 1, 4, 8) &&
|
||||
file->offset - (sizeof(struct bmp_file) + dib->size) < sizeof(struct bmp_map) * (1U << dib->depth))
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
*ret_map = map;
|
||||
*ret_dib = dib;
|
||||
*pixmap = bmp + file->offset;
|
||||
|
||||
Reference in New Issue
Block a user