public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation•org>
To: Zhou Qingyang <zhou1615@umn•edu>
Cc: kjlu@umn•edu, Arend van Spriel <aspriel@gmail•com>,
	Franky Lin <franky.lin@broadcom•com>,
	Hante Meuleman <hante.meuleman@broadcom•com>,
	Chi-hsien Lin <chi-hsien.lin@infineon•com>,
	Wright Feng <wright.feng@infineon•com>,
	Chung-hsien Hsu <chung-hsien.hsu@infineon•com>,
	Kalle Valo <kvalo@kernel•org>,
	"David S. Miller" <davem@davemloft•net>,
	Jakub Kicinski <kuba@kernel•org>, Len Baker <len.baker@gmx•com>,
	"Gustavo A. R. Silva" <gustavoars@kernel•org>,
	Shawn Guo <shawn.guo@linaro•org>,
	Hans deGoede <hdegoede@redhat•com>,
	Matthias Brugger <mbrugger@suse•com>,
	linux-wireless@vger•kernel.org,
	brcm80211-dev-list.pdl@broadcom•com,
	SHA-cyfmac-dev-list@infineon•com, netdev@vger•kernel.org,
	linux-kernel@vger•kernel.org
Subject: Re: [PATCH] brcmfmac: Fix a NULL pointer dereference in brcmf_of_probe()
Date: Fri, 28 Jan 2022 11:19:17 +0100	[thread overview]
Message-ID: <YfPDJaPJ89vTuBXA@kroah.com> (raw)
In-Reply-To: <20220124165048.54677-1-zhou1615@umn.edu>

On Tue, Jan 25, 2022 at 12:50:46AM +0800, Zhou Qingyang wrote:
> In brcmf_of_probe(), the return value of devm_kzalloc() is assigned to
> board_type and there is a dereference of it in strcpy() right after
> that. devm_kzalloc() could return NULL on failure of allocation, which
> could lead to NULL pointer dereference.
> 
> Fix this bug by adding a NULL check of board_type.
> 
> This bug was found by a static analyzer.
> 
> Builds with 'make allyesconfig' show no new warnings,
> and our static analyzer no longer warns about this code
> 
> Fixes: 29e354ebeeec ("brcmfmac: Transform compatible string for FW loading")
> Signed-off-by: Zhou Qingyang <zhou1615@umn•edu>
> ---
> The analysis employs differential checking to identify inconsistent 
> security operations (e.g., checks or kfrees) between two code paths 
> and confirms that the inconsistent operations are not recovered in the
> current function or the callers, so they constitute bugs. 
> 
> Note that, as a bug found by static analysis, it can be a false
> positive or hard to trigger. Multiple researchers have cross-reviewed
> the bug.
> 
>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> index 513c7e6421b2..535e8ddeab8d 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
> @@ -80,6 +80,8 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
>  		/* get rid of '/' in the compatible string to be able to find the FW */
>  		len = strlen(tmp) + 1;
>  		board_type = devm_kzalloc(dev, len, GFP_KERNEL);
> +		if (!board_type)
> +			return;
>  		strscpy(board_type, tmp, len);
>  		for (i = 0; i < board_type[i]; i++) {
>  			if (board_type[i] == '/')
> -- 
> 2.25.1
> 

As stated before, umn.edu is still not allowed to contribute to the
Linux kernel.  Please work with your administration to resolve this
issue.


      parent reply	other threads:[~2022-01-28 10:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 16:50 [PATCH] brcmfmac: Fix a NULL pointer dereference in brcmf_of_probe() Zhou Qingyang
2022-01-26 13:44 ` Arend van Spriel
2022-01-28 10:19 ` Greg KH [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=YfPDJaPJ89vTuBXA@kroah.com \
    --to=gregkh@linuxfoundation$(echo .)org \
    --cc=SHA-cyfmac-dev-list@infineon$(echo .)com \
    --cc=aspriel@gmail$(echo .)com \
    --cc=brcm80211-dev-list.pdl@broadcom$(echo .)com \
    --cc=chi-hsien.lin@infineon$(echo .)com \
    --cc=chung-hsien.hsu@infineon$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=franky.lin@broadcom$(echo .)com \
    --cc=gustavoars@kernel$(echo .)org \
    --cc=hante.meuleman@broadcom$(echo .)com \
    --cc=hdegoede@redhat$(echo .)com \
    --cc=kjlu@umn$(echo .)edu \
    --cc=kuba@kernel$(echo .)org \
    --cc=kvalo@kernel$(echo .)org \
    --cc=len.baker@gmx$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-wireless@vger$(echo .)kernel.org \
    --cc=mbrugger@suse$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shawn.guo@linaro$(echo .)org \
    --cc=wright.feng@infineon$(echo .)com \
    --cc=zhou1615@umn$(echo .)edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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