OSDN Git Service

nvme-tcp: avoid request double completion for concurrent nvme_tcp_timeout
authorChao Leng <lengchao@huawei.com>
Thu, 14 Jan 2021 09:09:26 +0000 (17:09 +0800)
committerChristoph Hellwig <hch@lst.de>
Mon, 18 Jan 2021 17:58:18 +0000 (18:58 +0100)
commit9ebbfe495ecd2e51bc92ac21ed5817c3b9e223ce
tree9f6c7565605aed2003cd1054c29ed86952efb5a3
parent7674073b2ed35ac951a49c425dec6b39d5a57140
nvme-tcp: avoid request double completion for concurrent nvme_tcp_timeout

Each name space has a request queue, if complete request long time,
multi request queues may have time out requests at the same time,
nvme_tcp_timeout will execute concurrently. Multi requests in different
request queues may be queued in the same tcp queue, multi
nvme_tcp_timeout may call nvme_tcp_stop_queue at the same time.
The first nvme_tcp_stop_queue will clear NVME_TCP_Q_LIVE and continue
stopping the tcp queue(cancel io_work), but the others check
NVME_TCP_Q_LIVE is already cleared, and then directly complete the
requests, complete request before the io work is completely canceled may
lead to a use-after-free condition.
Add a multex lock to serialize nvme_tcp_stop_queue.

Signed-off-by: Chao Leng <lengchao@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/tcp.c