public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Kun Qin <kun.q@outlook.com>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>,
	Xiaoyu Lu <xiaoyux.lu@intel.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Guomin Jiang <guomin.jiang@intel.com>
Subject: [PATCH v1 0/1] CryptoPkg: BaseCryptLib: Fix buffer double free in CryptPkcs7VerifyEku
Date: Tue, 20 Oct 2020 19:32:27 -0700	[thread overview]
Message-ID: <MWHPR06MB31028BF719295103D1C4C73BF31C0@MWHPR06MB3102.namprd06.prod.outlook.com> (raw)

The issue is in VerifyEKUsInPkcs7Signature routine of
CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c:

At the "Exit" portion of this routine, this function uses X509_free to free
SignerCert instance and PKCS7_free function to free Pkcs7. But SignerCert
is part of Pkcs7 instance, thus PKCS7_free will release the memory of
SignerCert for a second time with existed routine, which will cause page
fault if use-after-free guard is enabled.

The patch fix is to free Pkcs7 instance only using PKCS7_free.

Patch v1 branch: https://github.com/kuqin12/edk2/tree/buffer_double_free_v1

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>

Signed-off-by: Kun Qin <kun.q@outlook.com>

Kun Qin (1):
  CryptoPkg: BaseCryptLib: Fix buffer double free in CryptPkcs7VerifyEku

 CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c | 4 ----
 1 file changed, 4 deletions(-)

-- 
2.28.0.windows.1


             reply	other threads:[~2020-10-21  2:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21  2:32 Kun Qin [this message]
2020-10-21 13:41 ` [edk2-devel] [PATCH v1 0/1] CryptoPkg: BaseCryptLib: Fix buffer double free in CryptPkcs7VerifyEku Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR06MB31028BF719295103D1C4C73BF31C0@MWHPR06MB3102.namprd06.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox