fix mgcp_conn_free_all ubsan complaints

ubsan still complains about a unaligned load that can't be explained, so
silence it:

/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15: runtime
error: member access within misaligned address 0x612000000249 for type
'const struct llist_head', which requires 8 byte alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15 in
/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15: runtime
error: load of misaligned address 0x612000000249 for type 'struct
llist_head *const', which requires 8 byte alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/mgw-threads/install/include/osmocom/core/linuxlist.h:171:15 in
mgcp_conn.c:303:17: runtime error: member access within misaligned
address 0x612000000249 for type 'struct llist_head', which requires 8
byte alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
mgcp_conn.c:303:17 in
mgcp_conn.c:303:17: runtime error: load of misaligned address
0x612000000249 for type 'struct llist_head *', which requires 8 byte
alignment
0x612000000249: note: pointer points here
00 00 00  48 02 00 00 20 61 00 00  48 02 00 00 20 61 00 00  60 02 00 00
a0 62 00 00  80 1f 49 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
mgcp_conn.c:303:17 in
mgcp_conn.c:304:30: runtime error: member access within misaligned
address 0x4800006120000002 for type 'struct mgcp_conn', which requires 8
byte alignment
0x4800006120000002: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
mgcp_conn.c:304:30 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==223426==ERROR: AddressSanitizer: SEGV on unknown address (pc
0x0000004553f7 bp 0x7ffda5855080 sp 0x7ffda5855040 T0)
==223426==The signal is caused by a READ memory access.
==223426==Hint: this fault was caused by a dereference of a high value
address (see register values below).  Disassemble the provided pc to
learn which register was used.
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:199:14
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:258:9
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:304:3
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_endp.c:124:2
/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test.c:670:3
/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test.c:923:2
/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test.c:2248:2
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
(/mgw-threads/osmo-mgw/tests/mgcp/mgcp_test+0x404c2d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV
/mgw-threads/osmo-mgw/src/libosmo-mgcp/mgcp_conn.c:199:14 in
mgcp_conn_get
==223426==ABORTING

Change-Id: Ifd056eeb88966df164c07b9165b25faa4edbaadb
This commit is contained in:
Eric Wild 2021-11-09 21:45:44 +01:00 committed by laforge
parent 98aef217c6
commit 7c0fe31697
1 changed files with 5 additions and 0 deletions

View File

@ -325,6 +325,11 @@ void mgcp_conn_free_oldest(struct mgcp_endpoint *endp)
/*! free all connections at once.
* \param[in] endp associated endpoint */
#if defined(__has_attribute)
#if __has_attribute(no_sanitize)
__attribute__((no_sanitize("undefined"))) /* ubsan detects a misaligned load */
#endif
#endif
void mgcp_conn_free_all(struct mgcp_endpoint *endp)
{
struct mgcp_conn *conn;