提交 7b779771 编写于 作者: A Arend van Spriel 提交者: Xie XiuQi

brcmfmac: add subtype check for event handling in data path

mainline inclusion
from mainline-5.1-rc5
commit a4176ec356c73a46c07c181c6d04039fafa34a9f
category: bugfix
bugzilla: 13690
CVE: CVE-2019-9503

-------------------------------------------------

For USB there is no separate channel being used to pass events
from firmware to the host driver and as such are passed over the
data path. In order to detect mock event messages an additional
check is needed on event subtype. This check is added conditionally
using unlikely() keyword.
Reviewed-by: NHante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: NPieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: NFranky Lin <franky.lin@broadcom.com>
Signed-off-by: NArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7bea75c2
...@@ -464,7 +464,8 @@ void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event) ...@@ -464,7 +464,8 @@ void brcmf_rx_frame(struct device *dev, struct sk_buff *skb, bool handle_event)
} else { } else {
/* Process special event packets */ /* Process special event packets */
if (handle_event) if (handle_event)
brcmf_fweh_process_skb(ifp->drvr, skb); brcmf_fweh_process_skb(ifp->drvr, skb,
BCMILCP_SUBTYPE_VENDOR_LONG);
brcmf_netif_rx(ifp, skb); brcmf_netif_rx(ifp, skb);
} }
...@@ -481,7 +482,7 @@ void brcmf_rx_event(struct device *dev, struct sk_buff *skb) ...@@ -481,7 +482,7 @@ void brcmf_rx_event(struct device *dev, struct sk_buff *skb)
if (brcmf_rx_hdrpull(drvr, skb, &ifp)) if (brcmf_rx_hdrpull(drvr, skb, &ifp))
return; return;
brcmf_fweh_process_skb(ifp->drvr, skb); brcmf_fweh_process_skb(ifp->drvr, skb, 0);
brcmu_pkt_buf_free_skb(skb); brcmu_pkt_buf_free_skb(skb);
} }
......
...@@ -211,7 +211,7 @@ enum brcmf_fweh_event_code { ...@@ -211,7 +211,7 @@ enum brcmf_fweh_event_code {
*/ */
#define BRCM_OUI "\x00\x10\x18" #define BRCM_OUI "\x00\x10\x18"
#define BCMILCP_BCM_SUBTYPE_EVENT 1 #define BCMILCP_BCM_SUBTYPE_EVENT 1
#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
/** /**
* struct brcm_ethhdr - broadcom specific ether header. * struct brcm_ethhdr - broadcom specific ether header.
...@@ -334,10 +334,10 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr, ...@@ -334,10 +334,10 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr,
void brcmf_fweh_p2pdev_setup(struct brcmf_if *ifp, bool ongoing); void brcmf_fweh_p2pdev_setup(struct brcmf_if *ifp, bool ongoing);
static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr, static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
struct sk_buff *skb) struct sk_buff *skb, u16 stype)
{ {
struct brcmf_event *event_packet; struct brcmf_event *event_packet;
u16 usr_stype; u16 subtype, usr_stype;
/* only process events when protocol matches */ /* only process events when protocol matches */
if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL)) if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL))
...@@ -346,8 +346,16 @@ static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr, ...@@ -346,8 +346,16 @@ static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
if ((skb->len + ETH_HLEN) < sizeof(*event_packet)) if ((skb->len + ETH_HLEN) < sizeof(*event_packet))
return; return;
/* check for BRCM oui match */
event_packet = (struct brcmf_event *)skb_mac_header(skb); event_packet = (struct brcmf_event *)skb_mac_header(skb);
/* check subtype if needed */
if (unlikely(stype)) {
subtype = get_unaligned_be16(&event_packet->hdr.subtype);
if (subtype != stype)
return;
}
/* check for BRCM oui match */
if (memcmp(BRCM_OUI, &event_packet->hdr.oui[0], if (memcmp(BRCM_OUI, &event_packet->hdr.oui[0],
sizeof(event_packet->hdr.oui))) sizeof(event_packet->hdr.oui)))
return; return;
......
...@@ -1116,7 +1116,7 @@ static void brcmf_msgbuf_process_event(struct brcmf_msgbuf *msgbuf, void *buf) ...@@ -1116,7 +1116,7 @@ static void brcmf_msgbuf_process_event(struct brcmf_msgbuf *msgbuf, void *buf)
skb->protocol = eth_type_trans(skb, ifp->ndev); skb->protocol = eth_type_trans(skb, ifp->ndev);
brcmf_fweh_process_skb(ifp->drvr, skb); brcmf_fweh_process_skb(ifp->drvr, skb, 0);
exit: exit:
brcmu_pkt_buf_free_skb(skb); brcmu_pkt_buf_free_skb(skb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册