<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12450">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vlr: auth_fsm: make sure vsub->auth_fsm = NULL when it terminates<br><br>A patch not yet merged to master uncovered a cleanup bug: if the vlr_auth_fsm<br>terminates in error, the vlr_subscr->auth_fsm may not be reset to NULL even<br>though the FSM instance has been deallocated. Fix by a .cleanup callback.<br><br>The patch uncovering the bug is 1fbf45c291f7e1f09ef2e862abfeca6a23efdc03,<br>'enrich context for vlr_subscr_name and ran_conn fi name', which sets auth_fsm<br>context, on a non-NULL auth_fsm that has been deallocated.<br><br>The error looks like:<br><br>    at ../../../../src/osmo-msc/src/libvlr/vlr_lu_fsm.c:957<br>    file=file@entry=0x5611d8f10c28 "../../../../src/osmo-msc/src/libvlr/vlr_lu_fsm.c", line=line@entry=1467)<br>    at ../../../src/libosmocore/src/fsm.c:580<br>    parent_event_failure=parent_event_failure@entry=6, parent_event_data=parent_event_data@entry=0x0, vlr=0x5611d98862b0,<br>    msc_conn_ref=msc_conn_ref@entry=0x5611d9aa8150, type=VLR_LU_TYPE_REGULAR, tmsi=4294967295, imsi=0x7ffd756c1cf0 "262423403004874",<br>    old_lai=0x7ffd756c1ce0, new_lai=0x7ffd756c1ce8, authentication_required=true, ciphering_required=true, is_r99=false, is_utran=false,<br>    assign_tmsi=true) at ../../../../src/osmo-msc/src/libvlr/vlr_lu_fsm.c:1467<br>    at ../../../../src/osmo-msc/src/libmsc/gsm_04_08.c:443<br><br>Unfortunately I am not sure whether we have saved logging leading up to this<br>error.<br><br>Change-Id: I3c528eed295be2ee673ea295804372f388a0dccd<br>---<br>M src/libvlr/vlr_auth_fsm.c<br>1 file changed, 7 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/50/12450/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libvlr/vlr_auth_fsm.c b/src/libvlr/vlr_auth_fsm.c</span><br><span>index 8419696..ccf3660 100644</span><br><span>--- a/src/libvlr/vlr_auth_fsm.c</span><br><span>+++ b/src/libvlr/vlr_auth_fsm.c</span><br><span>@@ -240,9 +240,6 @@</span><br><span> /* Terminate the Auth FSM Instance and notify parent */</span><br><span> static void auth_fsm_term(struct osmo_fsm_inst *fi, enum gsm48_reject_value result)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct auth_fsm_priv *afp = fi->priv;</span><br><span style="color: hsl(0, 100%, 40%);">-        struct vlr_subscr *vsub = afp->vsub;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>      LOGPFSM(fi, "Authentication terminating with result %s\n",</span><br><span>                 vlr_auth_fsm_result_name(result));</span><br><span> </span><br><span>@@ -254,6 +251,12 @@</span><br><span> </span><br><span>    /* return the result to the parent FSM */</span><br><span>    osmo_fsm_inst_term(fi, OSMO_FSM_TERM_REGULAR, &result);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void auth_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct auth_fsm_priv *afp = fi->priv;</span><br><span style="color: hsl(120, 100%, 40%);">+      struct vlr_subscr *vsub = afp->vsub;</span><br><span>      vsub->auth_fsm = NULL;</span><br><span> }</span><br><span> </span><br><span>@@ -583,6 +586,7 @@</span><br><span>     .allstate_action = NULL,</span><br><span>     .log_subsys = DVLR,</span><br><span>  .event_names = fsm_auth_event_names,</span><br><span style="color: hsl(120, 100%, 40%);">+  .cleanup = auth_fsm_cleanup,</span><br><span> };</span><br><span> </span><br><span> /***********************************************************************</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12450">change 12450</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12450"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-msc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I3c528eed295be2ee673ea295804372f388a0dccd </div>
<div style="display:none"> Gerrit-Change-Number: 12450 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>