Browse Source

[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>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
7428ab7258
2 changed files with 34 additions and 15 deletions
  1. 11
    5
      src/Makefile
  2. 23
    10
      src/Makefile.housekeeping

+ 11
- 5
src/Makefile View File

@@ -62,7 +62,7 @@ QEMUIMG		:= qemu-img
62 62
 SRCDIRS		:=
63 63
 SRCDIRS		+= libgcc
64 64
 SRCDIRS		+= core
65
-SRCDIRS		+= net net/oncrpc net/tcp net/udp net/infiniband net/80211
65
+SRCDIRS		+= net net/tcp net/udp net/infiniband
66 66
 SRCDIRS		+= image
67 67
 SRCDIRS		+= drivers/bus
68 68
 SRCDIRS		+= drivers/net
@@ -71,10 +71,6 @@ SRCDIRS		+= drivers/net/e1000e
71 71
 SRCDIRS		+= drivers/net/igb
72 72
 SRCDIRS		+= drivers/net/igbvf
73 73
 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
78 74
 SRCDIRS		+= drivers/net/vxge
79 75
 SRCDIRS		+= drivers/net/efi
80 76
 SRCDIRS		+= drivers/net/tg3
@@ -105,6 +101,16 @@ SRCDIRS		+= hci/keymap
105 101
 SRCDIRS		+= usr
106 102
 SRCDIRS		+= config
107 103
 
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
+
108 114
 # NON_AUTO_SRCS lists files that are excluded from the normal
109 115
 # automatic build system.
110 116
 #

+ 23
- 10
src/Makefile.housekeeping View File

@@ -299,7 +299,7 @@ endif
299 299
 #
300 300
 # Select build architecture and platform based on $(BIN)
301 301
 #
302
-# BIN has the form bin[-[arch-]platform]
302
+# BIN has the form bin[-[<arch>-]<platform>[-sb]]
303 303
 
304 304
 ARCHS		:= $(patsubst arch/%,%,$(wildcard arch/*))
305 305
 PLATFORMS	:= $(patsubst config/defaults/%.h,%,\
@@ -312,17 +312,18 @@ platforms :
312 312
 
313 313
 ifdef BIN
314 314
 
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
323 321
 else
324
-BIN_PLATFORM	:= $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
322
+BIN_AP		:= $(BIN_APS)
323
+BIN_SECUREBOOT	:= 0
325 324
 endif
325
+BIN_PLATFORM	:= $(lastword $(BIN_AP))
326
+BIN_ARCH	:= $(wordlist 2,$(words $(BIN_AP)),discard $(BIN_AP))
326 327
 
327 328
 # Determine build architecture
328 329
 DEFAULT_ARCH	:= i386
@@ -339,6 +340,13 @@ CFLAGS		+= -DPLATFORM=$(PLATFORM)
339 340
 platform :
340 341
 	@$(ECHO) $(PLATFORM)
341 342
 
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
+
342 350
 endif # defined(BIN)
343 351
 
344 352
 # Include architecture-specific Makefile
@@ -357,6 +365,11 @@ endif
357 365
 #
358 366
 # Source file handling
359 367
 
368
+# Exclude known-insecure files from Secure Boot builds
369
+ifeq ($(SECUREBOOT),0)
370
+SRCDIRS		+= $(SRCDIRS_INSEC)
371
+endif
372
+
360 373
 # SRCDIRS lists all directories containing source files.
361 374
 srcdirs :
362 375
 	@$(ECHO) $(SRCDIRS)

Loading…
Cancel
Save