]> git.baikalelectronics.ru Git - kernel.git/commit
nvmet: avoid potential UAF in nvmet_req_complete()
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Mon, 6 Mar 2023 01:13:13 +0000 (10:13 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:47 +0000 (13:33 +0100)
commit0d0f279a6333ef750eafbc815f28dcb6c7524d96
tree1814ec400ee54de1537caccb9659a925ead29136
parent057a9b617207b79ab60034bc6ebf4d8bf5bfdfaa
nvmet: avoid potential UAF in nvmet_req_complete()

[ Upstream commit 6da2f576fab497e2fc719837857aefceb54ebb06 ]

An nvme target ->queue_response() operation implementation may free the
request passed as argument. Such implementation potentially could result
in a use after free of the request pointer when percpu_ref_put() is
called in nvmet_req_complete().

Avoid such problem by using a local variable to save the sq pointer
before calling __nvmet_req_complete(), thus avoiding dereferencing the
req pointer after that function call.

Fixes: ffb9618ad11f ("nvmet: add a generic NVMe target")
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/core.c