libosmo-abis/src
Vadim Yanitskiy c2729a525c fix use-after-free in ipaccess_bts_keepalive_fsm_alloc()
In ipaccess_bts_keepalive_fsm_alloc() we allocate a keepalive FSM
instance as a child of the respective struct ipa_client_conn, and
store the pointer to the respective struct e1inp_ts.

  + struct e1inp_line
  |
  ---+ struct ipaccess_line (void *driver_data)
  |  |
  |  ---+ struct ipa_client_conn *ipa_cli[NUM_E1_TS]  // <-- parent
  |
  ---+ struct e1inp_ts ts[NUM_E1_TS]
  |  |
  |  ---+ .driver.ipaccess.ka_fsm  // <-- pointer

When an ipaccess connection (be it OML or RSL) goes down and then
up again, for instance if the BSC gets restarted, osmo-bts crashes.
The problem is that struct ipa_client_conn gets free()ed before the
associated FSM instance gets terminated:

* e1inp_ipa_bts_rsl_connect_n() is called
** calling e1inp_ipa_bts_rsl_close_n()
*** this function free()s struct ipa_client_conn
*** (!) as well as the struct osmo_fsm_inst (talloc child)
** calling ipaccess_bts_keepalive_fsm_alloc()
*** calling ipaccess_keepalive_fsm_cleanup()
**** accessing free()d e1i_ts->driver.ipaccess.ka_fsm
**** BOOOM!  segmentation fault

Fix this by calling ipaccess_keepalive_fsm_cleanup() before free()ing
the associated struct ipa_client_conn.

Note that ipaccess_bsc_keepalive_fsm_alloc() is not affected because
it's allocating keepalive FSMs using the global tall_ipa_ctx.

Change-Id: Ic56c4b5b7b24b63104908a0c24f2f645ba4c5c1b
Related: SYS#6438
(cherry picked from commit f6bde0f521)
2023-05-08 22:18:14 +07:00
..
input fix use-after-free in ipaccess_bts_keepalive_fsm_alloc() 2023-05-08 22:18:14 +07:00
trau trau_sync: add Ericsson RBS GPRS TRAU synchronization pattern (16kbps) 2022-12-23 11:04:08 +00:00
Makefile.am libosmo{abis,trau}: add -no-undefined to *_la_LDFLAGS 2022-08-04 05:18:21 +07:00
e1_input.c Run struct_endianness.py 2023-05-08 22:18:14 +07:00
e1_input_vty.c ipaccess: Add connect timeout in e1inp_line 2022-12-15 16:10:36 +01:00
init.c Add SPDX-License-Identifier to all source files 2017-11-13 01:09:21 +09:00
ipa_proxy.c vty: use install_lib_element() and install_lib_element_ve() 2020-10-04 16:45:59 +07:00
subchan_demux.c subchan_demux: Fix out-of-bounds write 2020-07-04 11:21:23 +02:00
trau_frame.c trau_frame: Fix AMR frame decoding 2020-05-14 15:48:09 +00:00