From: Jouni Malinen Date: Tue, 7 Jul 2015 10:04:08 +0000 (+0300) Subject: trace: Use explicit alignment requirements to avoid misalignment X-Git-Tag: hostap_2_5~466 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e01281fccc666e121dc5846dad85327bae6e9517;p=thirdparty%2Fhostap.git trace: Use explicit alignment requirements to avoid misalignment 64-bit builds with CONFIG_WPA_TRACE=y resulted in the wpabuf pointers getting misaligned (only 32-bit aligned) and that would result in reads and writes of unaligned size_t values. Avoid this by indicating explicit alignment requirement for wpabuf_trace to 8 octets (i.e., there will be extra four octets of padding in case of 64-bit builds). Similarly, struct os_alloc_trace resulted in some potential misalignment cases, e.g., when CONFIG_ACS=y uses a 'long double' variable within struct hostapd_channel_data. Avoid misalignment issues with explicit alignment indication. Signed-off-by: Jouni Malinen --- diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index e4259042a..089b880bd 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -36,7 +36,7 @@ struct os_alloc_trace { struct dl_list list; size_t len; WPA_TRACE_INFO -}; +} __attribute__((aligned(16))); #endif /* WPA_TRACE */ diff --git a/src/utils/wpabuf.c b/src/utils/wpabuf.c index 7aafa0a51..11e732361 100644 --- a/src/utils/wpabuf.c +++ b/src/utils/wpabuf.c @@ -17,7 +17,7 @@ struct wpabuf_trace { unsigned int magic; -}; +} __attribute__((aligned(8))); static struct wpabuf_trace * wpabuf_get_trace(const struct wpabuf *buf) {