From: Polaris Pi > Sent: 14 July 2023 13:02 > > Make sure mwifiex_process_mgmt_packet and its callers > mwifiex_process_sta_rx_packet and mwifiex_process_uap_rx_packet > not out-of-bounds access the skb->data buffer. > ... > diff --git a/drivers/net/wireless/marvell/mwifiex/sta_rx.c > b/drivers/net/wireless/marvell/mwifiex/sta_rx.c > index 13659b02ba88..88aaec645291 100644 > --- a/drivers/net/wireless/marvell/mwifiex/sta_rx.c > +++ b/drivers/net/wireless/marvell/mwifiex/sta_rx.c > @@ -194,7 +194,8 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_private *priv, > > rx_pkt_hdr = (void *)local_rx_pd + rx_pkt_offset; > > - if ((rx_pkt_offset + rx_pkt_length) > (u16) skb->len) { > + if ((rx_pkt_offset + rx_pkt_length) > (u16)skb->len || > + skb->len - rx_pkt_offset < sizeof(*rx_pkt_hdr)) { What is the (u16) cast for? The domain of both tx_pkt_offset and rx_pkt_length is 16bits. Their sum is of type 'int', masking skb->len to 16 bits just discards high bits (which are probably zero). The second test should probably be: rx_pkt_offset + sizeof(*rx_pkt_hdr) > skb->len although the first test includes the 'offset > len' check. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)