public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch v2] NetworkPkg: UefiPxeBcDxe: Add EXCLUSIVE attribute when opening SNP protocol installed by PXE.
@ 2018-09-14  8:24 Wang Fan
  2018-09-14  8:50 ` Subramanian, Sriram
  0 siblings, 1 reply; 7+ messages in thread
From: Wang Fan @ 2018-09-14  8:24 UTC (permalink / raw)
  To: edk2-devel; +Cc: Subramanian, Sriram, Ye Ting, Fu Siyuan, Wu Jiaxin

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1152

v2: Sync the same logic to Ipv6 and update code comments.

The PXE driver installs a SNP and open this SNP with attribute BY_DRIVER
to avoid it being opened by MNP driver, this SNP is also expected not to
be opened by other drivers with EXCLUSIVE attribute. In some cases, other
drivers may happen to do this by error, and thus cause a system crash.
This patch adds EXCLUSIVE attribute when opening SNP in PXE driver, and
will reject all OpenProtocol requests by EXCLUSIVE.

Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wang Fan <fan.wang@intel.com>
---
 NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
index bc9dc914f3..0ab640beca 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -812,20 +812,20 @@ PxeBcCreateIp4Children (
     if (EFI_ERROR (Status)) {
       goto ON_ERROR;
     }
 
     //
-    // Open SNP on the child handle BY_DRIVER. It will prevent any additionally
+    // Open SNP on the child handle BY_DRIVER|EXCLUSIVE. It will prevent any additionally
     // layering to perform the experiment.
     //
     Status = gBS->OpenProtocol (
                     Private->Ip4Nic->Controller,
                     &gEfiSimpleNetworkProtocolGuid,
                     (VOID **) &Snp,
                     This->DriverBindingHandle,
                     Private->Ip4Nic->Controller,
-                    EFI_OPEN_PROTOCOL_BY_DRIVER
+                    EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
                     );
     if (EFI_ERROR (Status)) {
       goto ON_ERROR;
     }
   }
@@ -1155,20 +1155,20 @@ PxeBcCreateIp6Children (
     if (EFI_ERROR (Status)) {
       goto ON_ERROR;
     }
 
     //
-    // Open SNP on the child handle BY_DRIVER. It will prevent any additionally
+    // Open SNP on the child handle BY_DRIVER|EXCLUSIVE. It will prevent any additionally
     // layering to perform the experiment.
     //
     Status = gBS->OpenProtocol (
                     Private->Ip6Nic->Controller,
                     &gEfiSimpleNetworkProtocolGuid,
                     (VOID **) &Snp,
                     This->DriverBindingHandle,
                     Private->Ip6Nic->Controller,
-                    EFI_OPEN_PROTOCOL_BY_DRIVER
+                    EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE
                     );
     if (EFI_ERROR (Status)) {
       goto ON_ERROR;
     }
   }
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-19 11:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-14  8:24 [Patch v2] NetworkPkg: UefiPxeBcDxe: Add EXCLUSIVE attribute when opening SNP protocol installed by PXE Wang Fan
2018-09-14  8:50 ` Subramanian, Sriram
2018-09-18 10:17   ` Laszlo Ersek
2018-09-19  1:31     ` Wu, Jiaxin
2018-09-19  1:44       ` Wu, Jiaxin
2018-09-19  1:46         ` Wang, Fan
2018-09-19 11:19       ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox