osmo-bsc/include/osmocom/bsc
Pau Espin 9862bcb5cd Fix heap-use-after-free due to OML link destruction
ipaccess_drop_oml was being called inside an osmo_fd cb context, were
-EBADF must be returned if the structure holding the osmo_fd is freed.
In the middle of the path (see OS#3495 for path tree) it goes through a
signal dispatch, so it's impossible to make sure we return some value to
the osmo_fd cb. As a result, it is required to defer dropping the OML
Link from current code path and do it through a timer.

Fixes following ASan report:
20180822124927913  <0004> abis_nm.c:787 OC=RADIO-CARRIER(02) INST=(00,00,ff): CHANGE ADMINISTRATIVE STATE NACK CAUSE=Message cannot be performed
20180822124927913  <0004> osmo_bsc_main.c:186 Got CHANGE ADMINISTRATIVE STATE NACK going to drop the OML links.
20180822124927913  <0015> bts_ipaccess_nanobts.c:406 (bts=0) Dropping OML link.
...
=================================================================
==17607==ERROR: AddressSanitizer: heap-use-after-free on address 0x62e000060a68 at pc 0x7f5ea8e27086 bp 0x7ffde92b6d80 sp 0x7ffde92b6d78
READ of size 8 at 0x62e000060a68 thread T0
    #0 0x7f5ea8e27085 in handle_ts1_write input/ipaccess.c:371
    #1 0x7f5ea8e27085 in ipaccess_fd_cb input/ipaccess.c:391
    #2 0x7f5ea9147ca8 in osmo_fd_disp_fds libosmocore/src/select.c:217
    #3 0x7f5ea9147ca8 in osmo_select_main libosmocore/src/select.c:257
    #4 0x555813ab79d6 in main osmo-bsc/osmo_bsc_main.c:922
    #5 0x7f5ea76d02e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #6 0x555813ab84e9 in _start (/bin/osmo-bsc+0x34d4e9)

Fixes: OS#3495
Change-Id: I7c794c763481c28e8c35dc9b11d27969e16feb3c
2018-08-23 16:47:30 +02:00
..
Makefile.am cosmetic: rename bsc_api.h to gsm_08_08.h 2018-07-28 12:18:23 +02:00
a_reset.h GSCON: call api of a_reset.c with msc object directly 2018-08-07 15:11:41 +00:00
abis_nm.h fix dyn TS init: properly identify BTS on OML OPSTART ACK 2018-06-15 21:00:31 +02:00
abis_om2000.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
abis_rsl.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
acc_ramp.h ensure that acc_ramp_init() is only called once 2018-04-11 16:53:05 +00:00
arfcn_range_encode.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
assignment_fsm.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
bsc_msc_data.h lcls: do not LCLS call legs with different codecs 2018-08-08 13:02:58 +02:00
bsc_msg_filter.h Rename bsc_msg_acc_lst_vty_init to have more uniform prefix 2018-06-28 12:58:53 +02:00
bsc_rll.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
bsc_subscr_conn_fsm.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
bsc_subscriber.h use __FILE__, not __BASE_FILE__ 2018-08-20 12:40:43 +02:00
bss.h dissolve libbsc: move all to src/osmo-bsc, link .o files 2018-06-07 19:09:06 +02:00
bts_ipaccess_nanobts_omlattr.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
chan_alloc.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
codec_pref.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
ctrl.h Support control connection status query for a particular MSC. 2018-01-09 11:18:10 +00:00
debug.h create separate logging categories for lchan,ts,as FSMs 2018-07-28 12:18:23 +02:00
e1_config.h libcommon: join gsm_data_shared.* into gsm_data.* 2018-02-14 12:15:40 +01:00
gsm_04_08_rr.h cosmetic: reduce bsc_api.h 2018-07-28 12:18:23 +02:00
gsm_04_80.h bsc/gsm_04_80.h: clean up useless declarations 2018-01-12 14:06:56 +00:00
gsm_08_08.h cosmetic: rename bsc_api.h to gsm_08_08.h 2018-07-28 12:18:23 +02:00
gsm_data.h Fix heap-use-after-free due to OML link destruction 2018-08-23 16:47:30 +02:00
gsm_timers.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
handover.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
handover_cfg.h ho cfg: fix unit strings 2018-07-21 17:08:00 +00:00
handover_decision.h HO: make bts_by_arfcn_bsic() public 2018-01-19 22:09:19 +00:00
handover_decision_2.h HO: Implement load based handover, as handover_decision_2.c 2018-02-19 17:11:47 +01:00
handover_fsm.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
handover_vty.h HO: cfg: tweak vty write 2018-02-16 16:11:16 +01:00
ipaccess.h Fix heap-use-after-free due to OML link destruction 2018-08-23 16:47:30 +02:00
lchan_fsm.h lchan_fsm: split off lchan_rtp_fsm, establish RTP a bit earlier 2018-07-28 12:18:23 +02:00
lchan_rtp_fsm.h lchan_fsm: split off lchan_rtp_fsm, establish RTP a bit earlier 2018-07-28 12:18:23 +02:00
lchan_select.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
meas_feed.h resurrect meas_feed.c: vty, vty-test 2018-05-04 15:02:24 +00:00
meas_rep.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
mgw_endpoint_fsm.h gscon: use BSS-common payload types on BSS side 2018-08-01 11:27:17 +02:00
misdn.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
neighbor_ident.h inter-BSC HO: neighbor_ident API: drop 9bit BSIC 2018-07-28 12:18:23 +02:00
network_listen.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
openbscdefines.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
osmo_bsc.h cosmetic: reduce bsc_api.h 2018-07-28 12:18:23 +02:00
osmo_bsc_grace.h Implement support for paging based on CI (cell identifier). 2018-01-15 10:46:43 +00:00
osmo_bsc_lcls.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
osmo_bsc_reset.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
osmo_bsc_rf.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
osmo_bsc_sigtran.h Remove 'struct bsc_msc_connection' + fix IPA-encapsulated CTRL 2018-05-27 20:17:02 +02:00
osmux.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
paging.h Move BTS selection for paging from osmo_bsc_grace.c into osmo_bsc_bssap.c. 2018-01-16 14:14:01 +01:00
pcu_if.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
pcuif_proto.h pcu_if: implement support for 3-digit MNC 2018-03-11 00:45:45 +01:00
penalty_timers.h cosmetic: penalty timers: constify, tweak doc 2018-06-08 16:16:42 +00:00
rest_octets.h Generate SI2bis Rest Octets 2017-12-12 18:00:56 +00:00
rs232.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
signal.h fix dyn TS init: properly identify BTS on OML OPSTART ACK 2018-06-15 21:00:31 +02:00
system_information.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
timeslot_fsm.h large refactoring: use FSMs for lchans; add inter-BSC HO 2018-07-28 12:18:23 +02:00
ussd.h move include/openbsc to include/osmocom/bsc 2017-09-06 16:26:13 +02:00
vty.h vty: drop unused vty definitions (*_NODE, msc_*) 2018-03-22 17:27:57 +00:00