aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-08-22 12:21:47 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-08-22 12:25:44 +0200
commit889e0169a7a9942bbabdc7eb544395d6700a22c2 (patch)
tree21b8dd43aa36554056c2279d54199bfedb3e216a
parentc649c3fe8e3e8b1c2d04f75563be0f1837607f5c (diff)
abis_nm: Fix heap-use-after-free in abis_nm_set_channel_attr
LOGPFOH uses the msgb through "foh", so we have to free msgb after calling it, not before. Fixes following ASAN report: 20180822120155990 DNM <0004> abis_nm.c:1889 OC=CHANNEL(03) INST=(00,01,06): Set Chan Attr (bts=0,trx=1,ts=6) ================================================================= ==16465==ERROR: AddressSanitizer: heap-use-after-free on address 0x61a00002b3f0 at pc 0x7f587f44c0db bp 0x7ffc59e31df0 sp 0x7ffc59e31de8 READ of size 1 at 0x61a00002b3f0 thread T0 #0 0x7f587f44c0da in abis_nm_dump_foh libosmocore/src/gsm/abis_nm.c:937 #1 0x561e09e1532c in abis_nm_set_channel_attr osmo-bsc/src/osmo-bsc/abis_nm.c:1892 #2 0x561e09efd269 in nm_statechg_event osmo-bsc/src/osmo-bsc/bts_ipaccess_nanobts.c:168 #3 0x561e09efd269 in bts_ipa_nm_sig_cb osmo-bsc/src/osmo-bsc/bts_ipaccess_nanobts.c:335 #4 0x7f587efb3d16 in osmo_signal_dispatch libosmocore/src/signal.c:120 #5 0x561e09e18e31 in abis_nm_rx_statechg_rep osmo-bsc/src/osmo-bsc/abis_nm.c:255 #6 0x561e09e18e31 in abis_nm_rcvmsg_report osmo-bsc/src/osmo-bsc/abis_nm.c:380 #7 0x561e09e18e31 in abis_nm_rcvmsg_fom osmo-bsc/src/osmo-bsc/abis_nm.c:778 #8 0x561e09e1dc19 in abis_nm_rcvmsg osmo-bsc/src/osmo-bsc/abis_nm.c:926 #9 0x7f587ec90cc2 in handle_ts1_read input/ipaccess.c:274 #10 0x7f587ec90cc2 in ipaccess_fd_cb input/ipaccess.c:389 #11 0x7f587efb1ca8 in osmo_fd_disp_fds libosmocore/src/select.c:217 #12 0x7f587efb1ca8 in osmo_select_main libosmocore/src/select.c:257 #13 0x561e09e049d6 in main osmo-bsc/src/osmo-bsc/osmo_bsc_main.c:922 #14 0x7f587d53a2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0) #15 0x561e09e054e9 in _start (/bin/osmo-bsc+0x34d4e9) Fixes: OS#3494 Change-Id: I030117abfdcee387516a4dea7e1e6a9bae8055f6
-rw-r--r--src/osmo-bsc/abis_nm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index d056bc439..f59a4fe82 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -1888,9 +1888,9 @@ int abis_nm_set_channel_attr(struct gsm_bts_trx_ts *ts, uint8_t chan_comb)
DEBUGPFOH(DNM, foh, "Set Chan Attr %s\n", gsm_ts_name(ts));
if (verify_chan_comb(ts, chan_comb, &reason) < 0) {
- msgb_free(msg);
LOGPFOH(DNM, LOGL_ERROR, foh, "Invalid Channel Combination %d on %s. Reason: %s\n",
chan_comb, gsm_ts_name(ts), reason);
+ msgb_free(msg);
return -EINVAL;
}
ts->nm_chan_comb = chan_comb;