Skip to content

Commit aef7a03

Browse files
ppetter1025Kalle Valo
authored andcommitted
wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet
Only skip the code path trying to access the rfc1042 headers when the buffer is too small, so the driver can still process packets without rfc1042 headers. Fixes: 1195852 ("wifi: mwifiex: Fix OOB and integer underflow when rx packets") Signed-off-by: Pin-yen Lin <[email protected]> Acked-by: Brian Norris <[email protected]> Reviewed-by: Matthew Wang <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2e1b3ae commit aef7a03

File tree

1 file changed

+9
-7
lines changed
  • drivers/net/wireless/marvell/mwifiex

1 file changed

+9
-7
lines changed

drivers/net/wireless/marvell/mwifiex/sta_rx.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ int mwifiex_process_rx_packet(struct mwifiex_private *priv,
8686
rx_pkt_len = le16_to_cpu(local_rx_pd->rx_pkt_length);
8787
rx_pkt_hdr = (void *)local_rx_pd + rx_pkt_off;
8888

89-
if (sizeof(*rx_pkt_hdr) + rx_pkt_off > skb->len) {
89+
if (sizeof(rx_pkt_hdr->eth803_hdr) + sizeof(rfc1042_header) +
90+
rx_pkt_off > skb->len) {
9091
mwifiex_dbg(priv->adapter, ERROR,
9192
"wrong rx packet offset: len=%d, rx_pkt_off=%d\n",
9293
skb->len, rx_pkt_off);
@@ -95,12 +96,13 @@ int mwifiex_process_rx_packet(struct mwifiex_private *priv,
9596
return -1;
9697
}
9798

98-
if ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
99-
sizeof(bridge_tunnel_header))) ||
100-
(!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
101-
sizeof(rfc1042_header)) &&
102-
ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP &&
103-
ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX)) {
99+
if (sizeof(*rx_pkt_hdr) + rx_pkt_off <= skb->len &&
100+
((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header,
101+
sizeof(bridge_tunnel_header))) ||
102+
(!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header,
103+
sizeof(rfc1042_header)) &&
104+
ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP &&
105+
ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX))) {
104106
/*
105107
* Replace the 803 header and rfc1042 header (llc/snap) with an
106108
* EthernetII header, keep the src/dst and snap_type

0 commit comments

Comments
 (0)