Skip to contentSkip to conversation

efi: cper: check section header more appropriately

PATCH Applied Shuai Xue 2 participants 2 messages Aug 23, 2021 – Aug 27, 2021

Subsystems (2)
lore
Share & tools
lore

Shuai Xue

author reviewer
#0 lore raw

PATCH 1/1 efi: cper: check section header more appropriately

When checking a generic status block, we iterate over all the generic data blocks. The loop condition checks that the generic data block is valid. Because the size of data blocks (excluding error data) may vary depending on the revision and the revision is contained within the data block, we should ensure that enough of the current data block is valid appropiriately for different revision.

---
 drivers/firmware/efi/cper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/cper.c +1 -1
index e15d484b6a5a..e80706d9e78a 100644
@@ -635,7 +635,7 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
 	data_len = estatus->data_length;
 
 	apei_estatus_for_each_section(estatus, gdata) {
-		if (sizeof(struct acpi_hest_generic_data) > data_len)
+		if (acpi_hest_get_size(gdata) > data_len)
 			return -EINVAL;
 
 		record_size = acpi_hest_get_record_size(gdata);
Signature · 1 line
2.20.1.12.g72788fdb
maintainer Applied
#1 lore raw
Quoted 9 lines · Shuai Xue

When checking a generic status block, we iterate over all the generic data blocks. The loop condition checks that the generic data block is valid. Because the size of data blocks (excluding error data) may vary depending on the revision and the revision is contained within the data block, we should ensure that enough of the current data block is valid appropiriately for different revision.

Applied, thanks.

Quoted 20 lines
---
 drivers/firmware/efi/cper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/cper.c +1 -2
index e15d484b6a5a..e80706d9e78a 100644
@@ -635,7 +635,7 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
        data_len = estatus->data_length;
 
        apei_estatus_for_each_section(estatus, gdata) {
-               if (sizeof(struct acpi_hest_generic_data) > data_len)
+               if (acpi_hest_get_size(gdata) > data_len)
                        return -EINVAL;
 
                record_size = acpi_hest_get_record_size(gdata);
--

2.20.1.12.g72788fdb