Change in osmo-pcu[master]: Workaround ASan false positive runtime errors under some platforms

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Jan 14 11:24:15 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/22178 )


Change subject: Workaround ASan false positive runtime errors under some platforms
......................................................................

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
---
M src/pcu_l1_if.cpp
M src/pcu_vty_functions.cpp
2 files changed, 7 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/78/22178/1

diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 9cc6270..2aea00b 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -840,15 +840,16 @@
 
 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 92be77b..0276b3e 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -207,10 +207,12 @@
 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;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/22178
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I149fb42706501eb33f9c6fe48f76a03ddee5954a
Gerrit-Change-Number: 22178
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210114/2b54a810/attachment.htm>


More information about the gerrit-log mailing list