Skip to content

Commit 7428ab7

Browse files
committedSep 18, 2017
[build] Exclude selected directories from Secure Boot builds
When submitting binaries for UEFI Secure Boot signing, certain known-dubious subsystems (such as 802.11 and NFS) must be excluded from the build. Mark the directories containing these subsystems as insecure, and allow the build target to include an explicit "security flag" (a literal "-sb" appended to the build platform) to exclude these source directories from the build process. For example: make bin-x86_64-efi-sb/ipxe.efi will build iPXE with all code from the 802.11 and NFS subsystems excluded from the build. Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent d46c53c commit 7428ab7

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed
 

‎src/Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ QEMUIMG := qemu-img
6262
SRCDIRS :=
6363
SRCDIRS += libgcc
6464
SRCDIRS += core
65-
SRCDIRS += net net/oncrpc net/tcp net/udp net/infiniband net/80211
65+
SRCDIRS += net net/tcp net/udp net/infiniband
6666
SRCDIRS += image
6767
SRCDIRS += drivers/bus
6868
SRCDIRS += drivers/net
@@ -71,10 +71,6 @@ SRCDIRS += drivers/net/e1000e
7171
SRCDIRS += drivers/net/igb
7272
SRCDIRS += drivers/net/igbvf
7373
SRCDIRS += drivers/net/phantom
74-
SRCDIRS += drivers/net/rtl818x
75-
SRCDIRS += drivers/net/ath
76-
SRCDIRS += drivers/net/ath/ath5k
77-
SRCDIRS += drivers/net/ath/ath9k
7874
SRCDIRS += drivers/net/vxge
7975
SRCDIRS += drivers/net/efi
8076
SRCDIRS += drivers/net/tg3
@@ -105,6 +101,16 @@ SRCDIRS += hci/keymap
105101
SRCDIRS += usr
106102
SRCDIRS += config
107103

104+
# These directories contain code that is not eligible for UEFI Secure
105+
# Boot signing.
106+
#
107+
SRCDIRS_INSEC += net/oncrpc
108+
SRCDIRS_INSEC += net/80211
109+
SRCDIRS_INSEC += drivers/net/rtl818x
110+
SRCDIRS_INSEC += drivers/net/ath
111+
SRCDIRS_INSEC += drivers/net/ath/ath5k
112+
SRCDIRS_INSEC += drivers/net/ath/ath9k
113+
108114
# NON_AUTO_SRCS lists files that are excluded from the normal
109115
# automatic build system.
110116
#

‎src/Makefile.housekeeping

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ endif
299299
#
300300
# Select build architecture and platform based on $(BIN)
301301
#
302-
# BIN has the form bin[-[arch-]platform]
302+
# BIN has the form bin[-[<arch>-]<platform>[-sb]]
303303

304304
ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
305305
PLATFORMS := $(patsubst config/defaults/%.h,%,\
@@ -312,17 +312,18 @@ platforms :
312312

313313
ifdef BIN
314314

315-
# Determine architecture portion of $(BIN), if present
316-
BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
317-
$(patsubst bin-$(A)-%,$(A),\
318-
$(filter bin-$(A)-%,$(BIN)))))
319-
320-
# Determine platform portion of $(BIN), if present
321-
ifeq ($(BIN_ARCH),)
322-
BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
315+
# Split $(BIN) into architecture, platform, and security flag (where present)
316+
BIN_ELEMENTS := $(subst -,$(SPACE),$(BIN))
317+
BIN_APS := $(wordlist 2,4,$(BIN_ELEMENTS))
318+
ifeq ($(lastword $(BIN_APS)),sb)
319+
BIN_AP := $(wordlist 2,$(words $(BIN_APS)),discard $(BIN_APS))
320+
BIN_SECUREBOOT := 1
323321
else
324-
BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
322+
BIN_AP := $(BIN_APS)
323+
BIN_SECUREBOOT := 0
325324
endif
325+
BIN_PLATFORM := $(lastword $(BIN_AP))
326+
BIN_ARCH := $(wordlist 2,$(words $(BIN_AP)),discard $(BIN_AP))
326327

327328
# Determine build architecture
328329
DEFAULT_ARCH := i386
@@ -339,6 +340,13 @@ CFLAGS += -DPLATFORM=$(PLATFORM)
339340
platform :
340341
@$(ECHO) $(PLATFORM)
341342

343+
# Determine security flag
344+
DEFAULT_SECUREBOOT := 0
345+
SECUREBOOT := $(firstword $(BIN_SECUREBOOT) $(DEFAULT_SECUREBOOT))
346+
CFLAGS += -DSECUREBOOT=$(SECUREBOOT)
347+
secureboot :
348+
@$(ECHO) $(SECUREBOOT)
349+
342350
endif # defined(BIN)
343351

344352
# Include architecture-specific Makefile
@@ -357,6 +365,11 @@ endif
357365
#
358366
# Source file handling
359367

368+
# Exclude known-insecure files from Secure Boot builds
369+
ifeq ($(SECUREBOOT),0)
370+
SRCDIRS += $(SRCDIRS_INSEC)
371+
endif
372+
360373
# SRCDIRS lists all directories containing source files.
361374
srcdirs :
362375
@$(ECHO) $(SRCDIRS)

0 commit comments

Comments
 (0)