* [PATCH] ath10k: improve structure padding
@ 2023-06-16 9:04 Arnd Bergmann
2023-06-21 18:08 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2023-06-16 9:04 UTC (permalink / raw)
To: Kalle Valo
Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, Tom Rix,
Gustavo A. R. Silva, Kees Cook, ath10k, linux-wireless,
linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
Including an aligned structure inside of a packed one is ambiguous
and can lead to misaligned data, as pointed out by this clang warning:
drivers/net/wireless/ath/ath10k/htt.h:715:34: error: field prefix within 'struct htt_rx_indication' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
struct htt_rx_indication_prefix prefix;
^
drivers/net/wireless/ath/ath10k/htt.h:736:34: error: field prefix within 'struct htt_rx_indication_hl' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication_hl' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
struct htt_rx_indication_prefix prefix;
^
drivers/net/wireless/ath/ath10k/htt.h:1564:2: error: field within 'struct htt_tx_fetch_ind' is less aligned than 'union htt_tx_fetch_ind::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1564:2)' and is usually due to 'struct htt_tx_fetch_ind' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
union {
^
drivers/net/wireless/ath/ath10k/htt.h:1702:2: error: field within 'struct htt_resp' is less aligned than 'union htt_resp::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1702:2)' and is usually due to 'struct htt_resp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
These structures appear to actually need the packing since they
are embedded at misaligned offsets. Add even more such annotations
here to enforce bytewise access throughout the driver.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/wireless/ath/ath10k/htt.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h
index c051a22fce145..e0c9f45e74761 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -707,7 +707,7 @@ struct htt_rx_indication_prefix {
__le16 fw_rx_desc_bytes;
u8 pad0;
u8 pad1;
-};
+} __packed;
struct htt_rx_indication {
struct htt_rx_indication_hdr hdr;
@@ -1565,7 +1565,7 @@ struct htt_tx_fetch_ind {
/* ath10k_htt_get_tx_fetch_ind_resp_ids() */
DECLARE_FLEX_ARRAY(__le32, resp_ids);
DECLARE_FLEX_ARRAY(struct htt_tx_fetch_record, records);
- };
+ } __packed;
} __packed;
static inline void *
@@ -1723,7 +1723,7 @@ struct htt_resp {
struct htt_tx_mode_switch_ind tx_mode_switch_ind;
struct htt_channel_change chan_change;
struct htt_peer_tx_stats peer_tx_stats;
- };
+ } __packed;
} __packed;
/*** host side structures follow ***/
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ath10k: improve structure padding
2023-06-16 9:04 [PATCH] ath10k: improve structure padding Arnd Bergmann
@ 2023-06-21 18:08 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2023-06-21 18:08 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, Tom Rix,
Gustavo A. R. Silva, Kees Cook, ath10k, linux-wireless,
linux-kernel, llvm
Arnd Bergmann <arnd@kernel.org> wrote:
> Including an aligned structure inside of a packed one is ambiguous
> and can lead to misaligned data, as pointed out by this clang warning:
>
> drivers/net/wireless/ath/ath10k/htt.h:715:34: error: field prefix within 'struct htt_rx_indication' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
> struct htt_rx_indication_prefix prefix;
> ^
> drivers/net/wireless/ath/ath10k/htt.h:736:34: error: field prefix within 'struct htt_rx_indication_hl' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication_hl' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
> struct htt_rx_indication_prefix prefix;
> ^
> drivers/net/wireless/ath/ath10k/htt.h:1564:2: error: field within 'struct htt_tx_fetch_ind' is less aligned than 'union htt_tx_fetch_ind::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1564:2)' and is usually due to 'struct htt_tx_fetch_ind' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
> union {
> ^
> drivers/net/wireless/ath/ath10k/htt.h:1702:2: error: field within 'struct htt_resp' is less aligned than 'union htt_resp::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1702:2)' and is usually due to 'struct htt_resp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
>
> These structures appear to actually need the packing since they
> are embedded at misaligned offsets. Add even more such annotations
> here to enforce bytewise access throughout the driver.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Patch applied to ath-next branch of ath.git, thanks.
12ec37be3faf wifi: ath10k: improve structure padding
--
https://patchwork.kernel.org/project/linux-wireless/patch/20230616090439.2484857-1-arnd@kernel.org/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-21 18:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16 9:04 [PATCH] ath10k: improve structure padding Arnd Bergmann
2023-06-21 18:08 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®