linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Zhou Qingyang <zhou1615@umn.edu>
Cc: kjlu@umn.edu, Sathya Prakash <sathya.prakash@broadcom.com>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	Suganath Prabu Subramani  <suganath-prabu.subramani@broadcom.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Nagalakshmi Nandigama <Nagalakshmi.Nandigama@lsi.com>,
	James Bottomley <JBottomley@parallels.com>,
	MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: mpt3sas: FIx a NULL pointer dereference bug in mpt3sas_transport_port_add()
Date: Fri, 28 Jan 2022 11:17:30 +0100	[thread overview]
Message-ID: <YfPCukoJF3e3cqyu@kroah.com> (raw)
In-Reply-To: <20220124172120.62828-1-zhou1615@umn.edu>

On Tue, Jan 25, 2022 at 01:21:20AM +0800, Zhou Qingyang wrote:
> In mpt3sas_transport_port_add(), sas_end_device_alloc() is assigned to rphy
> and there is a dereference of it. sas_end_device_alloc() could return NULL
> on failure of allocation, which could introduce a NULL pointer dereference
> bug.
> 
> The same as sas_expander_alloc().
> 
> Fix this bug by adding a NULL check of rphy.
> 
> 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: f92363d12359 ("mpt3sas: add new driver supporting 12GB SAS")
> 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/scsi/mpt3sas/mpt3sas_transport.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c
> index 0681daee6c14..1caa929cf8bc 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c
> @@ -823,6 +823,11 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle,
>  			hba_port->sas_address =
>  			    mpt3sas_port->remote_identify.sas_address;
>  	}
> +	if (!rphy) {
> +		ioc_err(ioc, "failure at %s:%d/%s()!\n",
> +			__FILE__, __LINE__, __func__);
> +		goto out_fail;
> +	}
>  
>  	rphy->identify = mpt3sas_port->remote_identify;
>  
> -- 
> 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.


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 17:21 [PATCH] scsi: mpt3sas: FIx a NULL pointer dereference bug in mpt3sas_transport_port_add() Zhou Qingyang
2022-01-28 10:17 ` 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=YfPCukoJF3e3cqyu@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=JBottomley@parallels.com \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=Nagalakshmi.Nandigama@lsi.com \
    --cc=jejb@linux.ibm.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    --cc=zhou1615@umn.edu \
    /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;
as well as URLs for NNTP newsgroup(s).