Change in osmo-sgsn[master]: Disarm T3395 when dettaching mmctx from pdpctx

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jul 16 15:22:47 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9935 )

Change subject: Disarm T3395 when dettaching mmctx from pdpctx
......................................................................

Disarm T3395 when dettaching mmctx from pdpctx

In sgsn_pdp_ctx_terminate, a pdp ctx is terminated and the mm ctx is
detached. However, T3395 may still be armed and then pdpctx_timer_cb
will trigger, and attempt to use the pdp->mm ctx which was already
detached (set to NULL) when calling
gsm48_tx_gsm_deact_pdp_req()->mmctx2msgid().

Following list of log lines shows the scenario+crash, in which osmo-sgsn
is trying to deactivate the ctx all the time but the PCU doesn't ACK it,
and then at some point the PDP context is forced released.

osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(901700000015254/d7e9ab95) <- DEACTIVATE PDP CONTEXT REQ
osmo-sgsn/src/gprs/gprs_gmm.c:1464 MM(901700000015254/d7e9ab95) -> GMM DETACH REQUEST TLLI=0xd7e9ab95 type=GPRS detach Power-off
osmo-sgsn/src/gprs/gprs_gmm.c:313 MM(901700000015254/d7e9ab95) Cleaning MM context due to GPRS DETACH REQUEST
osmo-sgsn/src/gprs/gprs_sgsn.c:332 MM(901700000015254/d7e9ab95) Dropping PDP context for NSAPI=5
osmo-sgsn/src/gprs/gprs_sgsn.c:434 PDP(901700000015254/0) Forcing release of PDP context
osmo-sgsn/src/gprs/gprs_sndcp.c:508 SNSM-DEACTIVATE.ind (lle=0x62100001bca0, TLLI=d7e9ab95, SAPI=3, NSAPI=5)
osmo-sgsn/src/gprs/sgsn_libgtp.c:310 PDP(---/0) Delete PDP Context
osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(---/ffffffff) <- DEACTIVATE PDP CONTEXT REQ
osmo-sgsn/src/gprs/gprs_gmm.c:305:25: runtime error: member access within null pointer of type 'const struct sgsn_mm_ctx'

Program received signal SIGSEGV, Segmentation fault.
0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0)
    at /home/pespin/dev/sysmocom/git/osmo-sgsn/src/gprs/gprs_gmm.c:305
305             msgb_tlli(msg) = mm->gb.tlli;
(gdb) bt
 #0  0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0)
    at osmo-sgsn/src/gprs/gprs_gmm.c:305
 #1  0x00005555556b170a in _gsm48_tx_gsm_deact_pdp_req (mm=0x0, tid=0 '\000',
    sm_cause=38 '&')
    at osmo-sgsn/src/gprs/gprs_gmm.c:2297
 #2  0x00005555556b1a2e in gsm48_tx_gsm_deact_pdp_req (pdp=0x6140000008a0,
    sm_cause=38 '&')
    at osmo-sgsn/src/gprs/gprs_gmm.c:2311
 #3  0x00005555556b876c in pdpctx_timer_cb (_pdp=0x6140000008a0)
    at osmo-sgsn/src/gprs/gprs_gmm.c:2717
 #4  0x00007ffff355eb3e in osmo_timers_update ()
    at libosmocore/src/timer.c:257
 #5  0x00007ffff356255c in osmo_select_main (polling=0)
    at libosmocore/src/select.c:254
 #6  0x00005555556f17cb in main (argc=3, argv=0x7fffffffe298)
    at osmo-sgsn/src/gprs/sgsn_main.c:531

Change-Id: I2120e53ade6cabad37f9bd99e6680a453411821b
---
M include/osmocom/sgsn/gprs_gmm.h
M src/gprs/gprs_gmm.c
M src/gprs/gprs_sgsn.c
3 files changed, 13 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h
index 3c93efc..28c96ce 100644
--- a/include/osmocom/sgsn/gprs_gmm.h
+++ b/include/osmocom/sgsn/gprs_gmm.h
@@ -43,4 +43,6 @@
 /* TODO: move extract_subscr_* when gsm48_gmm_authorize() got removed */
 void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx);
 void extract_subscr_hlr(struct sgsn_mm_ctx *ctx);
+
+void pdp_ctx_detach_mm_ctx(struct sgsn_pdp_ctx *pdp);
 #endif /* _GPRS_GMM_H */
diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index 6a5c5d9..9d8a869 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -2192,6 +2192,16 @@
 	osmo_timer_del(&pdp->timer);
 }
 
+void pdp_ctx_detach_mm_ctx(struct sgsn_pdp_ctx *pdp)
+{
+	/* Detach from MM context */
+	llist_del(&pdp->list);
+	pdp->mm = NULL;
+
+	/* stop timer 3395 */
+	pdpctx_timer_stop(pdp, 3395);
+}
+
 #if 0
 static void msgb_put_pdp_addr_ipv4(struct msgb *msg, uint32_t ipaddr)
 {
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index 55ce096..ab5e79a 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -443,9 +443,7 @@
 	osmo_signal_dispatch(SS_SGSN, S_SGSN_PDP_TERMINATE, &sig_data);
 
 	/* Detach from MM context */
-	llist_del(&pdp->list);
-	pdp->mm = NULL;
-
+	pdp_ctx_detach_mm_ctx(pdp);
 	sgsn_delete_pdp_ctx(pdp);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/9935
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2120e53ade6cabad37f9bd99e6680a453411821b
Gerrit-Change-Number: 9935
Gerrit-PatchSet: 3
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180716/679ff821/attachment.htm>


More information about the gerrit-log mailing list