summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKees Cook <kees@outflux.net>2022-11-17 20:48:16 -0800
committerKees Cook <kees@outflux.net>2023-03-02 11:03:42 -0800
commitbfdd3446e7caf795c85c70326c137023942972c5 (patch)
treec78f683f2209220297ac884d408740f608d2e8c2
parent9879d9995482be4c76d56d41d4074dd3146c690f (diff)
downloadacpica-bfdd3446e7caf795c85c70326c137023942972c5.tar.gz
ACPI_RESOURCE_IRQ: Replace 1-element arrays with flexible array
Similar to commit 7ba2f3d91a32 ("Replace one-element array with flexible-array"), replace the 1-element array with a proper flexible array member as defined by C99. This allows the code to operate without tripping compile-time and run-time bounds checkers (e.g. via __builtin_object_size(), -fsanitize=bounds, and/or -fstrict-flex-arrays=3). Note that the spec requires there be at least one interrupt, so use a union to keep space allocated for this. The only binary change in .text and .data sections is some rearrangement by the compiler of AcpiDmAddressCommon(), but appears to be harmless.
-rw-r--r--source/include/acrestyp.h10
-rw-r--r--source/include/amlresrc.h5
2 files changed, 12 insertions, 3 deletions
diff --git a/source/include/acrestyp.h b/source/include/acrestyp.h
index ccde5bdde..0dab6ec7b 100644
--- a/source/include/acrestyp.h
+++ b/source/include/acrestyp.h
@@ -290,7 +290,10 @@ typedef struct acpi_resource_irq
UINT8 Shareable;
UINT8 WakeCapable;
UINT8 InterruptCount;
- UINT8 Interrupts[1];
+ union {
+ UINT8 Interrupt;
+ ACPI_FLEX_ARRAY(UINT8, Interrupts);
+ };
} ACPI_RESOURCE_IRQ;
@@ -541,7 +544,10 @@ typedef struct acpi_resource_extended_irq
UINT8 WakeCapable;
UINT8 InterruptCount;
ACPI_RESOURCE_SOURCE ResourceSource;
- UINT32 Interrupts[1];
+ union {
+ UINT32 Interrupt;
+ ACPI_FLEX_ARRAY(UINT32, Interrupts);
+ };
} ACPI_RESOURCE_EXTENDED_IRQ;
diff --git a/source/include/amlresrc.h b/source/include/amlresrc.h
index 1ad70d171..05fa1505d 100644
--- a/source/include/amlresrc.h
+++ b/source/include/amlresrc.h
@@ -503,7 +503,10 @@ typedef struct aml_resource_extended_irq
AML_RESOURCE_LARGE_HEADER_COMMON
UINT8 Flags;
UINT8 InterruptCount;
- UINT32 Interrupts[1];
+ union {
+ UINT32 Interrupt;
+ ACPI_FLEX_ARRAY(UINT32, Interrupts);
+ };
/* ResSourceIndex, ResSource optional fields follow */
} AML_RESOURCE_EXTENDED_IRQ;