aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Child <nnac123@gmail.com>2021-07-20 12:04:58 -0400
committerVasant Hegde <hegdevasant@linux.vnet.ibm.com>2021-07-22 12:09:53 +0530
commited764f33ab62d6357a7439992a3f547b755f6e6e (patch)
treeaa70f61eab424b62a5b3fb90df4cc29a74b5806c
parent5eea157271852eaf16c59ef542a889ea6563a2d6 (diff)
downloadskiboot-ed764f33ab62d6357a7439992a3f547b755f6e6e.zip
skiboot-ed764f33ab62d6357a7439992a3f547b755f6e6e.tar.gz
skiboot-ed764f33ab62d6357a7439992a3f547b755f6e6e.tar.bz2
secvar: ensure ESL buf size is at least what ESL header expects
[ Upstream commit 8a31163a0271f11b4597bca4e803f559e38e3d24 ] Currently, `get_esl_cert` receives a data buffer containing an ESL and its length. It is to return a data buffer of the certificate that is contained inside the ESL. The ESL has header info that contains the certificates `size` and the size of the header (`sig_data_offset`). We use this information to copy `size` bytes starting `sig_data_offset` bytes after the given ESL buffer. Currently we are checking that the length of the ESL buffer is at least `sig_data_offset` bytes but we are not checking that it also has enough bytes to also contain `size` bytes of the certificate. This becomes problematic if some data at the end of the ESL gets lost. Since the ESL claims it has more than it actually does, this will lead to a buffer over-read. What is even worse, is that this buffer over-read can go unnoticed since the last 256 bytes of the ESL are usually the x509 2048 bit signature so the extra garbage bytes that are copied will appear to be a valid rsa signature. To resolve this, this commit ensures that the ESL buffer length is large enough to hold the data that it claims it contains. Lastly, a new test case is added to test the described condition. It includes a new test file `trimmedKEK.h` which contains a struct a valid KEK auth file minus 5 bytes, therefore making it invalid. Fixes: 87562bc5c1a6 ("secvar/backend: add edk2 derived key updates processing") Signed-off-by: Nick Child <nick.child@ibm.com> Reviewed-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Nayna Jain <nayna@linux.ibm.com> Tested-by: Nayna Jain <nayna@linux.ibm.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
-rw-r--r--libstb/secvar/backend/edk2-compat-process.c6
-rw-r--r--libstb/secvar/test/data/trimmedKEK.h161
-rw-r--r--libstb/secvar/test/secvar-test-edk2-compat.c16
3 files changed, 182 insertions, 1 deletions
diff --git a/libstb/secvar/backend/edk2-compat-process.c b/libstb/secvar/backend/edk2-compat-process.c
index 037c1b4..55b50d6 100644
--- a/libstb/secvar/backend/edk2-compat-process.c
+++ b/libstb/secvar/backend/edk2-compat-process.c
@@ -135,8 +135,12 @@ static int get_esl_cert(const char *buf, const size_t buflen, char **cert)
sig_data_offset = sizeof(EFI_SIGNATURE_LIST)
+ le32_to_cpu(list->SignatureHeaderSize)
+ 16 * sizeof(uint8_t);
- if (sig_data_offset > buflen)
+
+ /* Ensure this ESL does not overflow the bounds of the buffer */
+ if (sig_data_offset + size > buflen) {
+ prlog(PR_ERR, "Number of bytes of ESL data is less than size specified\n");
return OPAL_PARAMETER;
+ }
*cert = zalloc(size);
if (!(*cert))
diff --git a/libstb/secvar/test/data/trimmedKEK.h b/libstb/secvar/test/data/trimmedKEK.h
new file mode 100644
index 0000000..6600d25
--- /dev/null
+++ b/libstb/secvar/test/data/trimmedKEK.h
@@ -0,0 +1,161 @@
+unsigned char trimmedKEK_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 ,0x30 ,0x82 ,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 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,0x0f ,0x3a ,0x04 ,0x42 ,0xfe ,0x45 ,0x82 ,0x29 ,0x56 ,0x5e ,0xe5
+,0x4c ,0xeb ,0x4b ,0xa6 ,0xe5 ,0xe0 ,0x1d ,0x74 ,0xc0 ,0x5a ,0x2f ,0x42 ,0xa5 ,0xf2 ,0x65 ,0xd5
+,0x4d ,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};
+
+unsigned int trimmedKEK_auth_len = 2518;
diff --git a/libstb/secvar/test/secvar-test-edk2-compat.c b/libstb/secvar/test/secvar-test-edk2-compat.c
index 8259ffa..a769863 100644
--- a/libstb/secvar/test/secvar-test-edk2-compat.c
+++ b/libstb/secvar/test/secvar-test-edk2-compat.c
@@ -12,6 +12,7 @@
#include "./data/KEK.h"
#include "./data/invalidkek.h"
#include "./data/malformedkek.h"
+#include "./data/trimmedKEK.h"
#include "./data/db.h"
#include "./data/dbsigneddata.h"
#include "./data/OldTSKEK.h"
@@ -196,6 +197,21 @@ int run_test()
tmp = find_secvar("db", 3, &variable_bank);
ASSERT(NULL != tmp);
+ /* Add trimmed KEK, .process(), should fail. */
+ printf("Add trimmed KEK\n");
+ tmp = new_secvar("KEK", 4, trimmedKEK_auth, trimmedKEK_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");
tmp = new_secvar("KEK", 4, KEK_auth, KEK_auth_len, 0);