Skip to content

Test mok mirror #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e3e6e72
Make CopyMem() work with EFI's declaration
vathpela Aug 4, 2021
34460fe
mok: delete the existing RT variables only when only_first=TRUE
lcp Jun 30, 2021
d0f98c5
Update gnu-efi
vathpela Aug 4, 2021
681a6c9
Add some more stuff to .gitignore
vathpela Aug 2, 2021
13cb202
Ignore a gcc issue in test-str.c
vathpela Aug 4, 2021
4594297
More minor improvements to support for COMPILER=clang
vathpela Aug 2, 2021
da41fa6
cleanup: always use BS and RT, not gBS and gRT
vathpela Jul 23, 2021
e401272
tests: clean up temp data after running tests
vathpela Aug 2, 2021
42246db
tests: make the CompareGuid() comparison size be less stupid
vathpela Aug 2, 2021
7479ee2
mok: move the mok_state_variables definitions to their own header
vathpela Jul 23, 2021
dcc968c
shim/mm/fb: move global state to its own source file
vathpela Jul 23, 2021
4ba12de
tpm: free measureddata when SHIM_UNIT_TEST is set
vathpela Aug 3, 2021
4a74db1
tests: Disable some logging when SHIM_UNIT_TEST is enabled
vathpela Aug 16, 2021
35b9fc4
tests: link all tests against libefivar
vathpela Jul 23, 2021
156df09
tests: Add a 'test-coverage' make target for gcov
vathpela Aug 4, 2021
52b6305
tests: add an efi error decoder
vathpela Aug 3, 2021
15339ea
tests: add some slightly better EFIAPI error mocks
vathpela Aug 3, 2021
71cc981
tests: add a mock implementation of {Get,Set}Variable and tests for it
vathpela Jul 22, 2021
fa4fd86
tests: model different behaviors for deleting variables
vathpela Aug 3, 2021
ea23585
tests: add pre and post hooks to the mock variable store
vathpela Jul 22, 2021
8c0a47e
tests: Add config table support
vathpela Jul 26, 2021
c7eb2b7
tests: Add a unit test for mok mirroring
vathpela Jul 23, 2021
5bd1269
mok: Fix memory leak in mok mirroring
vathpela Aug 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Make.local
*.efi.signed
*.esl
*.gdb*
*.gcda
*.gcno
*.gcov
*.hash
*.key
*.key
Expand All @@ -27,7 +30,9 @@ Make.local
*.sw?
*.tar.*
/build*/
/.cache/
/certdb/
/compile_commands.json
/cov-int/
/post-process-pe
/random.bin
Expand All @@ -37,5 +42,6 @@ Make.local
shim_cert.h
/test-*
!/test-*.c
!/test-data/
/test-random.h
version.c
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "gnu-efi"]
path = gnu-efi
url = https://github.com/rhboot/gnu-efi.git
branch = shim-15.4
branch = shim-15.5
2 changes: 1 addition & 1 deletion Cryptlib/Hash/CryptMd5.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Md5Duplicate (
return FALSE;
}

CopyMem (NewMd5Context, Md5Context, sizeof (MD5_CTX));
CopyMem (NewMd5Context, (void *)Md5Context, sizeof (MD5_CTX));

return TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion Cryptlib/Hash/CryptSha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Sha1Duplicate (
return FALSE;
}

CopyMem (NewSha1Context, Sha1Context, sizeof (SHA_CTX));
CopyMem (NewSha1Context, (void *)Sha1Context, sizeof (SHA_CTX));

return TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion Cryptlib/Hash/CryptSha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Sha256Duplicate (
return FALSE;
}

CopyMem (NewSha256Context, Sha256Context, sizeof (SHA256_CTX));
CopyMem (NewSha256Context, (void *)Sha256Context, sizeof (SHA256_CTX));

return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions Cryptlib/Hash/CryptSha512.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Sha384Duplicate (
return FALSE;
}

CopyMem (NewSha384Context, Sha384Context, sizeof (SHA512_CTX));
CopyMem (NewSha384Context, (void *)Sha384Context, sizeof (SHA512_CTX));

return TRUE;
}
Expand Down Expand Up @@ -308,7 +308,7 @@ Sha512Duplicate (
return FALSE;
}

CopyMem (NewSha512Context, Sha512Context, sizeof (SHA512_CTX));
CopyMem (NewSha512Context, (void *)Sha512Context, sizeof (SHA512_CTX));

return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions Cryptlib/Include/OpenSslSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ extern FILE *stdout;
//
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
//
#define memcpy(dest,source,count) ( {CopyMem(dest,source,(UINTN)(count)); dest; })
#define memcpy(dest,source,count) ( {CopyMem(dest,(void *)source,(UINTN)(count)); dest; })
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
#define memchr(buf,ch,count) ScanMem8((CHAR8 *)buf,(UINTN)(count),ch)
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
#define memmove(dest,source,count) CopyMem(dest,(void *)source,(UINTN)(count))
#define localtime(timer) NULL
#define assert(expression)
#define atoi(nptr) AsciiStrDecimalToUintn((const CHAR8 *)nptr)
Expand Down
2 changes: 1 addition & 1 deletion Cryptlib/Pk/CryptPkcs7Verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ WrapPkcs7Data (
//
// Part7: P7Data.
//
CopyMem (SignedData + 19, P7Data, P7Length);
CopyMem (SignedData + 19, (void *)P7Data, P7Length);
}

*WrapFlag = Wrapped;
Expand Down
7 changes: 6 additions & 1 deletion Make.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ override EFI_INCLUDES := $(EFI_INCLUDES)
EFI_CRT_OBJS = $(LOCAL_EFI_PATH)/crt0-efi-$(ARCH_GNUEFI).o
EFI_LDS = $(TOPDIR)/elf_$(ARCH)_efi.lds

CLANG_BUGS = $(if $(findstring gcc,$(CC)),-maccumulate-outgoing-args,)
CLANG_WARNINGS = -Wno-pointer-bool-conversion \
-Wno-unknown-attributes

CLANG_BUGS = $(if $(findstring gcc,$(CC)),-maccumulate-outgoing-args,) \
$(if $(findstring clang,$(CC)),$(CLANG_WARNINGS))

COMMIT_ID ?= $(shell if [ -e .git ] ; then git log -1 --pretty=format:%H ; elif [ -f commit ]; then cat commit ; else echo master; fi)

Expand Down Expand Up @@ -131,6 +135,7 @@ $(call update-variable,WERRFLAGS)
CFLAGS = $(FEATUREFLAGS) \
$(OPTIMIZATIONS) \
$(WARNFLAGS) \
$(if $(findstring clang,$(CC)),$(CLANG_WARNINGS)) \
$(ARCH_CFLAGS) \
$(WERRFLAGS) \
$(INCLUDES) \
Expand Down
29 changes: 21 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ CFLAGS += -DENABLE_SHIM_CERT
else
TARGETS += $(MMNAME) $(FBNAME)
endif
OBJS = shim.o mok.o netboot.o cert.o replacements.o tpm.o version.o errlog.o sbat.o sbat_data.o pe.o httpboot.o csv.o load-options.o
OBJS = shim.o globals.o mok.o netboot.o cert.o replacements.o tpm.o version.o errlog.o sbat.o sbat_data.o pe.o httpboot.o csv.o load-options.o
KEYS = shim_cert.h ocsp.* ca.* shim.crt shim.csr shim.p12 shim.pem shim.key shim.cer
ORIG_SOURCES = shim.c mok.c netboot.c replacements.c tpm.c errlog.c sbat.c pe.c httpboot.c shim.h version.h $(wildcard include/*.h)
MOK_OBJS = MokManager.o PasswordCrypt.o crypt_blowfish.o errlog.o sbat_data.o
ORIG_SOURCES = shim.c globals.c mok.c netboot.c replacements.c tpm.c errlog.c sbat.c pe.c httpboot.c shim.h version.h $(wildcard include/*.h)
MOK_OBJS = MokManager.o PasswordCrypt.o crypt_blowfish.o errlog.o sbat_data.o globals.o
ORIG_MOK_SOURCES = MokManager.c PasswordCrypt.c crypt_blowfish.c shim.h $(wildcard include/*.h)
FALLBACK_OBJS = fallback.o tpm.o errlog.o sbat_data.o
FALLBACK_OBJS = fallback.o tpm.o errlog.o sbat_data.o globals.o
ORIG_FALLBACK_SRCS = fallback.c
SBATPATH = $(TOPDIR)/data/sbat.csv

Expand Down Expand Up @@ -153,7 +153,10 @@ gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a: C
gnu-efi/$(ARCH_GNUEFI)/gnuefi/libgnuefi.a gnu-efi/$(ARCH_GNUEFI)/lib/libefi.a:
mkdir -p gnu-efi/lib gnu-efi/gnuefi
$(MAKE) -C gnu-efi \
ARCH=$(ARCH_GNUEFI) TOPDIR=$(TOPDIR)/gnu-efi \
COMPILER="$(COMPILER)" \
CC="$(CC)" \
ARCH=$(ARCH_GNUEFI) \
TOPDIR=$(TOPDIR)/gnu-efi \
-f $(TOPDIR)/gnu-efi/Makefile \
lib gnuefi inc

Expand Down Expand Up @@ -284,8 +287,14 @@ else
$(PESIGN) -n certdb -i $< -c "shim" -s -o $@ -f
endif

test :
@make -f $(TOPDIR)/include/test.mk EFI_INCLUDES="$(EFI_INCLUDES)" ARCH_DEFINES="$(ARCH_DEFINES)" all
test test-clean test-coverage test-lto :
@make -f $(TOPDIR)/include/test.mk \
COMPILER="$(COMPILER)" \
CROSS_COMPILE="$(CROSS_COMPILE)" \
CLANG_WARNINGS="$(CLANG_WARNINGS)" \
ARCH_DEFINES="$(ARCH_DEFINES)" \
EFI_INCLUDES="$(EFI_INCLUDES)" \
test-clean $@

$(patsubst %.c,%,$(wildcard test-*.c)) :
@make -f $(TOPDIR)/include/test.mk EFI_INCLUDES="$(EFI_INCLUDES)" ARCH_DEFINES="$(ARCH_DEFINES)" $@
Expand All @@ -298,7 +307,11 @@ clean-test-objs:
clean-gnu-efi:
@if [ -d gnu-efi ] ; then \
$(MAKE) -C gnu-efi \
ARCH=$(ARCH_GNUEFI) TOPDIR=$(TOPDIR)/gnu-efi \
CC="$(CC)" \
HOSTCC="$(HOSTCC)" \
COMPILER="$(COMPILER)" \
ARCH=$(ARCH_GNUEFI) \
TOPDIR=$(TOPDIR)/gnu-efi \
-f $(TOPDIR)/gnu-efi/Makefile \
clean ; \
fi
Expand Down
Loading