Skip to content

Commit 1a30a6b

Browse files
keesjmberg-intel
authored andcommitted
wifi: brcmfmac: p2p: Introduce generic flexible array frame member
Silence run-time memcpy() false positive warning when processing management frames: memcpy: detected field-spanning write (size 27) of single field "&mgmt_frame->u" at drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c:1469 (size 26) Due to this (soon to be fixed) GCC bug[1], FORTIFY_SOURCE (via __builtin_dynamic_object_size) doesn't recognize that the union may end with a flexible array, and returns "26" (the fixed size of the union), rather than the remaining size of the allocation. Add an explicit flexible array member and set it as the destination here, so that we get the correct coverage for the memcpy(). [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101832 Reported-by: Ard Biesheuvel <[email protected]> Cc: Arend van Spriel <[email protected]> Cc: Franky Lin <[email protected]> Cc: Hante Meuleman <[email protected]> Cc: Kalle Valo <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: Johannes Berg <[email protected]> Cc: "Jason A. Donenfeld" <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "Darrick J. Wong" <[email protected]> Cc: Colin Ian King <[email protected]> Cc: Brian Henriquez <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] [rename 'frame' to 'body'] Signed-off-by: Johannes Berg <[email protected]>
1 parent 3caf31e commit 1a30a6b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,8 @@ int brcmf_p2p_notify_action_frame_rx(struct brcmf_if *ifp,
14661466
ETH_ALEN);
14671467
memcpy(mgmt_frame->sa, e->addr, ETH_ALEN);
14681468
mgmt_frame->frame_control = cpu_to_le16(IEEE80211_STYPE_ACTION);
1469-
memcpy(&mgmt_frame->u, frame, mgmt_frame_len);
1470-
mgmt_frame_len += offsetof(struct ieee80211_mgmt, u);
1469+
memcpy(mgmt_frame->u.body, frame, mgmt_frame_len);
1470+
mgmt_frame_len += offsetof(struct ieee80211_mgmt, u.body);
14711471

14721472
freq = ieee80211_channel_to_frequency(ch.control_ch_num,
14731473
ch.band == BRCMU_CHAN_BAND_2G ?

include/linux/ieee80211.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,7 @@ struct ieee80211_mgmt {
13561356
} __packed wnm_timing_msr;
13571357
} u;
13581358
} __packed action;
1359+
DECLARE_FLEX_ARRAY(u8, body); /* Generic frame body */
13591360
} u;
13601361
} __packed __aligned(2);
13611362

0 commit comments

Comments
 (0)