Modify the SRAT parsing logic to prevent reading past the table buffer
length provided.
Check if the Static Resource Allocation Structure's buffer fits in the
SRAT table buffer before its contents are dumped.
Prevent buffer overruns when reading the Static Resource Allocation
Structure's header.
References:
- ACPI 6.3, January 2019, Section 5.2.16
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@inte.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
0,\r
NULL,\r
ResourcePtr,\r
- 2, // The length is 1 byte at offset 1\r
+ AcpiTableLength - Offset,\r
PARSER_PARAMS (SratResourceAllocationParser)\r
);\r
\r
+ // Make sure the SRAT structure lies inside the table\r
+ if ((Offset + *SratRALength) > AcpiTableLength) {\r
+ IncrementErrorCount ();\r
+ Print (\r
+ L"ERROR: Invalid SRAT structure length. SratRALength = %d. " \\r
+ L"RemainingTableBufferLength = %d. SRAT parsing aborted.\n",\r
+ *SratRALength,\r
+ AcpiTableLength - Offset\r
+ );\r
+ return;\r
+ }\r
+\r
switch (*SratRAType) {\r
case EFI_ACPI_6_2_GICC_AFFINITY:\r
AsciiSPrint (\r