]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
nvmet-tcp: fix potential race of tcp socket closing accept_work
authorSagi Grimberg <sagi@grimberg.me>
Fri, 5 Feb 2021 19:47:25 +0000 (11:47 -0800)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 15 Mar 2021 14:09:13 +0000 (15:09 +0100)
commita1a2daf5920f881f24d4029fa33d51980ec37ba7
tree81ef407c68cc0de5e275f40527ee8b60f68be1ea
parent33a2b2c97d4f072de5b6913e5799a94af113f03a
nvmet-tcp: fix potential race of tcp socket closing accept_work

[ Upstream commit 0fbcfb089a3f2f2a731d01f0aec8f7697a849c28 ]

When we accept a TCP connection and allocate an nvmet-tcp queue we should
make sure not to fully establish it or reference it as the connection may
be already closing, which triggers queue release work, which does not
fence against queue establishment.

In order to address such a race, we make sure to check the sk_state and
contain the queue reference to be done underneath the sk_callback_lock
such that the queue release work correctly fences against it.

Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver")
Reported-by: Elad Grupi <elad.grupi@dell.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/nvme/target/tcp.c