From: Petros Koutoupis <petros@petroskoutoupis.com>
To: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Finn Thain <fthain@telegraphics.com.au>,
kashyap.desai@avagotech.com, sumit.saxena@avagotech.com,
uday.lingala@avagotech.com, megaraidlinux.pdl@avagotech.com,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH] megaraid: add scsi_cmnd NULL check before use
Date: Wed, 11 May 2016 20:49:51 -0500 [thread overview]
Message-ID: <1463017791.5827.4.camel@petros-ultrathin> (raw)
In-Reply-To: <166e07c6f96724c0d1f972f2a65d0a65@mail.gmail.com>
On Wed, 2016-05-11 at 15:11 +0530, Sumit Saxena wrote:
> > -----Original Message-----
> > From: Petros Koutoupis [mailto:petros@petroskoutoupis.com]
> > Sent: Tuesday, May 10, 2016 2:59 AM
> > To: Sumit Saxena; Dan Carpenter; Finn Thain
> > Cc: kashyap.desai@avagotech.com; sumit.saxena@avagotech.com;
> > uday.lingala@avagotech.com; megaraidlinux.pdl@avagotech.com; linux-
> > scsi@vger.kernel.org
> > Subject: Re: [PATCH] megaraid: add scsi_cmnd NULL check before use
> >
> > On Mon, 2016-05-09 at 15:18 +0530, Sumit Saxena wrote:
> > > >
> > > > -----Original Message-----
> > > > From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> > > > Sent: Monday, May 09, 2016 1:36 PM
> > > > To: Finn Thain
> > > > Cc: Petros Koutoupis; kashyap.desai@avagotech.com;
> > > > sumit.saxena@avagotech.com; uday.lingala@avagotech.com;
> > > > megaraidlinux.pdl@avagotech.com; linux-scsi@vger.kernel.org
> > > > Subject: Re: [PATCH] megaraid: add scsi_cmnd NULL check before use
> > > >
> > > > Smatch doesn't quite catch it because we check "cmd_fusion->scmd"
> > > > for
> > > NULL
> > > >
> > > > then assign "scmd_local = cmd_fusion->scmd;" and dereference
> > > > scmd_local unconditionally...
> > > >
> > > > It does catch part of the bug if you have cross function analysis:
> > > >
> > > > drivers/scsi/megaraid/megaraid_sas_fusion.c:2318
> > > > complete_cmd_fusion()
> > > > error: we previously assumed 'cmd_fusion->scmd' could be null (see
> > > line 2281)
> > > >
> > > >
> > > > But that code was from 2010 so I never reported it to the original
> > > author or the
> > > >
> > > > list.
> > > "cmd_fusion->scmd" should not be NULL if scsi_io_req->Function is set
> > > to MPI2_FUNCTION_SCSI_IO_REQUEST (OR)
> > > MEGASAS_MPI2_FUNCTION_LD_IO_REQUES
> > > (inside these two cases only, cmd_fusion->scmd will be dereferenced).
> > > If cmd_fusion->scmd is NULL for these "scsi_io_req->Function", that
> > > will a BUG and should not continue with other commands processing in
> > > that case.
> > >
> >
> > Sumit,
> >
> > To clarify, a detection of cmd_fusion->scmd being NULL with scsi_io_req-
> > >Function set to MPI2_FUNCTION_SCSI_IO_REQUEST or
> > MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST should instead trigger a
> > BUG() and not attempt to iterate to the next command in the list. Thank
> > you.
>
> Petros,
>
> WARN_ON() can be used in this case. Upstream may have concerns on using
> BUG_ON() and also BUG_ON() won't help in this case. In production
> environment we never encountered this.
>
> Thanks,
> Sumit
> >
> > --
> > Petros
Sumit,
I will resubmit the patch with all the recommendations. Thank you. In case
you are interested, I have a crash file showcasing the error. I can always
provide this outside of this mailing thread.
--
Petros
next prev parent reply other threads:[~2016-05-12 1:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-08 0:40 [PATCH] megaraid: add scsi_cmnd NULL check before use Petros Koutoupis
2016-05-08 3:32 ` Finn Thain
2016-05-08 12:08 ` Petros Koutoupis
2016-05-08 12:22 ` Finn Thain
2016-05-08 16:34 ` Petros Koutoupis
2016-05-09 1:35 ` Julian Calaby
2016-05-09 2:59 ` Petros Koutoupis
2016-05-09 8:05 ` Dan Carpenter
2016-05-09 9:43 ` Dan Carpenter
2016-05-09 9:48 ` Sumit Saxena
2016-05-09 19:29 ` Dan Carpenter
2016-05-09 21:28 ` Petros Koutoupis
2016-05-11 9:41 ` Sumit Saxena
2016-05-12 1:49 ` Petros Koutoupis [this message]
2016-05-12 6:35 ` Dan Carpenter
2016-05-12 12:35 ` Sumit Saxena
2016-05-13 7:43 ` Finn Thain
2016-05-13 7:43 ` Sumit Saxena
2016-05-13 9:25 ` Finn Thain
2016-05-13 23:34 ` Petros Koutoupis
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=1463017791.5827.4.camel@petros-ultrathin \
--to=petros@petroskoutoupis.com \
--cc=dan.carpenter@oracle.com \
--cc=fthain@telegraphics.com.au \
--cc=kashyap.desai@avagotech.com \
--cc=linux-scsi@vger.kernel.org \
--cc=megaraidlinux.pdl@avagotech.com \
--cc=sumit.saxena@avagotech.com \
--cc=sumit.saxena@broadcom.com \
--cc=uday.lingala@avagotech.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