]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvme-rdma: fix crash when connect rejected
authorChao Leng <lengchao@huawei.com>
Mon, 12 Oct 2020 08:10:40 +0000 (16:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:08:45 +0000 (11:08 +0100)
commita2631d71e40d1d330729f42b43f6f6f159ef285a
treef2bded15935cd9f6286b0c504425cac4a03731d4
parente6786fd18fe2b91a4844f7d1606c50e09d4cebcf
nvme-rdma: fix crash when connect rejected

[ Upstream commit 43efdb8e870ee0f58633fd579aa5b5185bf5d39e ]

A crash can happened when a connect is rejected.   The host establishes
the connection after received ConnectReply, and then continues to send
the fabrics Connect command.  If the controller does not receive the
ReadyToUse capsule, host may receive a ConnectReject reply.

Call nvme_rdma_destroy_queue_ib after the host received the
RDMA_CM_EVENT_REJECTED event.  Then when the fabrics Connect command
times out, nvme_rdma_timeout calls nvme_rdma_complete_rq to fail the
request.  A crash happenes due to use after free in
nvme_rdma_complete_rq.

nvme_rdma_destroy_queue_ib is redundant when handling the
RDMA_CM_EVENT_REJECTED event as nvme_rdma_destroy_queue_ib is already
called in connection failure handler.

Signed-off-by: Chao Leng <lengchao@huawei.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/rdma.c