IKE Initial Exchange message should cover below process:
           Initiator                    Responder
Message1 HDR,SAil,KEi,Ni  ------>
Message2                  <------   HDR,SArl,KEr,Nr,[CERTREQ]
Message3 HDR,SK{}         ------>
Message4                  <------   HDR,SK{}

If Initial Exchange message is initiated by Linux IKE, it works well.
But the failure will happen if it's initiated by UEFI IKE. This issue
is caused by the no status check of NotifyCookiePayload.

If the IKE_SA_INIT doesn't contain COOKIE Notify payload,
EFI_INVALID_PARAMETER will be returned from
Ikev2ParserNotifyCookiePayload(). Then the session will be broken.

Cc: Ye Ting <ting...@intel.com>
Cc: Fu Siyuan <siyuan...@intel.com>
Cc: Zhang Lubo <lubo.zh...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
---
 NetworkPkg/IpSecDxe/Ikev2/Sa.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/Ikev2/Sa.c b/NetworkPkg/IpSecDxe/Ikev2/Sa.c
index 4cbfac3..f9421ed 100644
--- a/NetworkPkg/IpSecDxe/Ikev2/Sa.c
+++ b/NetworkPkg/IpSecDxe/Ikev2/Sa.c
@@ -285,13 +285,12 @@ Ikev2InitPskParser (
   // payload with the cookie data, initiator MUST retry the IKE_SA_INIT with a
   // Notify payload of type COOKIE containing the responder suppplied cookie 
data
   // as first payload and all other payloads unchanged.
   //
   if (IkeSaSession->SessionCommon.IsInitiator) {
-    if (NotifyPayload != NULL) {
-      Status = Ikev2ParserNotifyCookiePayload (NotifyPayload, IkeSaSession);
-      return Status;
+    if (NotifyPayload != NULL && !EFI_ERROR(Ikev2ParserNotifyCookiePayload 
(NotifyPayload, IkeSaSession))) {
+      return EFI_SUCCESS;
     }
   }
 
   if ((KeyPayload == NULL) || (SaPayload == NULL) || (NoncePayload == NULL)) {
     return EFI_INVALID_PARAMETER;
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to