From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Alexander Sapozhnikov <alsp705@gmail.com>
Cc: "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
Chaitanya Kulkarni <chaitanyak@nvidia.com>,
Sagi Grimberg <sagi@grimberg.me>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] drivers: nvme: target: core: deref after null
Date: Mon, 10 Jun 2024 04:34:00 +0000 [thread overview]
Message-ID: <99b7bf0e-8a91-492a-bb96-9f5ae7eef416@nvidia.com> (raw)
In-Reply-To: <20240607134340.11-1-alsp705@gmail.com>
On 6/7/24 06:43, Alexander Sapozhnikov wrote:
> From: Alexandr Sapozhnikov <alsp705@gmail.com>
>
> After having been compared to a NULL value at core.c:813,
> pointer '(**sq->ctrl).sqs' is dereferenced at core.c:838.
really didn't understand the NULL check mentioned above :-
812 */
813 if (ctrl && ctrl->sqs && ctrl->sqs[0] == sq)
814 nvmet_async_events_failall(ctrl);
from what I know it checks the non NULL ctrl->sqs and then
validates the sq is admin queue before calling failing the async
events ...
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
> ---
> drivers/nvme/target/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index 06f0c587f343..5a67d2bc0c55 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -827,7 +827,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
> */
> ctrl = sq->ctrl;
>
> - if (ctrl) {
> + if (ctrl && ctrl->sqs) {
> /*
> * The teardown flow may take some time, and the host may not
> * send us keep-alive during this period, hence reset the
do we need more fine grained check where ctrl->sqs is actually
accessed :-
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 06f0c587f343..a70cad5a6262 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -835,7 +835,8 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
* controller teardown as a result of a keep-alive
expiration.
*/
ctrl->reset_tbkas = true;
- sq->ctrl->sqs[sq->qid] = NULL;
+ if (sq->ctrl->sqs)
+ sq->ctrl->sqs[sq->qid] = NULL;
nvmet_ctrl_put(ctrl);
sq->ctrl = NULL; /* allows reusing the queue later */
}
-ck
next prev parent reply other threads:[~2024-06-10 4:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-07 13:43 [PATCH] drivers: nvme: target: core: deref after null Alexander Sapozhnikov
2024-06-10 4:34 ` Chaitanya Kulkarni [this message]
2024-06-10 6:54 ` Markus Elfring
2024-06-10 10:02 ` Sagi Grimberg
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=99b7bf0e-8a91-492a-bb96-9f5ae7eef416@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=alsp705@gmail.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=lvc-project@linuxtesting.org \
--cc=sagi@grimberg.me \
/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