aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel/iwlegacy/common.h
diff options
context:
space:
mode:
authorBen Hutchings <[email protected]>2024-09-11 23:01:21 +0000
committerKalle Valo <[email protected]>2024-09-19 08:45:46 +0000
commitd4cdc46ca16a5c78b36c5b9b6ad8cac09d6130a0 (patch)
treeb0698dfd0b021acee2959fa1eea3e2328c080b7d /drivers/net/wireless/intel/iwlegacy/common.h
parentwifi: mt76: do not increase mcu skb refcount if retry is not supported (diff)
downloadkernel-d4cdc46ca16a5c78b36c5b9b6ad8cac09d6130a0.tar.gz
kernel-d4cdc46ca16a5c78b36c5b9b6ad8cac09d6130a0.zip
wifi: iwlegacy: Fix "field-spanning write" warning in il_enqueue_hcmd()
iwlegacy uses command buffers with a payload size of 320 bytes (default) or 4092 bytes (huge). The struct il_device_cmd type describes the default buffers and there is no separate type describing the huge buffers. The il_enqueue_hcmd() function works with both default and huge buffers, and has a memcpy() to the buffer payload. The size of this copy may exceed 320 bytes when using a huge buffer, which now results in a run-time warning: memcpy: detected field-spanning write (size 1014) of single field "&out_cmd->cmd.payload" at drivers/net/wireless/intel/iwlegacy/common.c:3170 (size 320) To fix this: - Define a new struct type for huge buffers, with a correctly sized payload field - When using a huge buffer in il_enqueue_hcmd(), cast the command buffer pointer to that type when looking up the payload field Reported-by: Martin-Éric Racine <[email protected]> References: https://bugs.debian.org/1062421 References: https://bugzilla.kernel.org/show_bug.cgi?id=219124 Signed-off-by: Ben Hutchings <[email protected]> Fixes: 54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()") Tested-by: Martin-Éric Racine <[email protected]> Tested-by: Brandon Nielsen <[email protected]> Acked-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://patch.msgid.link/ZuIhQRi/[email protected]
Diffstat (limited to 'drivers/net/wireless/intel/iwlegacy/common.h')
-rw-r--r--drivers/net/wireless/intel/iwlegacy/common.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/wireless/intel/iwlegacy/common.h b/drivers/net/wireless/intel/iwlegacy/common.h
index 2147781b5fff..725c2a88ddb7 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.h
+++ b/drivers/net/wireless/intel/iwlegacy/common.h
@@ -560,6 +560,18 @@ struct il_device_cmd {
#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd))
+/**
+ * struct il_device_cmd_huge
+ *
+ * For use when sending huge commands.
+ */
+struct il_device_cmd_huge {
+ struct il_cmd_header hdr; /* uCode API */
+ union {
+ u8 payload[IL_MAX_CMD_SIZE - sizeof(struct il_cmd_header)];
+ } __packed cmd;
+} __packed;
+
struct il_host_cmd {
const void *data;
unsigned long reply_page;