ACK: [PATCH] lib: fwts_smbios: use fwts_safe_memcpy to read SMBIOS entry
ivanhu
ivan.hu at canonical.com
Mon Aug 21 06:40:21 UTC 2017
On 08/11/2017 09:41 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Use fwts_safe_memcpy rather than a fwts_safe_memread and then an
> un-safe copy as a micro optimisation. Also throw an error and
> return a NULL address if the memcpy failed because the memory is
> unreadable. Fixes a bug on aarch64 systems where this entry is
> non-readable and causes a BUS error.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_smbios.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_smbios.c b/src/lib/src/fwts_smbios.c
> index b3773aa2..abef4eb6 100644
> --- a/src/lib/src/fwts_smbios.c
> +++ b/src/lib/src/fwts_smbios.c
> @@ -56,13 +56,14 @@ static void *fwts_smbios_find_entry_uefi(fwts_framework *fw, fwts_smbios_entry *
> const size_t size = sizeof(fwts_smbios_entry);
>
> if ((mapped_entry = fwts_mmap((off_t)addr, size)) != FWTS_MAP_FAILED) {
> - if (fwts_safe_memread(mapped_entry, size) == FWTS_OK) {
> - *entry = *mapped_entry;
> + if (fwts_safe_memcpy(entry, mapped_entry, size) == FWTS_OK) {
> (void)fwts_munmap(mapped_entry, size);
> *type = FWTS_SMBIOS;
> return addr;
> } else {
> + fwts_log_error(fw, "Cannot read mmap'd SMBIOS entry at 0x%p\n", addr);
> (void)fwts_munmap(mapped_entry, size);
> + addr = NULL;
> }
> }
>
> @@ -73,7 +74,7 @@ static void *fwts_smbios_find_entry_uefi(fwts_framework *fw, fwts_smbios_entry *
> return addr;
> }
>
> - fwts_log_error(fw, "Cannot mmap SMBIOS entry at %p\n", addr);
> + fwts_log_error(fw, "Cannot mmap SMBIOS entry at 0x%p\n", addr);
> }
> return NULL;
> }
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list