From: Mike Christie <michael.christie@oracle.com>
To: Colin Ian King <colin.king@canonical.com>
Cc: Lee Duncan <lduncan@suse.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Manish Rangankar <mrangankar@marvell.com>
Subject: Re: scsi: iscsi: Drop suspend calls from ep_disconnect
Date: Thu, 3 Jun 2021 18:25:37 -0500 [thread overview]
Message-ID: <08f664af-30be-aa4b-aa82-2333650dee06@oracle.com> (raw)
In-Reply-To: <c429f1a3-348d-2cc4-7652-68ea4a63067e@canonical.com>
On 6/3/21 5:25 PM, Colin Ian King wrote:
> Hi,
>
> Static analysis on linux-next with Coverity has found an issue in
> drivers/scsi/qedi/qedi_iscsi.c with the following commit:
>
> commit 27e986289e739d08c1a4861cc3d3ec9b3a60845e
> Author: Mike Christie <michael.christie@oracle.com>
> Date: Tue May 25 13:17:56 2021 -0500
>
> scsi: iscsi: Drop suspend calls from ep_disconnect
>
> The analysis is as follows:
>
> 1662 void qedi_clear_session_ctx(struct iscsi_cls_session *cls_sess)
> 1663 {
> 1664 struct iscsi_session *session = cls_sess->dd_data;
> 1665 struct iscsi_conn *conn = session->leadconn;
>
> deref_ptr: Directly dereferencing pointer conn.
>
> 1666 struct qedi_conn *qedi_conn = conn->dd_data;
> 1667
> 1668 if (iscsi_is_session_online(cls_sess)) {
> Dereference before null check (REVERSE_INULL)
> check_after_deref: Null-checking conn suggests that it may be null,
> but it has already been dereferenced on all paths leading to the check.
>
> 1669 if (conn)
> 1670 iscsi_suspend_queue(conn);
> 1671 qedi_ep_disconnect(qedi_conn->iscsi_ep);
> 1672 }
>
> Pointer conn is being checked to see if it is null, but earlier it has
> been dereferenced on the assignment of qedi_conn. So either conn will
> be null at some point and a null ptr dereference occurs when qedi_conn
> is assigned, or conn can never be null and the conn null check is
> redundant and can be removed.
The analysis is correct.
The bigger problem is that this entire function seems racey with the
normal conn/ep disconnect or shutdown.
Manish, when this function is run iscsid or the in-kernel conn error
cleanup handler can be running right? There is nothing preventing
those from running at the same time?
I think you want to call iscsi_host_remove at the beginning of __qedi_remove.
That will tell userpsace that the host is being removed and libiscsi will
start the session shutdown and removal process. It then waits for the
sessions to be removed. We can then proceed with the other host removal
cleanup, and at the end of __qedi_remove you do the iscsi_host_free
call.
next prev parent reply other threads:[~2021-06-03 23:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 22:25 Colin Ian King
2021-06-03 23:25 ` Mike Christie [this message]
2021-06-03 23:27 ` Mike Christie
2021-06-04 21:48 ` Mike Christie
2021-06-07 11:03 ` [EXT] " Manish Rangankar
2021-06-09 5:33 ` Manish Rangankar
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=08f664af-30be-aa4b-aa82-2333650dee06@oracle.com \
--to=michael.christie@oracle.com \
--cc=colin.king@canonical.com \
--cc=lduncan@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mrangankar@marvell.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
all inboxes | Powered by JetHome®