]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/DxeImageVerificationLib: catch alignment overflow (CVE-2019-14562)
authorLaszlo Ersek <lersek@redhat.com>
Tue, 1 Sep 2020 09:12:21 +0000 (11:12 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 2 Sep 2020 10:16:18 +0000 (10:16 +0000)
The DxeImageVerificationHandler() function currently checks whether
"SecDataDir" has enough room for "WinCertificate->dwLength". However, for
advancing "OffSet", "WinCertificate->dwLength" is aligned to the next
multiple of 8. If "WinCertificate->dwLength" is large enough, the
alignment will return 0, and "OffSet" will be stuck at the same value.

Check whether "SecDataDir" has room left for both
"WinCertificate->dwLength" and the alignment.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2215
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200901091221.20948-4-lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Wenyi Xie <xiewenyi2@huawei.com>
Reviewed-by: Min M Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c

index 100739eb3eb68ef4ab257c96312179a4c24d8cf0..11154b6cc58aee2184bf979454fa0ed7ebde9d87 100644 (file)
@@ -1860,7 +1860,9 @@ DxeImageVerificationHandler (
       break;\r
     }\r
     WinCertificate = (WIN_CERTIFICATE *) (mImageBase + OffSet);\r
-    if (SecDataDirLeft < WinCertificate->dwLength) {\r
+    if (SecDataDirLeft < WinCertificate->dwLength ||\r
+        (SecDataDirLeft - WinCertificate->dwLength <\r
+         ALIGN_SIZE (WinCertificate->dwLength))) {\r
       break;\r
     }\r
 \r