SUNRPC: Trap RDMA segment overflows

Prevent svc_rdma_build_writes() from walking off the end of a Write
chunk's segment array. Caught with KASAN.

The test that this fix replaces is invalid, and might have been left
over from an earlier prototype of the PCL work.

Fixes: 7a1cbfa180 ("svcrdma: Use parsed chunk lists to construct RDMA Writes")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Chuck Lever 2022-06-01 12:46:52 -04:00
parent b6c71c66b0
commit f012e95b37

View File

@ -478,10 +478,10 @@ svc_rdma_build_writes(struct svc_rdma_write_info *info,
unsigned int write_len; unsigned int write_len;
u64 offset; u64 offset;
seg = &info->wi_chunk->ch_segments[info->wi_seg_no]; if (info->wi_seg_no >= info->wi_chunk->ch_segcount)
if (!seg)
goto out_overflow; goto out_overflow;
seg = &info->wi_chunk->ch_segments[info->wi_seg_no];
write_len = min(remaining, seg->rs_length - info->wi_seg_off); write_len = min(remaining, seg->rs_length - info->wi_seg_off);
if (!write_len) if (!write_len)
goto out_overflow; goto out_overflow;