[PATCH] fwts:dmicheck: replace memcpy with byte copy for SMBIOS 3.0 table

Colin Ian King colin.king at canonical.com
Mon Nov 28 20:07:36 UTC 2016


On 28/11/16 18:26, wufan wrote:
> From 00cae446405d4d856fbd56222f835c207d18d8e8 Mon Sep 17 00:00:00 2001
> 
> From: Fan Wu <wufan at codeaurora.org>
> 
> Date: Thu, 3 Nov 2016 14:03:40 -0600
> 
> Subject: [PATCH] fwts:dmicheck: replace memcpy with byte copy for SMBIOS 3.0
> 
> table
> 
>  
> 
> Mapping of SMBIOS 3.0 table in AARCH64 platforms through /dev/mem
> 
> has the memory tagged as device memory, and memcpy could trigger
> 
> alignment fault if the SMBIOS table is of odd size. The fix is to
> 
> replace memcpy with byte copy.
> 
>  
> 
> Change-Id: I52a5be2fedcd057fdd5e510ff090e4129f128221
> 
> ---
> 
> src/dmi/dmicheck/dmicheck.c | 7 +++++--
> 
> 1 file changed, 5 insertions(+), 2 deletions(-)
> 
>  
> 
> diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
> 
> index 1934ebe..98db76b 100644
> 
> --- a/src/dmi/dmicheck/dmicheck.c
> 
> +++ b/src/dmi/dmicheck/dmicheck.c
> 
> @@ -370,8 +370,11 @@ static void* dmi_table_smbios30(fwts_framework *fw,
> fwts_smbios30_entry *entry)
> 
>         mem = fwts_mmap(addr, length);
> 
>         if (mem != FWTS_MAP_FAILED) {
> 
>                 table = malloc(length);
> 
> -               if (table)
> 
> -                       memcpy(table, mem, length);
> 
> +               if (table) {
> 
> +                       size_t i = length;
> 
> +                       while (i--)
> 
> +                               ((uint8_t*)table)[i] = ((uint8_t*)mem)[i];
> 
> +               }
> 
>                 (void)fwts_munmap(mem, length);
> 
>                 return table;
> 
>         }
> 
> --
> 
> 1.8.2.1
> 
Is this a hypothetical issue or does it fix an observed issue with
non-aligned SMBIOS tables?

Colin




More information about the fwts-devel mailing list