ACPI_PCI_ROUTING_TABLE: Replace fixed-size array with flex array member

The "Source" array is actually a dynamically sized array, but it
is defined as a fixed-size 4 byte array. This results in tripping
both compile-time and run-time bounds checkers (e.g. via either
__builtin_object_size() or -fsanitize=bounds).

To retain the padding, create a union with an unused Pad variable of
size 4, and redefine Source as a proper flexible array member.
This commit is contained in:
Kees Cook 2022-11-17 20:42:06 -08:00
parent 8a8443112b
commit b1c7901e10
1 changed files with 4 additions and 2 deletions

View File

@ -927,8 +927,10 @@ typedef struct acpi_pci_routing_table
UINT32 Pin;
UINT64 Address; /* here for 64-bit alignment */
UINT32 SourceIndex;
char Source[4]; /* pad to 64 bits so sizeof() works in all cases */
union {
char Pad[4]; /* pad to 64 bits so sizeof() works in all cases */
ACPI_FLEX_ARRAY(char, Source);
};
} ACPI_PCI_ROUTING_TABLE;
#endif /* __ACRESTYP_H__ */