From 5b31c1db438b655ca5ae7436a3750a2b1b248c57 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 26 Feb 2020 21:52:47 +0100 Subject: [PATCH] nas: delete security context when receiving attach reject with cause 3, 6, or 35 --- lib/include/srslte/asn1/liblte_mme.h | 1 + srsue/src/stack/upper/nas.cc | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/asn1/liblte_mme.h b/lib/include/srslte/asn1/liblte_mme.h index 6cc91871d..e5f13615b 100644 --- a/lib/include/srslte/asn1/liblte_mme.h +++ b/lib/include/srslte/asn1/liblte_mme.h @@ -692,6 +692,7 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_drx_parameter_ie(uint8** ie_ptr, LIBLTE_MME_ #define LIBLTE_MME_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED 0x18 #define LIBLTE_MME_EMM_CAUSE_NOT_AUTHORIZED_FOR_THIS_CSG 0x19 #define LIBLTE_MME_EMM_CAUSE_NON_EPS_AUTHENTICATION_UNACCEPTABLE 0x1A +#define LIBLTE_MME_EMM_CAUSE_REQUESTED_SERVICE_OPTION_NOT_AUTHORIZED 0x23 #define LIBLTE_MME_EMM_CAUSE_CS_SERVICE_TEMPORARILY_NOT_AVAILABLE 0x27 #define LIBLTE_MME_EMM_CAUSE_NO_EPS_BEARER_CONTEXT_ACTIVATED 0x28 #define LIBLTE_MME_EMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE 0x5F diff --git a/srsue/src/stack/upper/nas.cc b/srsue/src/stack/upper/nas.cc index d56b48701..7a5436c6b 100644 --- a/srsue/src/stack/upper/nas.cc +++ b/srsue/src/stack/upper/nas.cc @@ -1119,8 +1119,19 @@ void nas::parse_attach_reject(uint32_t lcid, unique_byte_buffer_t pdu) t3410.stop(); } + // 5.5.1.2.5 + if (attach_rej.emm_cause == LIBLTE_MME_EMM_CAUSE_ILLEGAL_UE || + attach_rej.emm_cause == LIBLTE_MME_EMM_CAUSE_ILLEGAL_ME || + attach_rej.emm_cause == LIBLTE_MME_EMM_CAUSE_REQUESTED_SERVICE_OPTION_NOT_AUTHORIZED) { + // delete security context + have_guti = false; + have_ctxt = false; + ctxt = {}; + } + + // TODO: handle other relevant reject causes + enter_emm_deregistered(); - // TODO: Command RRC to release? } void nas::parse_authentication_request(uint32_t lcid, unique_byte_buffer_t pdu, const uint8_t sec_hdr_type)