firmware: coreboot: Check size of table entry and use flex-array

The memcpy() of the data following a coreboot_table_entry couldn't
be evaluated by the compiler under CONFIG_FORTIFY_SOURCE. To make it
easier to reason about, add an explicit flexible array member to struct
coreboot_device so the entire entry can be copied at once. Additionally,
validate the sizes before copying. Avoids this run-time false positive

  memcpy: detected field-spanning write (size 168) of single field "&device->entry" at drivers/firmware/google/coreboot_table.c:103 (size 8)

Reported-by: Paul Menzel <>
Cc: Jack Rosenthal <>
Cc: Guenter Roeck <>
Cc: Julius Werner <>
Cc: Brian Norris <>
Cc: Stephen Boyd <>
Cc: Greg Kroah-Hartman <>
Signed-off-by: Kees Cook <>
Reviewed-by: Julius Werner <>
Reviewed-by: Guenter Roeck <>
Reviewed-by: Stephen Boyd <>
Reviewed-by: Jack Rosenthal <>
2 files changed