open5gs/src/mme
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
..
app-init.c A minor typo fix (#2707) 2023-10-28 22:11:58 +09:00
emm-build.c [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
emm-build.h [MME] Follow-up Cancel Location Handling (#1698) 2022-08-19 16:52:39 +09:00
emm-handler.c [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
emm-handler.h [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
emm-sm.c [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
esm-build.c [MME/SMF] Added Extended-PCO in 4G/LTE (#2261) 2023-04-22 00:06:50 +09:00
esm-build.h Distinguish the type of session creation 2022-04-14 17:34:55 +09:00
esm-handler.c Add trace log for debugging #2287 2023-08-07 22:13:35 +09:00
esm-handler.h [ALL] Fix differences in function parameter names between definition and declaration 2022-07-01 21:38:47 +09:00
esm-sm.c Add trace log for debugging #2287 2023-08-07 22:13:35 +09:00
meson.build mme: Introduce initial Gn iface (GTPv1C) support 2023-07-15 23:44:57 +09:00
metrics.c [AMF metrics] Initial histogram support 2023-03-24 23:03:49 +09:00
metrics.h [METRICS] Re-order init/final (#1985, #2001) 2023-01-20 21:16:45 +09:00
mme-context.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
mme-context.h [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
mme-event.c [MME] Gn: Introduce initial support for 4G->2G cell reselection 2023-12-23 09:56:55 +09:00
mme-event.h [MME] Gn: Introduce initial support for 4G->2G cell reselection 2023-12-23 09:56:55 +09:00
mme-fd-path.c MME: support for IDR EPS_USER_STATE 2024-01-13 12:00:20 +09:00
mme-fd-path.h [MME] Add Purge-UE Capability (#1991) 2023-01-14 09:13:48 +09:00
mme-gn-build.c [SMF,MME] Gn: Set Maximum SDU Size QoS field to 1500 2024-01-27 07:11:44 +09:00
mme-gn-build.h [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
mme-gn-handler.c [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
mme-gn-handler.h [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
mme-gtp-path.c [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
mme-gtp-path.h [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
mme-init.c [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00
mme-path.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
mme-path.h no Purge Timer, no config, expanded code 2023-01-24 12:35:47 -06:00
mme-s6a-handler.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
mme-s6a-handler.h [MME] Add Purge-UE Capability (#1991) 2023-01-14 09:13:48 +09:00
mme-s11-build.c [MME] Gn: Introduce initial support for 2G->4G cell reselection 2024-01-17 23:05:19 +09:00
mme-s11-build.h [ALL] Fix differences in function parameter names between definition and declaration 2022-07-01 21:38:47 +09:00
mme-s11-handler.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
mme-s11-handler.h [ALL] Fix differences in function parameter names between definition and declaration 2022-07-01 21:38:47 +09:00
mme-sm.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
mme-sm.h [CSFB] Create a state machine 2019-06-16 15:40:26 +09:00
mme-timer.c [MME] Gn: Introduce initial support for 4G->2G cell reselection 2023-12-23 09:56:55 +09:00
mme-timer.h [MME] Gn: Introduce initial support for 4G->2G cell reselection 2023-12-23 09:56:55 +09:00
nas-path.c [AMF/SMF] Fixed a crash (#2030, #2074, #2085) 2023-02-20 20:49:48 +09:00
nas-path.h [MME] Follow-up Cancel Location Handling (#1698) 2022-08-19 16:52:39 +09:00
nas-security.c Shall cipher in the NAS message container IE 2022-01-05 22:39:06 +09:00
nas-security.h Add AUSF, UDM, and UDR 2020-06-04 14:12:05 -04:00
s1ap-build.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
s1ap-build.h [MME] Implement ENBConfigurationUpdate (#2589) 2023-09-16 20:58:58 +09:00
s1ap-handler.c [MME] Fixes crash in building s1ap message 2024-02-02 21:17:41 +09:00
s1ap-handler.h [MME] Implement ENBConfigurationUpdate (#2589) 2023-09-16 20:58:58 +09:00
s1ap-path.c [MME] Fix incorrect function name printed in error line 2024-01-05 05:52:56 +09:00
s1ap-path.h [MME] Implement ENBConfigurationUpdate (#2589) 2023-09-16 20:58:58 +09:00
s1ap-sctp.c [ALL] Removing trailing whitespace and tab 2022-09-02 23:38:39 +09:00
s1ap-sm.c [MME] Implement ENBConfigurationUpdate (#2589) 2023-09-16 20:58:58 +09:00
sbc-handler.c [AMF/MME] Fixed crash when no NG/S1 context(#2012) 2023-01-23 10:37:22 +09:00
sbc-handler.h [CSFB] Fix the MacOSX 2019-07-08 21:03:39 +09:00
sbc-message.h NGSetup is added 2020-05-25 12:15:22 -04:00
sgsap-build.c [MME] SGaAP-MO-CSFB-INDICATION w/ TAI/ECGI (#2664) 2023-10-11 20:37:12 +09:00
sgsap-build.h Refact paging module (#1676) 2022-07-30 14:44:34 +09:00
sgsap-conv.c Re-factoring the all library 2019-09-13 21:07:47 +09:00
sgsap-conv.h Move src/../nf-sm.[ch] to lib/sbi/nf-sm.[ch] 2022-08-12 14:03:53 +09:00
sgsap-handler.c [AMF/MME] Remove code that doesn't work (#2013) 2023-07-23 14:54:06 +09:00
sgsap-handler.h [SGsAP] add MM-INFORMATION-REQUEST(Discard by Option2) 2019-07-21 22:52:28 +09:00
sgsap-path.c Fixed MacOSX compile error 2023-04-04 21:53:39 +09:00
sgsap-path.h [SGsAP] Changed message if Paging failed (#1701) 2022-08-19 18:58:55 +09:00
sgsap-sctp.c [ALL] Removing trailing whitespace and tab 2022-09-02 23:38:39 +09:00
sgsap-sm.c [LOG] remove ogs_expect_or_return()/return_val() 2023-01-24 00:01:36 +09:00
sgsap-types.h [MME] SGaAP-MO-CSFB-INDICATION w/ TAI/ECGI (#2664) 2023-10-11 20:37:12 +09:00