Skip to content

Commit 1a38879

Browse files
committed
efi: libstub: Disable struct randomization
The EFI stub is a wrapper around the core kernel that makes it look like a EFI compatible PE/COFF application to the EFI firmware. EFI applications run on top of the EFI runtime, which is heavily based on so-called protocols, which are struct types consisting [mostly] of function pointer members that are instantiated and recorded in a protocol database. These structs look like the ideal randomization candidates to the randstruct plugin (as they only carry function pointers), but of course, these protocols are contracts between the firmware that exposes them, and the EFI applications (including our stubbed kernel) that invoke them. This means that struct randomization for EFI protocols is not a great idea, and given that the stub shares very little data with the core kernel that is represented as a randomizable struct, we're better off just disabling it completely here. Cc: <[email protected]> # v4.14+ Reported-by: Daniel Marth <[email protected]> Tested-by: Daniel Marth <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Acked-by: Kees Cook <[email protected]>
1 parent 568035b commit 1a38879

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/firmware/efi/libstub/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
3737
$(call cc-option,-fno-addrsig) \
3838
-D__DISABLE_EXPORTS
3939

40+
#
41+
# struct randomization only makes sense for Linux internal types, which the EFI
42+
# stub code never touches, so let's turn off struct randomization for the stub
43+
# altogether
44+
#
45+
KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS))
46+
4047
# remove SCS flags from all objects in this directory
4148
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
4249
# disable LTO

0 commit comments

Comments
 (0)