Skip to content

Commit 9e56970

Browse files
Jian J Wangmergify[bot]
Jian J Wang
authored andcommitted
SecurityPkg/DxeImageVerificationLib: fix wrong fetch dbx in IsAllowedByDb (CVE-2019-14575)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1608 Normally two times of calling gRT->GetVariable() are needed to get the data of a variable: get the variable size by passing zero variable size, and then allocate enough memory and pass the correct variable size and buffer. But in the inner loop in IsAllowedByDb(), the DbxDataSize was not initialized to zero before calling gRT->GetVariable(). It won't cause problem if dbx does not exist. But it will give wrong result if dbx exists and the DbxDataSize happens to be a small enough value. In this situation, EFI_BUFFER_TOO_SMALL will be returned. Then the result check code followed will jump to 'Done', which is not correct because it's actually the value expected. if (Status == EFI_BUFFER_TOO_SMALL) { goto Done; } Cc: Jiewen Yao <[email protected]> Cc: Chao Zhang <[email protected]> Signed-off-by: Jian J Wang <[email protected]> Reviewed-by: Jiewen Yao <[email protected]>
1 parent c13742b commit 9e56970

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,9 @@ IsAllowedByDb (
14561456
//
14571457
// Here We still need to check if this RootCert's Hash is revoked
14581458
//
1459+
DbxDataSize = 0;
14591460
Status = gRT->GetVariable (EFI_IMAGE_SECURITY_DATABASE1, &gEfiImageSecurityDatabaseGuid, NULL, &DbxDataSize, NULL);
1460-
if (Status == EFI_BUFFER_TOO_SMALL) {
1461+
if (Status != EFI_BUFFER_TOO_SMALL) {
14611462
goto Done;
14621463
}
14631464
DbxData = (UINT8 *) AllocateZeroPool (DbxDataSize);

0 commit comments

Comments
 (0)