wifi: brcmfmac: cyw: fix heap overflow on a short auth frame
PATCH v2 1/1 wifi: brcmfmac: cyw: fix heap overflow on a short auth frame
brcmf_notify_auth_frame_rx() takes the frame length from the firmware event and copies the frame body with the management header offset subtracted:
u32 mgmt_frame_len = e->datalen - sizeof(struct brcmf_rx_mgmt_data); ... memcpy(&mgmt_frame->u, frame, mgmt_frame_len - offsetof(struct ieee80211_mgmt, u));
The only length check is e->datalen >= sizeof(*rxframe), so mgmt_frame_len can be anything from 0 up. offsetof(struct ieee80211_mgmt, u) is 24. When mgmt_frame_len is below that, the subtraction wraps as an unsigned value to a huge length. The memcpy then runs far past the kzalloc'd buffer. A malicious or malfunctioning AP can make the frame short during the external SAE auth exchange, so this is a remotely triggered heap overflow.
Reject frames shorter than the management header offset before the copy.
---
v2: drop the Link: tag (Arend), add Arend's Acked-by.
v1: https://lore.kernel.org/r/[email protected]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +6 -0
@@ -293,6 +293,12 @@ brcmf_notify_auth_frame_rx(struct brcmf_if *ifp,return -EINVAL ; } +if (mgmt_frame_len < offsetof(struct ieee80211_mgmt , u)) { +bphy_err (drvr,"Event %s (%d) frame too small. Ignore\n" , +brcmf_fweh_event_name (e->event_code), e->event_code); +return -EINVAL ; + } + wdev = &ifp->vif->wdev;WARN_ON (!wdev);
Signature · 1 line
2.34.1
Arend van Spriel
maintainerQuoted 16 lines · Maoyi Xie
brcmf_notify_auth_frame_rx()takes the frame length from the firmware event and copies the frame body with the management header offset subtracted:u32 mgmt_frame_len = e->datalen - sizeof(struct brcmf_rx_mgmt_data); ... memcpy(&mgmt_frame->u, frame, mgmt_frame_len - offsetof(struct ieee80211_mgmt, u));The only length check is
e->datalen>=sizeof(*rxframe), somgmt_frame_lencan be anything from 0 up.offsetof(struct ieee80211_mgmt, u)is 24. Whenmgmt_frame_lenis below that, the subtraction wraps as an unsigned value to a huge length. The memcpy then runs far past the kzalloc'd buffer. A malicious or malfunctioning AP can make the frame short during the external SAE auth exchange, so this is a remotely triggered heap overflow.
Quoted 8 lines
Reject frames shorter than the management header offset before the copy.
Fixes 66f909308a7c ("wifi: brcmfmac: cyw: support external SAE authentication in station mode")Co-developed-by Kaixuan Li <[email protected]>Signed-off-by Kaixuan Li <[email protected]>Signed-off-by Maoyi Xie <[email protected]>Acked-by Arend van Spriel <[email protected]>
Thanks. Nothing to add here.
Quoted 6 lines
---
v2: drop the Link: tag (Arend), add Arend's Acked-by.v1: https://lore.kernel.org/r/[email protected]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
Arend van Spriel
maintainerQuoted 19 lines · Arend van Spriel
Quoted 18 lines · Maoyi Xie
brcmf_notify_auth_frame_rx()takes the frame length from the firmware event and copies the frame body with the management header offset subtracted:u32
mgmt_frame_len=e->datalen-sizeof(struct brcmf_rx_mgmt_data);
...
memcpy(&mgmt_frame->u, frame,
mgmt_frame_len-offsetof(struct ieee80211_mgmt, u));The only length check is
e->datalen>=sizeof(*rxframe), somgmt_frame_lencan be anything from 0 up.offsetof(struct ieee80211_mgmt, u)is 24. Whenmgmt_frame_lenis below that, the subtraction wraps as an unsigned value to a huge length. The memcpy then runs far past the kzalloc'd buffer. A malicious or malfunctioning AP can make the frame short during the external SAE auth exchange, so this is a remotely triggered heap overflow.Reject frames shorter than the management header offset before the copy.
Quoted 8 lines
Quoted 6 lines
Fixes 66f909308a7c ("wifi: brcmfmac: cyw: support external SAE authentication in station mode")Co-developed-by Kaixuan Li <[email protected]>Signed-off-by Kaixuan Li <[email protected]>Signed-off-by Maoyi Xie <[email protected]>Acked-by Arend van Spriel <[email protected]>Thanks. Nothing to add here.
Actually v1 was already applied to the wireless tree.
Quoted 6 lines
Quoted 6 lines
---
v2: drop the Link: tag (Arend), add Arend's Acked-by.v1: https://lore.kernel.org/r/20260627131313.3878893-1- [email protected]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c| 6 ++++++1 file changed, 6 insertions(+)
Quoted 2 lines · Arend van Spriel
Actually v1 was already applied to the wireless tree.
Yeah, I thought the Link: was fine - I (only) add links to the patch submission itself for tracking (Linus isn't super happy about accepts it now), but the link given was to a report/further discussion, so that seemed OK.
johannes