From: Douglas Gilbert <dgilbert@interlog.com>
To: Johannes Thumshirn <jthumshirn@suse.de>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: James Bottomley <jejb@linux.vnet.ibm.com>,
Andrey Konovalov <andreyknvl@google.com>,
Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>,
Linux SCSI Mailinglist <linux-scsi@vger.kernel.org>,
Hannes Reinecke <hare@suse.de>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2] scsi: sg: don't return bogus Sg_requests
Date: Wed, 10 May 2017 15:37:56 -0400 [thread overview]
Message-ID: <ec8d85ca-10c6-b857-049d-74fedc55aba7@interlog.com> (raw)
In-Reply-To: <20170510075340.12125-1-jthumshirn@suse.de>
On 2017-05-10 03:53 AM, Johannes Thumshirn wrote:
> If the list search in sg_get_rq_mark() fails to find a valid request, we
> return a bogus element. This then can later lead to a GPF in sg_remove_scat().
>
> So don't return bogus Sg_requests in sg_get_rq_mark() but NULL in case the
> list search doesn't find a valid request.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Doug Gilbert <dgilbert@interlog.com>
> ---
> Changes to v1:
> * Directly return found element within the loop (Hannes)
>
> drivers/scsi/sg.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 0a38ba01b7b4..82c33a6edbea 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -2074,11 +2074,12 @@ sg_get_rq_mark(Sg_fd * sfp, int pack_id)
> if ((1 == resp->done) && (!resp->sg_io_owned) &&
> ((-1 == pack_id) || (resp->header.pack_id == pack_id))) {
> resp->done = 2; /* guard against other readers */
> - break;
> + write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
> + return resp;
> }
> }
> write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
> - return resp;
> + return NULL;
> }
>
> /* always adds to end of list */
>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
next prev parent reply other threads:[~2017-05-10 19:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 7:53 [PATCH v2] scsi: sg: don't return bogus Sg_requests Johannes Thumshirn
2017-05-10 8:03 ` Hannes Reinecke
2017-05-10 19:37 ` Douglas Gilbert [this message]
2017-05-12 3:15 ` Martin K. Petersen
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=ec8d85ca-10c6-b857-049d-74fedc55aba7@interlog.com \
--to=dgilbert@interlog.com \
--cc=andreyknvl@google.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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