ACPICA: Use designated initializers
authorKees Cook <keescook@chromium.org>
Mon, 26 Jun 2017 22:53:07 +0000 (00:53 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 27 Jun 2017 20:27:24 +0000 (22:27 +0200)
The struct layout randomization plugin detects and randomizes any structs
that contain only function pointers. Once layout is randomized, all
initialization must be designated or the compiler will misalign the
assignments. This switches all the ACPICA function pointer struct to
use designated initializers, using the proposed upstream ACPICA macro:
https://github.com/acpica/acpica/pull/248/

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpica/hwxfsleep.c
include/acpi/platform/acenv.h
include/acpi/platform/aclinux.h

index 5733b1167e46cd1207d1d6c88345c4c541a745d8..7ef13934968f3d56d2e76cba94ec5424cfdaaa3c 100644 (file)
@@ -70,11 +70,15 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
 
 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
-       {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
-        acpi_hw_extended_sleep},
-       {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
-        acpi_hw_extended_wake_prep},
-       {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
+       {ACPI_STRUCT_INIT(legacy_function,
+                         ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep)),
+        ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_sleep) },
+       {ACPI_STRUCT_INIT(legacy_function,
+                         ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep)),
+        ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_wake_prep) },
+       {ACPI_STRUCT_INIT(legacy_function,
+                         ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake)),
+        ACPI_STRUCT_INIT(extended_function, acpi_hw_extended_wake) }
 };
 
 /*
index 09994b063243c749ddfa424c82c154ee2552cf69..912563c66948e48568e90f618bf1b8872e3342f6 100644 (file)
 #define ACPI_INIT_FUNCTION
 #endif
 
+#ifndef ACPI_STRUCT_INIT
+#define ACPI_STRUCT_INIT(field, value) value
+#endif
+
 #endif                         /* __ACENV_H__ */
index a39e3f67616fc299c2c98964f3ec28cc064a0202..047f13865608e246bad8dea81f45a4826f05357d 100644 (file)
 #define ACPI_MSG_BIOS_ERROR     KERN_ERR "ACPI BIOS Error (bug): "
 #define ACPI_MSG_BIOS_WARNING   KERN_WARNING "ACPI BIOS Warning (bug): "
 
+#define ACPI_STRUCT_INIT(field, value) .field = value
+
 #else                          /* !__KERNEL__ */
 
 #define ACPI_USE_STANDARD_HEADERS