]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/IpSecDxe: Fix issue to parse SA Payload.
authorJiaxin Wu <Jiaxin.wu@intel.com>
Fri, 12 Oct 2018 08:00:57 +0000 (16:00 +0800)
committerJiaxin Wu <Jiaxin.wu@intel.com>
Mon, 22 Oct 2018 01:04:57 +0000 (09:04 +0800)
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1251

*v2: Correct the type of parameters in Ikev2ParseProposalData(), and refined
the corresponding description.

IpSecDxe failed to create the Child SA during parsing SA Payload, the issue
was caused by the below commit:

SHA-1: 1e0db7b11987d0ec93be7dfe26102a327860fdbd
* MdeModulePkg/NetworkPkg: Checking for NULL pointer before use.

In above commit, it changed the value of IsMatch in Ikev2ChildSaParseSaPayload()
to FALSE. That's correct but it exposed the potential bug in to match the correct
proposal Data, which will cause the issue happen.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
NetworkPkg/IpSecDxe/Ikev2/Utility.c

index 0c9c9297057d3573e069f1d6f578575022579a9e..162bbb27ee3817434a120e744acd11dec7cde35a 100644 (file)
@@ -1995,28 +1995,45 @@ Ikev2IsSupportAlg (
 /**\r
   Get the preferred algorithm types from ProposalData.\r
 \r
-  @param[in]  ProposalData              Pointer to related IKEV2_PROPOSAL_DATA.\r
-  @param[out] PreferEncryptAlgorithm    Output of preferred encrypt algorithm.\r
-  @param[out] PreferIntegrityAlgorithm  Output of preferred integrity algorithm.\r
-  @param[out] PreferPrfAlgorithm        Output of preferred PRF algorithm. Only\r
-                                        for IKE SA.\r
-  @param[out] PreferDhGroup             Output of preferred DH group. Only for\r
-                                        IKE SA.\r
-  @param[out] PreferEncryptKeylength    Output of preferred encrypt key length\r
-                                        in bytes.\r
-  @param[out] IsSupportEsn              Output of value about the Extented Sequence\r
-                                        Number is support or not. Only for Child SA.\r
-  @param[in]  IsChildSa                 If it is ture, the ProposalData is for IKE\r
-                                        SA. Otherwise the proposalData is for Child SA.\r
+  @param[in]      ProposalData              Pointer to related IKEV2_PROPOSAL_DATA.\r
+  @param[in, out] PreferEncryptAlgorithm    Pointer to buffer which is used to store the\r
+                                            preferred encrypt algorithm.\r
+                                            Input value shall be initialized to zero that\r
+                                            indicates to be parsed from ProposalData.\r
+                                            Output of preferred encrypt algorithm.\r
+  @param[in, out] PreferIntegrityAlgorithm  Pointer to buffer which is used to store the\r
+                                            preferred integrity algorithm.\r
+                                            Input value shall be initialized to zero that\r
+                                            indicates to be parsed from ProposalData.\r
+                                            Output of preferred integrity algorithm.\r
+  @param[in, out] PreferPrfAlgorithm        Pointer to buffer which is used to store the\r
+                                            preferred PRF algorithm.\r
+                                            Input value shall be initialized to zero that\r
+                                            indicates to be parsed from ProposalData.\r
+                                            Output of preferred PRF algorithm. Only\r
+                                            for IKE SA.\r
+  @param[in, out] PreferDhGroup             Pointer to buffer which is used to store the\r
+                                            preferred DH group.\r
+                                            Input value shall be initialized to zero that\r
+                                            indicates to be parsed from ProposalData.\r
+                                            Output of preferred DH group. Only for\r
+                                            IKE SA.\r
+  @param[out]     PreferEncryptKeylength    Pointer to buffer which is used to store the\r
+                                            preferred encrypt key length in bytes.\r
+  @param[out]     IsSupportEsn              Pointer to buffer which is used to store the\r
+                                            value about the Extented Sequence Number is\r
+                                            support or not. Only for Child SA.\r
+  @param[in]      IsChildSa                 If it is ture, the ProposalData is for IKE\r
+                                            SA. Otherwise the proposalData is for Child SA.\r
 \r
 **/\r
 VOID\r
 Ikev2ParseProposalData (\r
   IN     IKEV2_PROPOSAL_DATA  *ProposalData,\r
-     OUT UINT16               *PreferEncryptAlgorithm,\r
-     OUT UINT16               *PreferIntegrityAlgorithm,\r
-     OUT UINT16               *PreferPrfAlgorithm,\r
-     OUT UINT16               *PreferDhGroup,\r
+  IN OUT UINT16               *PreferEncryptAlgorithm,\r
+  IN OUT UINT16               *PreferIntegrityAlgorithm,\r
+  IN OUT UINT16               *PreferPrfAlgorithm,\r
+  IN OUT UINT16               *PreferDhGroup,\r
      OUT UINTN                *PreferEncryptKeylength,\r
      OUT BOOLEAN              *IsSupportEsn,\r
   IN     BOOLEAN              IsChildSa\r
@@ -2504,11 +2521,12 @@ Ikev2ChildSaParseSaPayload (
           ) {\r
         IsMatch = TRUE;\r
       } else {\r
-        PreferEncryptAlgorithm   = 0;\r
-        PreferIntegrityAlgorithm = 0;\r
-        IsSupportEsn             = TRUE;\r
+        IntegrityAlgorithm = 0;\r
+        EncryptAlgorithm   = 0;\r
+        EncryptKeylength   = 0;\r
+        IsSupportEsn       = FALSE;\r
       }\r
-       ProposalData = (IKEV2_PROPOSAL_DATA*)((UINT8*)(ProposalData + 1) +\r
+      ProposalData = (IKEV2_PROPOSAL_DATA*)((UINT8*)(ProposalData + 1) +\r
                      ProposalData->NumTransforms * sizeof (IKEV2_TRANSFORM_DATA));\r
     }\r
 \r