Skip to content

Commit

Permalink
SUNRPC: Trap RDMA segment overflows
Browse files Browse the repository at this point in the history
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: 7a1cbfa ("svcrdma: Use parsed chunk lists to construct RDMA Writes")
Signed-off-by: Chuck Lever <[email protected]>
  • Loading branch information
chucklever committed Jun 2, 2022
1 parent b6c71c6 commit f012e95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/sunrpc/xprtrdma/svc_rdma_rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@ svc_rdma_build_writes(struct svc_rdma_write_info *info,
unsigned int write_len;
u64 offset;

seg = &info->wi_chunk->ch_segments[info->wi_seg_no];
if (!seg)
if (info->wi_seg_no >= info->wi_chunk->ch_segcount)
goto out_overflow;

seg = &info->wi_chunk->ch_segments[info->wi_seg_no];
write_len = min(remaining, seg->rs_length - info->wi_seg_off);
if (!write_len)
goto out_overflow;
Expand Down

0 comments on commit f012e95

Please sign in to comment.