]> git.baikalelectronics.ru Git - kernel.git/commit
nvme-tcp: fix possible data corruption with bio merges
authorSagi Grimberg <sagi@grimberg.me>
Wed, 13 Jan 2021 21:56:57 +0000 (13:56 -0800)
committerChristoph Hellwig <hch@lst.de>
Thu, 14 Jan 2021 19:27:35 +0000 (20:27 +0100)
commit088ce9bffad2d1dfac515d42f57ec297b5d3b651
tree6e7c8cea04747d3c8efc190e8eb3175cc7ee894e
parent04811f8b855a8f5ec506cc8e411ff05d1a5bd1d7
nvme-tcp: fix possible data corruption with bio merges

When a bio merges, we can get a request that spans multiple
bios, and the overall request payload size is the sum of
all bios. When we calculate how much we need to send
from the existing bio (and bvec), we did not take into
account the iov_iter byte count cap.

Since multipage bvecs support, bvecs can split in the middle
which means that when we account for the last bvec send we
should also take the iov_iter byte count cap as it might be
lower than the last bvec size.

Reported-by: Hao Wang <pkuwangh@gmail.com>
Fixes: 1fcf4b8ae898 ("nvme-tcp: add NVMe over TCP host driver")
Tested-by: Hao Wang <pkuwangh@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/tcp.c