public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Polaris Pi' <pinkperfect2021@gmail.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"amitkarwar@gmail.com" <amitkarwar@gmail.com>,
	"kvalo@kernel.org" <kvalo@kernel.org>,
	"ganapathi017@gmail.com" <ganapathi017@gmail.com>,
	"sharvari.harisangam@nxp.com" <sharvari.harisangam@nxp.com>,
	"huxinming820@gmail.com" <huxinming820@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v5] wifi: mwifiex: Fix OOB and integer underflow when rx packets
Date: Mon, 17 Jul 2023 13:41:58 +0000	[thread overview]
Message-ID: <8aacfa081d3f4bc3a3ea8359e610fa3e@AcuMS.aculab.com> (raw)
In-Reply-To: <20230714120222.3920248-1-pinkperfect2021@gmail.com>

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)


      parent reply	other threads:[~2023-07-17 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 12:02 [PATCH v5] wifi: mwifiex: Fix OOB and integer underflow when rx packets Polaris Pi
2023-07-14 22:12 ` Abhishek Kumar
2023-07-14 22:38   ` Polaris Pi
2023-07-14 22:16 ` Matthew Wang
2023-07-17 13:41 ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8aacfa081d3f4bc3a3ea8359e610fa3e@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=amitkarwar@gmail.com \
    --cc=ganapathi017@gmail.com \
    --cc=huxinming820@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pinkperfect2021@gmail.com \
    --cc=sharvari.harisangam@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox