nbd: Aovid double completion of a request
authorXie Yongji <xieyongji@bytedance.com>
Fri, 13 Aug 2021 15:13:30 +0000 (23:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Aug 2021 06:59:14 +0000 (08:59 +0200)
commite0ee8d9c31b5a670f35a4ff7e2daf59967f2f27a
tree9d03621c3ffd79b411a74de92899927aa275dcbf
parentf5cefe9a52a637f9fc39d05bd70de0d4acb890d6
nbd: Aovid double completion of a request

[ Upstream commit cddce01160582a5f52ada3da9626c052d852ec42 ]

There is a race between iterating over requests in
nbd_clear_que() and completing requests in recv_work(),
which can lead to double completion of a request.

To fix it, flush the recv worker before iterating over
the requests and don't abort the completed request
while iterating.

Fixes: 96d97e17828f ("nbd: clear_sock on netlink disconnect")
Reported-by: Jiang Yadong <jiangyadong@bytedance.com>
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20210813151330.96-1-xieyongji@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/nbd.c