Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPICA: acpi_resource_irq: Replace 1-element arrays with flexible array

ACPICA commit bfdd3446e7caf795c85c70326c137023942972c5

Similar to "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 acpi_dm_address_common(), but appears to be harmless.

Link: https://github.com/acpica/acpica/commit/bfdd3446
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Kees Cook and committed by
Rafael J. Wysocki
376b0fb3 2a85fc56

+12 -3
+4 -1
drivers/acpi/acpica/amlresrc.h
··· 261 261 struct aml_resource_extended_irq { 262 262 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; 263 263 u8 interrupt_count; 264 - u32 interrupts[1]; 264 + union { 265 + u32 interrupt; 266 + ACPI_FLEX_ARRAY(u32, interrupts); 267 + }; 265 268 /* res_source_index, res_source optional fields follow */ 266 269 }; 267 270
+8 -2
include/acpi/acrestyp.h
··· 142 142 u8 shareable; 143 143 u8 wake_capable; 144 144 u8 interrupt_count; 145 - u8 interrupts[1]; 145 + union { 146 + u8 interrupt; 147 + ACPI_FLEX_ARRAY(u8, interrupts); 148 + }; 146 149 }; 147 150 148 151 struct acpi_resource_dma { ··· 338 335 u8 wake_capable; 339 336 u8 interrupt_count; 340 337 struct acpi_resource_source resource_source; 341 - u32 interrupts[1]; 338 + union { 339 + u32 interrupt; 340 + ACPI_FLEX_ARRAY(u32, interrupts); 341 + }; 342 342 }; 343 343 344 344 struct acpi_resource_generic_register {