open5gs/src
Sukchan Lee 3f0979dab2 [MME] Fixes crash in building s1ap message
Because a race condition can occur between S6A Diameter and S1AP message,
the following error handling code has been added.

1. InitialUEMessage + Attach Request + PDN Connectivity request
2. Authentication-Information-Request/Authentication-Information-Answer
3. Authentication Request/Response
4. Security-mode command/complete
5. Update-Location-Request/Update-Location-Answer
6. Detach request/accept

In the ULR/ULA process in step 6, the PDN Connectivity request is
pushed to the queue as an ESM_MESSAGE because the NAS-Type is still
an Attach Request.

See the code below in 'mme-s6a-handler.c' for where the queue is pushed.

  if (mme_ue->nas_eps.type == MME_EPS_TYPE_ATTACH_REQUEST) {
      rv = nas_eps_send_emm_to_esm(mme_ue,
              &mme_ue->pdn_connectivity_request);
      if (rv != OGS_OK) {
          ogs_error("nas_eps_send_emm_to_esm() failed");
          return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED;
      }
  } else if (mme_ue->nas_eps.type == MME_EPS_TYPE_TAU_REQUEST) {
      r = nas_eps_send_tau_accept(mme_ue,
              S1AP_ProcedureCode_id_InitialContextSetup);
      ogs_expect(r == OGS_OK);
      ogs_assert(r != OGS_ERROR);
  } else {
      ogs_error("Invalid Type[%d]", mme_ue->nas_eps.type);
      return OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED;
  }

If you perform step 7 Detach request/accept here,
the NAS-Type becomes Detach Request and the EMM state changes
to emm_state_de_registered().

Since the PDN, which is an ESM message that was previously queued,
should not be processed in de_registered, the message is ignored
through error handling below.

Otherwise, MME will crash because there is no active bearer
in the initial_context_setup_request build process.

See the code below in 's1ap-build.c' for where the crash occurs.
  ogs_list_for_each(&mme_ue->sess_list, sess) {
      ogs_list_for_each(&sess->bearer_list, bearer) {
          ...
          if (mme_ue->nas_eps.type == MME_EPS_TYPE_ATTACH_REQUEST) {
          } else if (OGS_FSM_CHECK(&bearer->sm, esm_state_inactive)) {
              ogs_warn("No active EPS bearer [%d]", bearer->ebi);
              ogs_warn("    IMSI[%s] NAS-EPS Type[%d] "
                      "ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]",
                      mme_ue->imsi_bcd, mme_ue->nas_eps.type,
                      enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
              continue;
          }
          ...
      }
  }
2024-02-02 21:17:41 +09:00
..
amf [AMF/MME] Fixed M-TMSI pool release (#2307) 2024-01-21 11:58:43 +09:00
ausf [NRF] Fixed crash due to invalid PATCH body (#2735) 2023-11-25 22:03:28 +09:00
bsf [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00
hss fix mismatch of parameters between prototype and declaration 2024-01-22 17:34:59 +09:00
mme [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
nrf [NRF] crash after sending invalid message (#2808) 2023-12-23 09:55:19 +09:00
nssf [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00
pcf memset input/output structure inside the function 2024-01-22 17:34:59 +09:00
pcrf Document Gx interface spec references 2024-01-25 07:05:33 +09:00
scp fix mismatch of parameters between prototype and declaration 2024-01-22 17:34:59 +09:00
sepp fix mismatch of parameters between prototype and declaration 2024-01-22 17:34:59 +09:00
sgwc [GTP-U] Fixed ogs_pfcp_find_gtpu_resource()(#2923) 2024-01-30 22:39:34 +09:00
sgwu [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00
smf [GTP-U] Fixed ogs_pfcp_find_gtpu_resource()(#2923) 2024-01-30 22:39:34 +09:00
udm Introduce ability for multiple SDM_Subscriptions 2024-01-21 13:16:21 +09:00
udr [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00
upf [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00
main.c Fixed dynamic-stack-buffer-overflow (#2578, #2577) 2023-09-05 21:58:05 +09:00
meson.build [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00