aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-08-24 17:43:45 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-08-24 17:50:22 +0200
commitfe6731181c7db6455490c62b3e3f3f051fbdb09f (patch)
tree4498ff4c79afbe28fdb9e5af59de2624125bbe12
parent67902bbeb973b9da8a390bb5aacb3dba7ece1e15 (diff)
ipa: don't crash on missing IPA ID GET message
ipaccess_bts_read_cb() only initializes signalling links if it has received an IPA ID GET message on it, and so far happily accesses the uninitialized sign_links list anyway if it hasn't. Reproduce: simply don't send an IPA ID GET message when connecting to an IPA server run by libosmo-abis, then continue to use the link --> segfault. Fix the segfault: make sure that the e1inp_ts' type has been set, i.e. that e1inp_ts_config_sign() has been called and the sign_links llist is initialized, before calling e1inp_lookup_sign_link() on it. ../../../src/libosmo-abis/src/e1_input.c:511:2: runtime error: member access within null pointer of type 'struct e1inp_sign_link' ../../../src/libosmo-abis/src/e1_input.c:512:11: runtime error: member access within null pointer of type 'struct e1inp_sign_link' ASAN:SIGSEGV ================================================================= ==5702==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000038 (pc 0x7f28a379ea34 sp 0x7ffd7d8933f0 bp 0x62e000000a98 T0) #0 0x7f28a379ea33 in e1inp_lookup_sign_link ../../../src/libosmo-abis/src/e1_input.c:512 #1 0x7f28a37b97d4 in ipaccess_bts_read_cb ../../../src/libosmo-abis/src/input/ipaccess.c:778 #2 0x7f28a37b0277 in ipa_client_read ../../../src/libosmo-abis/src/input/ipa.c:76 #3 0x7f28a37b0277 in ipa_client_fd_cb ../../../src/libosmo-abis/src/input/ipa.c:139 #4 0x7f28a2ac1a34 in osmo_fd_disp_fds ../../../src/libosmocore/src/select.c:217 #5 0x7f28a2ac1a34 in osmo_select_main ../../../src/libosmocore/src/select.c:257 #6 0x444ba3 in bts_main ../../../../src/osmo-bts/src/common/main.c:364 #7 0x7f28a17ddb44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44) #8 0x405e54 (/usr/local/bin/osmo-bts-trx+0x405e54) Related: OS#3498 Change-Id: I2487ca37a0fe9aa56733f66bcad9dcf91fc11144
-rw-r--r--src/input/ipaccess.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index ac61e14..cce1654 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -727,12 +727,11 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
struct ipaccess_head *hh = (struct ipaccess_head *) msg->data;
struct e1inp_ts *e1i_ts = NULL;
struct e1inp_sign_link *sign_link;
+ uint8_t msg_type = *(msg->l2h);
int ret = 0;
/* special handling for IPA CCM. */
if (hh->proto == IPAC_PROTO_IPACCESS) {
- uint8_t msg_type = *(msg->l2h);
-
/* this is a request for identification from the BSC. */
if (msg_type == IPAC_MSGT_ID_GET) {
if (!link->line->ops->sign_link_up) {
@@ -751,8 +750,6 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
goto err;
if (ret == 1 && hh->proto == IPAC_PROTO_IPACCESS) {
- uint8_t msg_type = *(msg->l2h);
-
if (msg_type == IPAC_MSGT_ID_GET) {
sign_link = link->line->ops->sign_link_up(msg,
link->line,
@@ -774,6 +771,13 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
OSMO_ASSERT(e1i_ts != NULL);
+ if (e1i_ts->type == E1INP_TS_TYPE_NONE) {
+ LOGP(DLINP, LOGL_ERROR, "Signalling link not initialized. Discarding."
+ " port=%u msg_type=%u\n", link->port, msg_type);
+ ret = -EIO;
+ goto err;
+ }
+
/* look up for some existing signaling link. */
sign_link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0);
if (sign_link == NULL) {