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)
committerChristoph Hellwig <hch@lst.de>
Wed, 20 Oct 2021 17:16:00 +0000 (19:16 +0200)
commite3e19dcc4c416d65f99f13d55be2b787f8d0050e
tree0abf4cdc025d15b2a16a81042c73e34e84a29f8b
parent2b2af50ae8367b0655e12ccfe6252d5c1d7ae7bf
nvmet: fix use-after-free when a port is removed

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>
drivers/nvme/target/configfs.c