[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99b7bf0e-8a91-492a-bb96-9f5ae7eef416@nvidia.com>
Date: Mon, 10 Jun 2024 04:34:00 +0000
From: Chaitanya Kulkarni <chaitanyak@...dia.com>
To: Alexander Sapozhnikov <alsp705@...il.com>
CC: "linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>,
Chaitanya Kulkarni <chaitanyak@...dia.com>, Sagi Grimberg <sagi@...mberg.me>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Christoph
Hellwig <hch@....de>, "lvc-project@...uxtesting.org"
<lvc-project@...uxtesting.org>
Subject: Re: [PATCH] drivers: nvme: target: core: deref after null
On 6/7/24 06:43, Alexander Sapozhnikov wrote:
> From: Alexandr Sapozhnikov <alsp705@...il.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@...il.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
Powered by blists - more mailing lists