aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-14 12:12:43 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-01-14 12:12:45 +0100
commit54faf023be0e8f9bcfdb64fd0afb3a00138cd45f (patch)
tree92516f6860837b7cb4bc247a09f1e38da4c12cfb
parentf842e06c88027ed6ccf5a791d6691228b858fd56 (diff)
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
-rw-r--r--src/pcu_l1_if.cpp5
-rw-r--r--src/pcu_vty_functions.cpp6
2 files changed, 7 insertions, 4 deletions
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 9cc62708..2aea00b4 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -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++;
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index 92be77be..0276b3e3 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -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;
}