All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arend Van Spriel <aspriel@gmail.com>
To: Dokyung Song <dokyung.song@gmail.com>, linux-wireless@vger.kernel.org
Cc: Jisoo Jang <jisoo.jang@yonsei.ac.kr>,
	Minsuk Kang <linuxlovemin@yonsei.ac.kr>
Subject: Re: [PATCH] brcmfmac: Fixes potential buffer overflow in 'brcmf_fweh_event_worker'
Date: Thu, 20 Oct 2022 10:39:14 +0200	[thread overview]
Message-ID: <649de84e-6f9a-5c6b-9a94-a7c6462abd1f@gmail.com> (raw)
In-Reply-To: <20221020014907.GA338234@laguna>

On 10/20/2022 3:49 AM, Dokyung Song wrote:
> This patch fixes an intra-object buffer overflow in brcmfmac that occurs
> when the device provides a 'bsscfgidx' equal to or greater than the
> buffer size. The patch adds a check that leads to a safe failure if that
> is the case.
> 
> Found by a modified version of syzkaller.
> 
> UBSAN: array-index-out-of-bounds in drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
> index 52 is out of range for type 'brcmf_if *[16]'
> CPU: 0 PID: 1898 Comm: kworker/0:2 Tainted: G           O      5.14.0+ #132

[...]

> Kernel panic - not syncing: Fatal exception
> 
> Reported-by: Dokyung Song <dokyungs@yonsei.ac.kr>
> Reported-by: Jisoo Jang <jisoo.jang@yonsei.ac.kr>
> Reported-by: Minsuk Kang <linuxlovemin@yonsei.ac.kr>

Not sure what the rules are for using 'Reported-by' tag, but it looks a 
bit odd. I leave it to the wireless maintainer.

Reviewed-by: Arend van Spriel <aspriel@gmail.com>
> Signed-off-by: Dokyung Song <dokyung.song@gmail.com>
> ---
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
> index bc3f4e4edcdf..e035e9c5a1fa 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
> @@ -255,10 +255,15 @@ static void brcmf_fweh_event_worker(struct work_struct *work)
>   			goto event_free;
>   		}
>   
> -		if (event->code == BRCMF_E_TDLS_PEER_EVENT)
> +		if (event->code == BRCMF_E_TDLS_PEER_EVENT) {
>   			ifp = drvr->iflist[0];
> -		else
> +		} else {
> +			if (emsg.bsscfgidx >= BRCMF_MAX_IFS) {
> +				bphy_err(drvr, "invalid bsscfg index: %u\n", emsg.bsscfgidx);
> +				goto event_free;
> +			}

probably better to do the validation before any other handling. So right 
after converting the event message at line 245

https://elixir.bootlin.com/linux/latest/source/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c#L245

>   			ifp = drvr->iflist[emsg.bsscfgidx];
> +		}
>   		err = brcmf_fweh_call_event_handler(drvr, ifp, event->code,
>   						    &emsg, event->data);
>   		if (err) {

  reply	other threads:[~2022-10-20  8:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  1:49 [PATCH] brcmfmac: Fixes potential buffer overflow in 'brcmf_fweh_event_worker' Dokyung Song
2022-10-20  8:39 ` Arend Van Spriel [this message]
2022-10-20  8:41   ` Arend Van Spriel

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=649de84e-6f9a-5c6b-9a94-a7c6462abd1f@gmail.com \
    --to=aspriel@gmail.com \
    --cc=dokyung.song@gmail.com \
    --cc=jisoo.jang@yonsei.ac.kr \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxlovemin@yonsei.ac.kr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.