Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 7a1cbfa18059 ("svcrdma: Use parsed chunk lists to construct RDMA Writes")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+2 -2
+2 -2
net/sunrpc/xprtrdma/svc_rdma_rw.c
··· 478 478 unsigned int write_len; 479 479 u64 offset; 480 480 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) 483 482 goto out_overflow; 484 483 484 + seg = &info->wi_chunk->ch_segments[info->wi_seg_no]; 485 485 write_len = min(remaining, seg->rs_length - info->wi_seg_off); 486 486 if (!write_len) 487 487 goto out_overflow;