<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/10600">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ipa: don't crash on missing IPA ID GET message<br><br>ipaccess_bts_read_cb() only initializes signalling links if it has received an<br>IPA ID GET message on it, and so far happily accesses the uninitialized<br>sign_links list anyway if it hasn't.<br><br>Reproduce: simply don't send an IPA ID GET message when connecting to an IPA<br>server run by libosmo-abis, then continue to use the link --> segfault.<br><br>Fix the segfault: make sure that the e1inp_ts' type has been set, i.e. that<br>e1inp_ts_config_sign() has been called and the sign_links llist is initialized,<br>before calling e1inp_lookup_sign_link() on it.<br><br>../../../src/libosmo-abis/src/e1_input.c:511:2: runtime error: member access within null pointer of type 'struct e1inp_sign_link'<br>../../../src/libosmo-abis/src/e1_input.c:512:11: runtime error: member access within null pointer of type 'struct e1inp_sign_link'<br>ASAN:SIGSEGV<br>=================================================================<br>==5702==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000038 (pc 0x7f28a379ea34 sp 0x7ffd7d8933f0 bp 0x62e000000a98 T0)<br>    #0 0x7f28a379ea33 in e1inp_lookup_sign_link ../../../src/libosmo-abis/src/e1_input.c:512<br>    #1 0x7f28a37b97d4 in ipaccess_bts_read_cb ../../../src/libosmo-abis/src/input/ipaccess.c:778<br>    #2 0x7f28a37b0277 in ipa_client_read ../../../src/libosmo-abis/src/input/ipa.c:76<br>    #3 0x7f28a37b0277 in ipa_client_fd_cb ../../../src/libosmo-abis/src/input/ipa.c:139<br>    #4 0x7f28a2ac1a34 in osmo_fd_disp_fds ../../../src/libosmocore/src/select.c:217<br>    #5 0x7f28a2ac1a34 in osmo_select_main ../../../src/libosmocore/src/select.c:257<br>    #6 0x444ba3 in bts_main ../../../../src/osmo-bts/src/common/main.c:364<br>    #7 0x7f28a17ddb44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)<br>    #8 0x405e54 (/usr/local/bin/osmo-bts-trx+0x405e54)<br><br>Related: OS#3498<br>Change-Id: I2487ca37a0fe9aa56733f66bcad9dcf91fc11144<br>---<br>M src/input/ipaccess.c<br>1 file changed, 8 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/00/10600/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c</span><br><span>index ac61e14..cce1654 100644</span><br><span>--- a/src/input/ipaccess.c</span><br><span>+++ b/src/input/ipaccess.c</span><br><span>@@ -727,12 +727,11 @@</span><br><span>   struct ipaccess_head *hh = (struct ipaccess_head *) msg->data;</span><br><span>    struct e1inp_ts *e1i_ts = NULL;</span><br><span>      struct e1inp_sign_link *sign_link;</span><br><span style="color: hsl(120, 100%, 40%);">+    uint8_t msg_type = *(msg->l2h);</span><br><span>   int ret = 0;</span><br><span> </span><br><span>     /* special handling for IPA CCM. */</span><br><span>  if (hh->proto == IPAC_PROTO_IPACCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-              uint8_t msg_type = *(msg->l2h);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>           /* this is a request for identification from the BSC. */</span><br><span>             if (msg_type == IPAC_MSGT_ID_GET) {</span><br><span>                  if (!link->line->ops->sign_link_up) {</span><br><span>@@ -751,8 +750,6 @@</span><br><span>                 goto err;</span><br><span> </span><br><span>        if (ret == 1 && hh->proto == IPAC_PROTO_IPACCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-          uint8_t msg_type = *(msg->l2h);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>           if (msg_type == IPAC_MSGT_ID_GET) {</span><br><span>                  sign_link = link->line->ops->sign_link_up(msg,</span><br><span>                                      link->line,</span><br><span>@@ -774,6 +771,13 @@</span><br><span> </span><br><span>    OSMO_ASSERT(e1i_ts != NULL);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+      if (e1i_ts->type == E1INP_TS_TYPE_NONE) {</span><br><span style="color: hsl(120, 100%, 40%);">+          LOGP(DLINP, LOGL_ERROR, "Signalling link not initialized. Discarding."</span><br><span style="color: hsl(120, 100%, 40%);">+                   " port=%u msg_type=%u\n", link->port, msg_type);</span><br><span style="color: hsl(120, 100%, 40%);">+            ret = -EIO;</span><br><span style="color: hsl(120, 100%, 40%);">+           goto err;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     </span><br><span>     /* look up for some existing signaling link. */</span><br><span>      sign_link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0);</span><br><span>         if (sign_link == NULL) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10600">change 10600</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/10600"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-abis </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2487ca37a0fe9aa56733f66bcad9dcf91fc11144 </div>
<div style="display:none"> Gerrit-Change-Number: 10600 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>