Workaround ASan false positive runtime errors under some platforms

Under some platforms (RPI4, ARM) container older ASan, it will log false
positive log errors which will make unit test fail because then output
changes:
"""
pcu_l1_if.cpp:847:2: runtime error: member access within misaligned address 0xb3f0b78c for type 'struct GprsMs', which requires 8 byte alignment
"""

The pointer is indeed misaligned, but it's not actually a bug, because
the pointer is never derreferenced. That happens during
llist_for_each_entry operation where it does cast the pointer but it
only checks if the list has actually reached the end.

To workaround the issue, simply defer casting it by using llist_for_each
instead, where the pointer is assigned only in the case it really points
to a GprsMS struct.

Change-Id: I149fb42706501eb33f9c6fe48f76a03ddee5954a
This commit is contained in:
Pau Espin 2021-01-14 12:12:43 +01:00
parent f842e06c88
commit 54faf023be
2 changed files with 7 additions and 4 deletions

View File

@ -840,15 +840,16 @@ static int pcu_rx_susp_req(struct gsm_pcu_if_susp_req *susp_req)
static int pcu_rx_app_info_req(struct gsm_pcu_if_app_info_req *app_info_req)
{
GprsMs *ms;
BTS *bts = BTS::main_bts();
struct gprs_rlcmac_bts *bts_data = bts->bts_data();
struct llist_head *tmp;
LOGP(DL1IF, LOGL_DEBUG, "Application Information Request received: type=0x%08x len=%i\n",
app_info_req->application_type, app_info_req->len);
bts_data->app_info_pending = 0;
llist_for_each_entry(ms, bts->ms_store().ms_list(), list) {
llist_for_each(tmp, bts->ms_store().ms_list()) {
GprsMs *ms = llist_entry(tmp, typeof(*ms), list);
if (!ms_dl_tbf(ms))
continue;
bts_data->app_info_pending++;

View File

@ -207,10 +207,12 @@ static int show_ms(struct vty *vty, GprsMs *ms)
int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
{
BTS *bts = bts_data->bts;
GprsMs *ms_iter;
struct llist_head *tmp;
llist_for_each_entry(ms_iter, bts->ms_store().ms_list(), list)
llist_for_each(tmp, bts->ms_store().ms_list()) {
GprsMs *ms_iter = llist_entry(tmp, typeof(*ms_iter), list);
show_ms(vty, ms_iter);
}
return CMD_SUCCESS;
}