Blame 0023-NetworkPkg-UefiPxeBcDxe-Add-EXCLUSIVE-attribute-when.patch

Paolo Bonzini ec71ad
From cde5a72d365eff5b02b8330fef1c8d36fced08eb Mon Sep 17 00:00:00 2001
Paolo Bonzini ec71ad
From: "edk2-devel-bounces@lists.01.org" <edk2-devel-bounces@lists.01.org>
Paolo Bonzini ec71ad
Date: Fri, 14 Sep 2018 16:24:15 +0800
Paolo Bonzini ec71ad
Subject: [PATCH] NetworkPkg: UefiPxeBcDxe: Add EXCLUSIVE attribute when
Paolo Bonzini ec71ad
 opening SNP protocol installed by PXE.
Paolo Bonzini ec71ad
Paolo Bonzini ec71ad
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1152
Paolo Bonzini ec71ad
Paolo Bonzini ec71ad
v2: Sync the same logic to Ipv6 and update code comments.
Paolo Bonzini ec71ad
Paolo Bonzini ec71ad
The PXE driver installs a SNP and open this SNP with attribute BY_DRIVER
Paolo Bonzini ec71ad
to avoid it being opened by MNP driver, this SNP is also expected not to
Paolo Bonzini ec71ad
be opened by other drivers with EXCLUSIVE attribute. In some cases, other
Paolo Bonzini ec71ad
drivers may happen to do this by error, and thus cause a system crash.
Paolo Bonzini ec71ad
This patch adds EXCLUSIVE attribute when opening SNP in PXE driver, and
Paolo Bonzini ec71ad
will reject all OpenProtocol requests by EXCLUSIVE.
Paolo Bonzini ec71ad
Paolo Bonzini ec71ad
Cc: Subramanian, Sriram <sriram-s@hpe.com>
Paolo Bonzini ec71ad
Cc: Ye Ting <ting.ye@intel.com>
Paolo Bonzini ec71ad
Cc: Fu Siyuan <siyuan.fu@intel.com>
Paolo Bonzini ec71ad
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Paolo Bonzini ec71ad
Contributed-under: TianoCore Contribution Agreement 1.1
Paolo Bonzini ec71ad
Signed-off-by: Wang Fan <fan.wang@intel.com>
Paolo Bonzini ec71ad
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Paolo Bonzini ec71ad
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Paolo Bonzini ec71ad
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Paolo Bonzini ec71ad
---
Paolo Bonzini ec71ad
 NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 8 ++++----
Paolo Bonzini ec71ad
 1 file changed, 4 insertions(+), 4 deletions(-)
Paolo Bonzini ec71ad
Paolo Bonzini ec71ad
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
Paolo Bonzini ec71ad
index bc9dc914f3..0ab640beca 100644
Paolo Bonzini ec71ad
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
Paolo Bonzini ec71ad
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
Paolo Bonzini ec71ad
@@ -814,7 +814,7 @@ PxeBcCreateIp4Children (
Paolo Bonzini ec71ad
     }
Paolo Bonzini ec71ad
 
Paolo Bonzini ec71ad
     //
Paolo Bonzini ec71ad
-    // Open SNP on the child handle BY_DRIVER. It will prevent any additionally
Paolo Bonzini ec71ad
+    // Open SNP on the child handle BY_DRIVER|EXCLUSIVE. It will prevent any additionally
Paolo Bonzini ec71ad
     // layering to perform the experiment.
Paolo Bonzini ec71ad
     //
Paolo Bonzini ec71ad
     Status = gBS->OpenProtocol (
Paolo Bonzini ec71ad
@@ -823,7 +823,7 @@ PxeBcCreateIp4Children (
Paolo Bonzini ec71ad
                     (VOID **) &Snp,
Paolo Bonzini ec71ad
                     This->DriverBindingHandle,
Paolo Bonzini ec71ad
                     Private->Ip4Nic->Controller,
Paolo Bonzini ec71ad
-                    EFI_OPEN_PROTOCOL_BY_DRIVER
Paolo Bonzini ec71ad
+                    EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
Paolo Bonzini ec71ad
                     );
Paolo Bonzini ec71ad
     if (EFI_ERROR (Status)) {
Paolo Bonzini ec71ad
       goto ON_ERROR;
Paolo Bonzini ec71ad
@@ -1157,7 +1157,7 @@ PxeBcCreateIp6Children (
Paolo Bonzini ec71ad
     }
Paolo Bonzini ec71ad
 
Paolo Bonzini ec71ad
     //
Paolo Bonzini ec71ad
-    // Open SNP on the child handle BY_DRIVER. It will prevent any additionally
Paolo Bonzini ec71ad
+    // Open SNP on the child handle BY_DRIVER|EXCLUSIVE. It will prevent any additionally
Paolo Bonzini ec71ad
     // layering to perform the experiment.
Paolo Bonzini ec71ad
     //
Paolo Bonzini ec71ad
     Status = gBS->OpenProtocol (
Paolo Bonzini ec71ad
@@ -1166,7 +1166,7 @@ PxeBcCreateIp6Children (
Paolo Bonzini ec71ad
                     (VOID **) &Snp,
Paolo Bonzini ec71ad
                     This->DriverBindingHandle,
Paolo Bonzini ec71ad
                     Private->Ip6Nic->Controller,
Paolo Bonzini ec71ad
-                    EFI_OPEN_PROTOCOL_BY_DRIVER
Paolo Bonzini ec71ad
+                    EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
Paolo Bonzini ec71ad
                     );
Paolo Bonzini ec71ad
     if (EFI_ERROR (Status)) {
Paolo Bonzini ec71ad
       goto ON_ERROR;
Paolo Bonzini ec71ad
-- 
Paolo Bonzini ec71ad
2.17.1
Paolo Bonzini ec71ad