aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2020-12-04 11:45:03 (GMT)
committerJouni Malinen <j@w1.fi>2020-12-04 11:59:37 (GMT)
commitbba926350a0e28fa181af7caee24a11619ad10fc (patch)
tree2cce3851f679e747a5369553b9334db695663f25
parentd215f42538289c230c015550bc4efb4586c208b2 (diff)
downloadhostap-bba926350a0e28fa181af7caee24a11619ad10fc.zip
hostap-bba926350a0e28fa181af7caee24a11619ad10fc.tar.gz
hostap-bba926350a0e28fa181af7caee24a11619ad10fc.tar.bz2
Fix gcc-10 build with -Werror=array-bounds and dl_list_for_each()
The earlier workaround for UBSAN issues in commit 3b6b3ae58133 ("Modify dl_list_for_each() to not use unaligned access with WPA_TRACE") ended up using a construction in which the type cast to the containing structure was compared instead of the struct dl_list pointers. While that worked around the UBSAN issue, it resulted in a comparison that gcc-10 interprets as being out of bounds for struct dl_list (which it obviously is since this is to find the start of the containing structure). Revert that workaround and instead, mark the struct dl_list used within struct os_alloc_trace to have matching 16 octet alignment as the containing structure. This is also restoring consistent design for dl_list_for_each*(). Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--src/utils/list.h4
-rw-r--r--src/utils/os_unix.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/list.h b/src/utils/list.h
index 5298c26..aa62c08 100644
--- a/src/utils/list.h
+++ b/src/utils/list.h
@@ -76,8 +76,8 @@ static inline unsigned int dl_list_len(const struct dl_list *list)
dl_list_entry((list)->prev, type, member))
#define dl_list_for_each(item, list, type, member) \
- for (item = dl_list_first((list), type, member); \
- item && item != dl_list_entry((list), type, member); \
+ for (item = dl_list_entry((list)->next, type, member); \
+ &item->member != (list); \
item = dl_list_entry(item->member.next, type, member))
#define dl_list_for_each_safe(item, n, list, type, member) \
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 6f0c177..1de3720 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -39,7 +39,7 @@ static struct dl_list alloc_list = DL_LIST_HEAD_INIT(alloc_list);
struct os_alloc_trace {
unsigned int magic;
- struct dl_list list;
+ struct dl_list list __attribute__((aligned(16)));
size_t len;
WPA_TRACE_INFO
} __attribute__((aligned(16)));