Skip to content

Commit 257d49a

Browse files
committed
Generate and use generated_sbat_var_defs.h
Build changes to generate include/generated_sbat_var_defs.h from SbatLevel_Variable.txt and use that header file. From here on forward SbatLevel_Variable.txt should be the only place a new revocation needs to be recorded. Signed-off-by: Jan Setje-Eilers <Jan.SetjeEilers@oracle.com>
1 parent 5be1564 commit 257d49a

File tree

5 files changed

+16
-47
lines changed

5 files changed

+16
-47
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Make.local
3939
/fuzz-*
4040
!/fuzz-*.c
4141
/generate_sbat_var_defs
42+
/generated_sbat_var_defs.h
4243
/leak-*
4344
/post-process-pe
4445
/random.bin

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ CFLAGS += -DENABLE_SHIM_CERT
3838
else
3939
TARGETS += $(MMNAME) $(FBNAME)
4040
endif
41-
# This is temporary and will go away soon
42-
TARGETS += generate_sbat_var_defs
4341
OBJS = shim.o globals.o mok.o netboot.o cert.o dp.o replacements.o tpm.o version.o errlog.o sbat.o sbat_data.o sbat_var.o pe.o pe-relocate.o httpboot.o csv.o load-options.o
4442
KEYS = shim_cert.h ocsp.* ca.* shim.crt shim.csr shim.p12 shim.pem shim.key shim.cer
4543
ORIG_SOURCES = shim.c globals.c mok.c netboot.c dp.c replacements.c tpm.c errlog.c sbat.c pe.c pe-relocate.c httpboot.c shim.h version.h $(wildcard include/*.h) cert.S sbat_var.S
@@ -102,6 +100,7 @@ shim.crt:
102100
shim.cer: shim.crt
103101
$(OPENSSL) x509 -outform der -in $< -out $@
104102

103+
105104
.NOTPARALLEL: shim_cert.h
106105
shim_cert.h: shim.cer
107106
echo "static UINT8 shim_cert[] __attribute__((__unused__)) = {" > $@
@@ -123,8 +122,10 @@ shim.o: $(SOURCES)
123122
ifneq ($(origin ENABLE_SHIM_CERT),undefined)
124123
shim.o: shim_cert.h
125124
endif
125+
sbat_var.S : generated_sbat_var_defs.h
126126
shim.o: $(wildcard $(TOPDIR)/*.h)
127127

128+
128129
sbat.%.csv : data/sbat.%.csv
129130
$(DOS2UNIX) $(D2UFLAGS) $< $@
130131
tail -c1 $@ | read -r _ || echo >> $@ # ensure a trailing newline
@@ -193,6 +194,10 @@ post-process-pe : $(TOPDIR)/post-process-pe.c
193194
generate_sbat_var_defs: $(TOPDIR)/generate_sbat_var_defs.c
194195
$(HOSTCC) -std=gnu11 -Og -g3 -Wall -Wextra -Wno-missing-field-initializers -Werror -o $@ $<
195196

197+
.NOTPARALLEL: generated_sbat_var_defs.h
198+
generated_sbat_var_defs.h: generate_sbat_var_defs
199+
./generate_sbat_var_defs $(TOPDIR) > $@
200+
196201
buildid : $(TOPDIR)/buildid.c
197202
$(HOSTCC) -I/usr/include -Og -g3 -Wall -Werror -Wextra -o $@ $< -lelf
198203

@@ -317,7 +322,7 @@ fuzz fuzz-clean fuzz-coverage fuzz-lto :
317322
EFI_INCLUDES="$(EFI_INCLUDES)" \
318323
fuzz-clean $@
319324

320-
test test-clean test-coverage test-lto :
325+
test test-clean test-coverage test-lto : generated_sbat_var_defs.h
321326
@make -f $(TOPDIR)/include/test.mk \
322327
COMPILER="$(COMPILER)" \
323328
CROSS_COMPILE="$(CROSS_COMPILE)" \
@@ -361,7 +366,7 @@ clean-lib-objs:
361366
clean-shim-objs:
362367
@rm -rvf $(TARGET) *.o $(SHIM_OBJS) $(MOK_OBJS) $(FALLBACK_OBJS) $(KEYS) certdb $(BOOTCSVNAME)
363368
@rm -vf *.debug *.so *.efi *.efi.* *.tar.* version.c buildid post-process-pe compile_commands.json
364-
@rm -vf generate_sbat_var_defs
369+
@rm -vf generate_sbat_var_defs generated_sbat_var_defs.h
365370
@rm -vf Cryptlib/*.[oa] Cryptlib/*/*.[oa]
366371
@if [ -d .git ] ; then git clean -f -d -e 'Cryptlib/OpenSSL/*'; fi
367372

include/sbat_var_defs.h

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#define QUOTE(s) #s
88

99
/*
10-
* This is the entry for the sbat data format
10+
* SbatLevel Epoch and SHIM_DEVEL definitions are here
11+
* Actual revocations are now soley defined in
12+
* SbatLevel_Variable.txt
1113
*/
1214
#define SBAT_VAR_SIG "sbat,"
1315
#define SBAT_VAR_VERSION "1,"
@@ -22,51 +24,10 @@
2224

2325
#define SBAT_VAR_LATEST_DATE "2022050100"
2426
#define SBAT_VAR_LATEST_REVOCATIONS "component,2\nothercomponent,2\n"
25-
#define SBAT_VAR_LATEST \
26-
SBAT_VAR_SIG SBAT_VAR_VERSION SBAT_VAR_LATEST_DATE "\n" \
27-
SBAT_VAR_LATEST_REVOCATIONS
28-
#else /* !ENABLE_SHIM_DEVEL */
29-
30-
/*
31-
* Some distros may want to apply revocations from 2022052400
32-
* or 2022111500 automatically. They can be selected by setting
33-
* SBAT_AUTOMATIC_DATE=<datestamp> at build time. Otherwise the
34-
* default is to apply the second to most recent revocations
35-
* automatically. Distros that need to manage automatic updates
36-
* externally from shim can choose the epoch 2021030218 emtpy
37-
* revocations.
38-
*/
39-
#ifndef SBAT_AUTOMATIC_DATE
40-
#define SBAT_AUTOMATIC_DATE 2023012900
41-
#endif /* SBAT_AUTOMATIC_DATE */
42-
#if SBAT_AUTOMATIC_DATE == 2021030218
43-
#define SBAT_VAR_AUTOMATIC_REVOCATIONS
44-
#elif SBAT_AUTOMATIC_DATE == 2022052400
45-
#define SBAT_VAR_AUTOMATIC_REVOCATIONS "grub,2\n"
46-
#elif SBAT_AUTOMATIC_DATE == 2022111500
47-
#define SBAT_VAR_AUTOMATIC_REVOCATIONS "shim,2\ngrub,3\n"
48-
#elif SBAT_AUTOMATIC_DATE == 2023012900
49-
#define SBAT_VAR_AUTOMATIC_REVOCATIONS "shim,2\ngrub,3\ngrub.debian,4\n"
50-
#elif SBAT_AUTOMATIC_DATE == 2024010900
51-
#define SBAT_VAR_AUTOMATIC_REVOCATIONS "shim,4\ngrub,3\ngrub.debian,4\n"
52-
#else
53-
#error "Unknown SBAT_AUTOMATIC_DATE"
54-
#endif /* SBAT_AUTOMATIC_DATE == */
55-
#define SBAT_VAR_AUTOMATIC_DATE QUOTEVAL(SBAT_AUTOMATIC_DATE)
56-
#define SBAT_VAR_AUTOMATIC \
57-
SBAT_VAR_SIG SBAT_VAR_VERSION SBAT_VAR_AUTOMATIC_DATE "\n" \
58-
SBAT_VAR_AUTOMATIC_REVOCATIONS
5927

60-
/*
61-
* Revocations for:
62-
* - January 2024 shim CVEs
63-
* - October 2023 grub CVEs
64-
* - Debian/Ubuntu (peimage) CVE-2024-2312
65-
*/
66-
#define SBAT_VAR_LATEST_DATE "2024040900"
67-
#define SBAT_VAR_LATEST_REVOCATIONS "shim,4\ngrub,4\ngrub.peimage,2\n"
6828
#define SBAT_VAR_LATEST \
6929
SBAT_VAR_SIG SBAT_VAR_VERSION SBAT_VAR_LATEST_DATE "\n" \
7030
SBAT_VAR_LATEST_REVOCATIONS
7131
#endif /* ENABLE_SHIM_DEVEL */
32+
7233
#endif /* !SBAT_VAR_DEFS_H_ */

sbat_var.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: BSD-2-Clause-Patent
22

33
#include "include/sbat_var_defs.h"
4+
#include "generated_sbat_var_defs.h"
45

56
.section .sbatlevel, "a", %progbits
67
.balignl 4, 0

test-sbat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "sbat_var_defs.h"
99
#endif
1010
#include "shim.h"
11+
#include "generated_sbat_var_defs.h"
1112

1213
#include <stdio.h>
1314

0 commit comments

Comments
 (0)