Skip to content

Commit 55cc6fe

Browse files
mchehabrafaeljw
authored andcommitted
EFI/CPER: don't dump the entire memory region
The current logic at cper_print_fw_err() doesn't check if the error record length is big enough to handle offset. On a bad firmware, if the ofset is above the actual record, length -= offset will underflow, making it dump the entire memory. The end result can be: - the logic taking a lot of time dumping large regions of memory; - data disclosure due to the memory dumps; - an OOPS, if it tries to dump an unmapped memory region. Fix it by checking if the section length is too small before doing a hex dump. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> [ rjw: Subject tweaks ] Link: https://patch.msgid.link/1752b5ba63a3e2f148ddee813b36c996cc617e86.1767871950.git.mchehab+huawei@kernel.org Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent fa2408a commit 55cc6fe

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/firmware/efi/cper.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ static void cper_print_fw_err(const char *pfx,
560560
} else {
561561
offset = sizeof(*fw_err);
562562
}
563+
if (offset > length) {
564+
printk("%s""error section length is too small: offset=%d, length=%d\n",
565+
pfx, offset, length);
566+
return;
567+
}
563568

564569
buf += offset;
565570
length -= offset;

0 commit comments

Comments
 (0)