]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvmet-rdma: fix possible bogus dereference under heavy load
authorSagi Grimberg <sagi@grimberg.me>
Mon, 3 Sep 2018 10:47:07 +0000 (03:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Oct 2018 06:56:00 +0000 (08:56 +0200)
commit80b6e9d538463028626ee814ed343fab777adefe
treed5817191a67bbca5eec11d172fd71d21ca7dc01a
parent1d44f7f5bc07127743e9d4a4f968bcbaf3b95ee9
nvmet-rdma: fix possible bogus dereference under heavy load

[ Upstream commit 8407879c4e0d7731f6e7e905893cecf61a7762c7 ]

Currently we always repost the recv buffer before we send a response
capsule back to the host. Since ordering is not guaranteed for send
and recv completions, it is posible that we will receive a new request
from the host before we got a send completion for the response capsule.

Today, we pre-allocate 2x rsps the length of the queue, but in reality,
under heavy load there is nothing that is really preventing the gap to
expand until we exhaust all our rsps.

To fix this, if we don't have any pre-allocated rsps left, we dynamically
allocate a rsp and make sure to free it when we are done. If under memory
pressure we fail to allocate a rsp, we silently drop the command and
wait for the host to retry.

Reported-by: Steve Wise <swise@opengridcomputing.com>
Tested-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
[hch: dropped a superflous assignment]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvme/target/rdma.c