From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B335A21962301 for ; Fri, 14 Sep 2018 01:24:24 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Sep 2018 01:24:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,372,1531810800"; d="scan'208";a="70789337" Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.29]) by fmsmga008.fm.intel.com with ESMTP; 14 Sep 2018 01:24:22 -0700 From: Wang Fan To: edk2-devel@lists.01.org Cc: Subramanian, Sriram , Ye Ting , Fu Siyuan , Wu Jiaxin Date: Fri, 14 Sep 2018 16:24:15 +0800 Message-Id: <20180914082415.800-1-fan.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [Patch v2] NetworkPkg: UefiPxeBcDxe: Add EXCLUSIVE attribute when opening SNP protocol installed by PXE. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Sep 2018 08:24:24 -0000 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 Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wang Fan --- 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