• C
    nvme-tcp: avoid request double completion for concurrent nvme_tcp_timeout · eb336f0c
    Chao Leng 提交于
    stable inclusion
    from stable-5.10.14
    commit 82ae0714c344ac707900aacd9805773474059282
    bugzilla: 48051
    
    --------------------------------
    
    [ Upstream commit 9ebbfe49 ]
    
    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: NChao Leng <lengchao@huawei.com>
    Signed-off-by: NChristoph Hellwig <hch@lst.de>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
    eb336f0c
tcp.c 64.4 KB