Skip to content

Commit f012e95

Browse files
committed
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: 7a1cbfa ("svcrdma: Use parsed chunk lists to construct RDMA Writes") Signed-off-by: Chuck Lever <[email protected]>
1 parent b6c71c6 commit f012e95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/sunrpc/xprtrdma/svc_rdma_rw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,10 @@ svc_rdma_build_writes(struct svc_rdma_write_info *info,
478478
unsigned int write_len;
479479
u64 offset;
480480

481-
seg = &info->wi_chunk->ch_segments[info->wi_seg_no];
482-
if (!seg)
481+
if (info->wi_seg_no >= info->wi_chunk->ch_segcount)
483482
goto out_overflow;
484483

484+
seg = &info->wi_chunk->ch_segments[info->wi_seg_no];
485485
write_len = min(remaining, seg->rs_length - info->wi_seg_off);
486486
if (!write_len)
487487
goto out_overflow;

0 commit comments

Comments
 (0)