public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Peter Jones <pjones@redhat.com>
To: edk2-devel@ml01.01.org
Cc: Peter Jones <pjones@redhat.com>
Subject: [PATCH] Pkcs7VerifyDxe: Don't allow Pkcs7Verify to install protocols twice.
Date: Thu, 29 Sep 2016 14:45:34 -0400	[thread overview]
Message-ID: <20160929184534.13871-1-pjones@redhat.com> (raw)
In-Reply-To: <E92EE9817A31E24EB0585FDF735412F56481DCC7@ORSMSX113.amr.corp.intel.com>

This patch makes Pkcs7VerifyDxe check that it has not already been
installed before installing its protocols.  This prevents the case where
loading it as an external driver (either manually, through Driver####
variables, etc.) will refuse to add a second provider of the API.

v2 - return EFI_ABORTED as per Michael Kinney's feedback.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Peter Jones <pjones@redhat.com>
---
 SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c b/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c
index 07fdf55..e5ec1b4 100644
--- a/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c
+++ b/SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.c
@@ -1030,8 +1030,17 @@ Pkcs7VerifyDriverEntry (
   IN EFI_SYSTEM_TABLE    *SystemTable
   )
 {
-  EFI_STATUS    Status;
-  EFI_HANDLE    Handle;
+  EFI_STATUS                Status;
+  EFI_HANDLE                Handle;
+  EFI_PKCS7_VERIFY_PROTOCOL Useless;
+
+  //
+  // Avoid loading a second copy if this is built as an external module.
+  //
+  Status = gBS->LocateProtocol (&gEfiPkcs7VerifyProtocolGuid, NULL, (VOID **) &Useless);
+  if (!EFI_ERROR (Status)) {
+    return EFI_ABORTED;
+  }
 
   //
   // Install UEFI Pkcs7 Verification Protocol
-- 
2.10.0



  parent reply	other threads:[~2016-09-29 18:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 15:59 [PATCH] Pkcs7VerifyDxe: Don't allow Pkcs7Verify to install protocols twice Peter Jones
2016-09-29 16:33 ` Kinney, Michael D
2016-09-29 17:45   ` Peter Jones
2016-09-29 18:38     ` Kinney, Michael D
2016-09-29 18:39       ` Peter Jones
2016-09-29 18:45       ` Peter Jones [this message]
2016-09-29 18:48         ` Kinney, Michael D
2016-09-30  1:06           ` Long, Qin

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=20160929184534.13871-1-pjones@redhat.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