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