From: Sumit Saxena <sumit.saxena@broadcom.com>
To: Finn Thain <fthain@telegraphics.com.au>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Petros Koutoupis <petros@petroskoutoupis.com>,
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: Fri, 13 May 2016 13:13:45 +0530 [thread overview]
Message-ID: <567011d5ce3abcd2ad1419985750cb79@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1605131459480.7564@nippy.intranet>
> -----Original Message-----
> From: Finn Thain [mailto:fthain@telegraphics.com.au]
> Sent: Friday, May 13, 2016 1:14 PM
> To: Sumit Saxena
> Cc: Dan Carpenter; 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
>
>
> On Thu, 12 May 2016, Sumit Saxena wrote:
>
> > > From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> > >
> > > Also when I'm doing static analysis people always tell me that "that
> > > bug is impossible, trust me." and instead of trusting people I
> > > really wish they would just show me the relevant code that prevents
> > > it from happening.
> >
> > Inside megasas_build_io_fusion() function, driver sets "cmd->scmd"
> > pointer(SCSI command pointer received from SCSI mid layer). Functions
> > called inside megasas_build_io_fusion()(which actually builds frame to
> > be sent to firmware) are setting Function type-
> > MPI2_FUNCTION_SCSI_IO_REQUEST (or)
> MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST.
> > So in case Function type set to any one these two, there must be valid
> > "cmd->scmd".
>
> That doesn't show what prevents the bug. It merely shows that the bug
does not
> always manifest.
>
> For example, you might check whether anything prevents
> megasas_build_io_fusion() from returning before assigning cmd->scmd,
like
> so:
>
> 2112 if (sge_count > instance->max_num_sge) {
> 2113 dev_err(&instance->pdev->dev, "Error. sge_count (0x%x)
> exceeds "
> 2114 "max (0x%x) allowed\n", sge_count,
> 2115 instance->max_num_sge);
> 2116 return 1;
> 2117 }
>
> Another possibility: cmd->io_request->Function is valid yet cmd->scmd is
NULL
> when seen from the interrupt handler if it intervenes between the two
> statements in megasas_return_cmd_fusion():
For IOs returned by above error are not actually fired to firmware so
there will be no interrupt handler called for the same.
Anyways, if anyone has logs pertaining to the failure, please attach..
>
> 180 inline void megasas_return_cmd_fusion(struct megasas_instance
*instance,
> 181 struct megasas_cmd_fusion *cmd)
> 182 {
> 183 cmd->scmd = NULL;
> 184 memset(cmd->io_request, 0, sizeof(struct
> MPI2_RAID_SCSI_IO_REQUEST));
> 185 }
>
> You might want to confirm that locking always prevents that.
>
> OTOH, without an actual backtrace, I too might be reluctant to pursue
this kind
> of speculation.
>
> --
next prev parent reply other threads:[~2016-05-13 7:43 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
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 [this message]
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=567011d5ce3abcd2ad1419985750cb79@mail.gmail.com \
--to=sumit.saxena@broadcom.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=petros@petroskoutoupis.com \
--cc=sumit.saxena@avagotech.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;
as well as URLs for NNTP newsgroup(s).