Find a file
Sukchan Lee dd7c518a56 amf: snapshot RAN-UE ID in SBI transaction to avoid race during SM Context Update
Several users reported intermittent AMF crashes when SM Context Update
procedures overlap with NG context release or a new Registration
procedure. In these situations the RAN-UE associated with a session may
change before the asynchronous SBI response arrives.

Typical trigger scenarios include:

  * UEContextReleaseRequest followed by a new Registration Request
  * PDU Session Update overlapping with UE deactivation or handover
  * Registration Request arriving while a previous Service Request is
    still being processed

In these cases the AMF may send an Update SM Context request to the SMF
while the NG context is being released or replaced. When the asynchronous
SBI response arrives later, the AMF uses the session's current ran_ue
pointer. However, that pointer may already have been switched to a new
RAN-UE or cleared due to the release procedure.

As a result, the AMF may reference the wrong RAN-UE context or an
inconsistent state, eventually triggering an assertion such as:

  amf_nsmf_pdusession_handle_update_sm_context:
      Assertion `ran_ue->deactivation.group' failed

The root cause is that SBI client transactions do not preserve the
RAN-UE association at the time the request was sent. Because SBI
operations are asynchronous, the session context may change before the
response is processed.

This patch introduces a generic mechanism to attach user-defined context
to an SBI transaction:

  - Add `user_data` and `user_data_free` to `ogs_sbi_xact_t`
  - Allow NF-specific code to store per-transaction context
  - Ensure the memory is released automatically when the transaction
    is removed

The AMF now stores a snapshot of the RAN-UE ID in the SBI transaction
when sending an Update SM Context request. When the SBI response is
processed, the AMF retrieves the RAN-UE using this snapshot instead of
the session's current ran_ue pointer. This guarantees that the response
is associated with the correct RAN context even if the session state has
changed in the meantime.

This approach avoids race conditions between asynchronous SBI responses
and NG context lifecycle events, preventing the AMF from accessing an
incorrect or partially released RAN-UE context.

Reported-by:
  multiple users on v2.7.6 environments

Issues: #4174, #4274
2026-03-05 22:30:31 +09:00
.github Update cifuzz 2025-02-04 21:09:20 +09:00
configs [HR] Implement handling of UE-initiated PDU Session Modification (#2194) 2025-06-30 10:07:06 +09:00
debian Release v2.7.6 2025-07-19 10:32:41 +09:00
docker docker: remove deprecated version from docker-compose.yml 2026-02-08 11:55:34 +09:00
docs Add Baicells Aurora 243 to hardware list 2026-02-01 06:54:46 +09:00
lib amf: snapshot RAN-UE ID in SBI transaction to avoid race during SM Context Update 2026-03-05 22:30:31 +09:00
misc Add roaming type toggle via command line (#4211) 2025-12-23 13:53:53 +09:00
src amf: snapshot RAN-UE ID in SBI transaction to avoid race during SM Context Update 2026-03-05 22:30:31 +09:00
subprojects Tested on FreeBSD-14.1-STABLE (#3350) 2024-08-03 21:45:52 +09:00
tests upf: Implement UE-to-UE hairpin in the GTP-U path 2026-02-26 06:07:35 +09:00
vagrant Tested on FreeBSD-14.1-STABLE (#3350) 2024-08-03 21:45:52 +09:00
webui Update to secure secrets using env 2026-01-17 10:45:03 +09:00
.clang-tidy [MISC] Add support for static code analysis 2022-07-01 21:38:47 +09:00
.dockerignore [build] Use local sources to build applications (#1583) 2022-06-19 18:18:09 +09:00
.editorconfig editorconfig: new file (#2746) 2023-11-27 22:21:35 +09:00
.gitignore .gitignore: Add install/ dir 2023-10-10 08:03:25 +09:00
LICENSE Change LICENSE to GNU AGPL v3.0 2017-12-18 10:35:54 +09:00
meson.build Release v2.7.6 2025-07-19 10:32:41 +09:00
meson_options.txt [Fuzzing] oss-fuzz support for fuzzing (#2283) 2023-05-05 17:20:11 +09:00
README.md nrf: Fix serving PLMN counter reset on NF register 2026-02-04 20:51:29 +09:00

Open5GS logo

Getting Started

Please follow the documentation at open5gs.org!

Sponsors

If you find Open5GS useful for work, please consider supporting this Open Source project by Becoming a sponsor. To manage the funding transactions transparently, you can donate through OpenCollective.

sponsors

Community

  • Problem with Open5GS can be filed as issues in this repository.
  • Other topics related to this project are happening on the discussions.
  • Voice and text chat are available in Open5GS's Discord workspace. Use this link to get started.

Contributing

If you're contributing through a pull request to Open5GS project on GitHub, please read the Contributor License Agreement in advance.

License

Support

Technical support and customized services for Open5GS are provided by NewPlane at support@newplane.io.