[Skiboot-stable] [PATCH 6.7.x 3/4] secvar/backend: fix a memory leak in get_pkcs7
Daniel Axtens
dja at axtens.net
Wed Jul 21 14:00:29 AEST 2021
commit 8dd8b6e4abb4d61cdf98470f3fe5cb750def7a18 upstream.
We need to actually free the pkcs7 structure, not just pass it to
mbedtls_pkcs7_free().
Signed-off-by: Daniel Axtens <dja at axtens.net>
Reviewed-by: Nayna Jain <nayna at linux.ibm.com>
Tested-by: Nayna Jain <nayna at linux.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
libstb/secvar/backend/edk2-compat-process.c | 1 +
libstb/secvar/test/Makefile.check | 5 +-
libstb/secvar/test/data/KEKpkcs7corrupt.h | 161 +++++++++++++++++++
libstb/secvar/test/secvar-test-edk2-compat.c | 15 ++
4 files changed, 181 insertions(+), 1 deletion(-)
create mode 100644 libstb/secvar/test/data/KEKpkcs7corrupt.h
diff --git a/libstb/secvar/backend/edk2-compat-process.c b/libstb/secvar/backend/edk2-compat-process.c
index c5113b72b3f1..3361eb5f8169 100644
--- a/libstb/secvar/backend/edk2-compat-process.c
+++ b/libstb/secvar/backend/edk2-compat-process.c
@@ -461,6 +461,7 @@ static mbedtls_pkcs7* get_pkcs7(const struct efi_variable_authentication_2 *auth
out:
mbedtls_pkcs7_free(pkcs7);
+ free(pkcs7);
pkcs7 = NULL;
return pkcs7;
}
diff --git a/libstb/secvar/test/Makefile.check b/libstb/secvar/test/Makefile.check
index 6cb1687d3a7e..5aeeb54d6ea8 100644
--- a/libstb/secvar/test/Makefile.check
+++ b/libstb/secvar/test/Makefile.check
@@ -10,6 +10,9 @@ HOSTCFLAGS += -I$(SRC)/$(LIBSTB_DIR)/crypto/mbedtls/include
# Needed because x86 and POWER disagree on the type for uint64_t, causes printf issues
HOSTCFLAGS+= -Wno-format
+# we want to test for leaks too:
+SECVAR_VALGRIND := $(VALGRIND) --leak-check=full
+
.PHONY : secvar-check
secvar-check: $(SECVAR_TEST:%=%-check) $(SECVAR_TEST_NOSTUB:%=%-check)
@@ -27,7 +30,7 @@ $(SECVAR_TEST:%=%-gcov-run) : %-run: %
$(SECVAR_TEST:%=%-check) : %-check: %
@dd if=/dev/zero of=secboot.img bs=128k count=1 2> /dev/null
- $(call QTEST, RUN-TEST ,$(VALGRIND) $<, $<)
+ $(call QTEST, RUN-TEST ,$(SECVAR_VALGRIND) $<, $<)
@$(RM) -f secboot.img
HOST_MBEDTLS_OBJS=$(MBEDTLS_OBJS:%.o=$(CRYPTO_DIR)/%.host.o)
diff --git a/libstb/secvar/test/data/KEKpkcs7corrupt.h b/libstb/secvar/test/data/KEKpkcs7corrupt.h
new file mode 100644
index 000000000000..4631db47faab
--- /dev/null
+++ b/libstb/secvar/test/data/KEKpkcs7corrupt.h
@@ -0,0 +1,161 @@
+unsigned char KEKpkcs7corrupt_auth[] = {
+0xe4 ,0x07 ,0x09 ,0x0e ,0x0e ,0x22 ,0x2e ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
+,0xd3 ,0x05 ,0x00 ,0x00 ,0x00 ,0x02 ,0xf1 ,0x0e ,0x9d ,0xd2 ,0xaf ,0x4a ,0xdf ,0x68 ,0xee ,0x49
+,0x8a ,0xa9 ,0x34 ,0x7d ,0x37 ,0x56 ,0x65 ,0xa7 ,0xff ,0xff ,0x05 ,0xb7 ,0x06 ,0x09 ,0x2a ,0x86
+,0x48 ,0x86 ,0xf7 ,0x0d ,0x01 ,0x07 ,0x02 ,0xa0 ,0x82 ,0x05 ,0xa8 ,0x30 ,0x82 ,0x05 ,0xa4 ,0x02
+,0x01 ,0x01 ,0x31 ,0x0f ,0x30 ,0x0d ,0x06 ,0x09 ,0x60 ,0x86 ,0x48 ,0x01 ,0x65 ,0x03 ,0x04 ,0x02
+,0x01 ,0x05 ,0x00 ,0x30 ,0x0b ,0x06 ,0x09 ,0x2a ,0x86 ,0x48 ,0x86 ,0xf7 ,0x0d ,0x01 ,0x07 ,0x01
+,0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,0x3b ,0x22 ,0xd2 ,0x96 ,0x42 ,0xcf ,0xbd ,0xd7 ,0x8b ,0x37 ,0x7a ,0xb6 ,0xd9 ,0xd4 ,0xd7
+,0x45 ,0x47 ,0x3b ,0x3c ,0xb3 ,0xd9 ,0x29 ,0x69 ,0x91 ,0x7d ,0x4c ,0x06 ,0xad ,0x6c ,0xea ,0x62
+,0xf1 ,0xf7 ,0xec ,0x67 ,0xae ,0xd5 ,0x43 ,0xd0 ,0xab ,0xb8 ,0xbf ,0xa4 ,0x28 ,0xd4 ,0x75 ,0xd2
+,0x3f ,0x53 ,0x5d ,0xa8 ,0x09 ,0x46 ,0x89 ,0x7f ,0x84 ,0x36 ,0xad ,0x78 ,0x41 ,0x03 ,0xf4 ,0xc4
+,0x43 ,0x43 ,0xdc ,0x52 ,0xc6 ,0xff ,0xab ,0xd6 ,0x8c ,0x7f ,0xc0 ,0xab ,0x67 ,0x5b ,0x0b ,0xa9
+,0x6a ,0xd2 ,0x85 ,0x71 ,0x9f ,0xc2 ,0xf1 ,0x96 ,0xd2 ,0x41 ,0xb0 };
+
+unsigned int KEKpkcs7corrupt_auth_len = 2523;
diff --git a/libstb/secvar/test/secvar-test-edk2-compat.c b/libstb/secvar/test/secvar-test-edk2-compat.c
index 4952a4b3d555..d715b17ec817 100644
--- a/libstb/secvar/test/secvar-test-edk2-compat.c
+++ b/libstb/secvar/test/secvar-test-edk2-compat.c
@@ -14,6 +14,7 @@
#include "./data/malformedkek.h"
#include "./data/trimmedKEK.h"
#include "./data/KEKeslcorrupt.h"
+#include "./data/KEKpkcs7corrupt.h"
#include "./data/db.h"
#include "./data/dbsigneddata.h"
#include "./data/OldTSKEK.h"
@@ -289,6 +290,20 @@ int run_test()
ASSERT(NULL != tmp);
ASSERT(0 == tmp->data_size);
+ /* KEK with corrupted pkcs7, used to leak memory */
+ printf("KEK with corrupt PKCS#7 message\n");
+ tmp = new_secvar("KEK", 4, KEKpkcs7corrupt_auth, KEKpkcs7corrupt_auth_len, 0);
+ ASSERT(0 == edk2_compat_validate(tmp));
+ list_add_tail(&update_bank, &tmp->link);
+ ASSERT(1 == list_length(&update_bank));
+
+ rc = edk2_compat_process(&variable_bank, &update_bank);
+ ASSERT(OPAL_PARAMETER == rc);
+ ASSERT(5 == list_length(&variable_bank));
+ ASSERT(0 == list_length(&update_bank));
+ tmp = find_secvar("KEK", 4, &variable_bank);
+ ASSERT(NULL != tmp);
+ ASSERT(0 == tmp->data_size);
/* Add valid KEK, .process(), succeeds. */
printf("Add KEK");
--
2.30.2
More information about the Skiboot-stable
mailing list