Skip to content

Commit ca1ff67

Browse files
sagigrimbergChristoph Hellwig
authored andcommitted
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: 3f2304f ("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>
1 parent ada8317 commit ca1ff67

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/nvme/host/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static inline size_t nvme_tcp_req_cur_offset(struct nvme_tcp_request *req)
201201

202202
static inline size_t nvme_tcp_req_cur_length(struct nvme_tcp_request *req)
203203
{
204-
return min_t(size_t, req->iter.bvec->bv_len - req->iter.iov_offset,
204+
return min_t(size_t, iov_iter_single_seg_count(&req->iter),
205205
req->pdu_len - req->pdu_sent);
206206
}
207207

0 commit comments

Comments
 (0)