]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
nvmet: fix use-after-free when a port is removed
authorIsrael Rukshin <israelr@nvidia.com>
Wed, 6 Oct 2021 08:09:43 +0000 (08:09 +0000)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 7 Dec 2021 06:32:47 +0000 (07:32 +0100)
commitedbd6960a3331fc3b4d9fadd5a14a1c5e68e84a3
treed8205e35cfab1d691b207f721c40ee12bfbaffa1
parentd8877d784664ecc12d06fa0a720c6bfd58c1457a
nvmet: fix use-after-free when a port is removed

BugLink: https://bugs.launchpad.net/bugs/1951822
[ Upstream commit e3e19dcc4c416d65f99f13d55be2b787f8d0050e ]

When a port is removed through configfs, any connected controllers
are starting teardown flow asynchronously and can still send commands.
This causes a use-after-free bug for any command that dereferences
req->port (like in nvmet_parse_io_cmd).

To fix this, wait for all the teardown scheduled works to complete
(like release_work at rdma/tcp drivers). This ensures there are no
active controllers when the port is eventually removed.

Signed-off-by: Israel Rukshin <israelr@nvidia.com>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/nvme/target/configfs.c