Skip to content

Commit

Permalink
ACPICA: Use designated initializers
Browse files Browse the repository at this point in the history
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:
acpica/acpica#248

Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
kees authored and rafaeljw committed Jun 27, 2017
1 parent a976c29 commit 3d867f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/acpi/acpica/hwxfsleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
};

/*
Expand Down
4 changes: 4 additions & 0 deletions include/acpi/platform/acenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,4 +382,8 @@
#define ACPI_INIT_FUNCTION
#endif

#ifndef ACPI_STRUCT_INIT
#define ACPI_STRUCT_INIT(field, value) value
#endif

#endif /* __ACENV_H__ */
2 changes: 2 additions & 0 deletions include/acpi/platform/aclinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@
#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
Expand Down

0 comments on commit 3d867f6

Please sign in to comment.