]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitbf550fd4870f9277fcd4e24d7d351319837b0a19
tree9f6c7565605aed2003cd1054c29ed86952efb5a3
parenta0575a6ab34922b2315c2d3c0c35cb6b209d6ae8
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