From: Liang He <windhl@126.com>
To: james.smart@broadcom.com, hch@lst.de, sagi@grimberg.me,
kch@nvidia.com, linux-nvme@lists.infradead.org
Cc: windhl@126.com
Subject: [PATCH] nvmet-fc: Fix potential Use-after-free bug in nvmet_fc_delete_target_queue()
Date: Fri, 16 Sep 2022 16:29:53 +0800 [thread overview]
Message-ID: <20220916082953.4095940-1-windhl@126.com> (raw)
In nvmet_fc_delete_target_queue(), the nvmet_fc_tgt_q_put() may free
queue if its refcount hits 0. And the following code will dereference
it to get qclock by 'queue->qlock', so there is a potential UAF bug.
Fixes: 619c62dcc62b ("nvmet-fc: correct ref counting error when deferred rcv used")
Signed-off-by: Liang He <windhl@126.com>
---
drivers/nvme/target/fc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index ab2627e17bb9..32e1d62017d2 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -881,6 +881,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport;
struct nvmet_fc_fcp_iod *fod = queue->fod;
struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr;
+ spinlock_t *q_lock = &queue->qlock;
unsigned long flags;
int i;
bool disconnect;
@@ -942,7 +943,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
kfree(deferfcp);
- spin_lock_irqsave(&queue->qlock, flags);
+ spin_lock_irqsave(q_lock, flags);
}
spin_unlock_irqrestore(&queue->qlock, flags);
--
2.25.1
next reply other threads:[~2022-09-16 8:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 8:29 Liang He [this message]
2022-09-16 18:09 ` [PATCH] nvmet-fc: Fix potential Use-after-free bug in nvmet_fc_delete_target_queue() James Smart
2022-09-19 1:46 ` Liang He
2022-09-19 17:57 ` [PATCH] " James Smart
2022-09-20 12:54 ` Liang He
2022-09-20 15:53 ` James Smart
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=20220916082953.4095940-1-windhl@126.com \
--to=windhl@126.com \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=kch@nvidia.com \
--cc=linux-nvme@lists.infradead.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