Skip to content

Commit

Permalink
Fix uioskip crash when skip to end
Browse files Browse the repository at this point in the history
When doing uioskip to skip an iovec to the very end, the current loop
condition will falsely check pass the end of iovec. We fix this checking
uio_iovcnt first.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3806
Closes #3850
  • Loading branch information
tuxoko authored and behlendorf committed Sep 29, 2015
1 parent b815ec3 commit 45838e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions module/zcommon/zfs_uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ uioskip(uio_t *uiop, size_t n)

uiop->uio_skip += n;
if (uiop->uio_segflg != UIO_BVEC) {
while (uiop->uio_skip >= uiop->uio_iov->iov_len) {
while (uiop->uio_iovcnt &&
uiop->uio_skip >= uiop->uio_iov->iov_len) {
uiop->uio_skip -= uiop->uio_iov->iov_len;
uiop->uio_iov++;
uiop->uio_iovcnt--;
}
} else {
while (uiop->uio_skip >= uiop->uio_bvec->bv_len) {
while (uiop->uio_iovcnt &&
uiop->uio_skip >= uiop->uio_bvec->bv_len) {
uiop->uio_skip -= uiop->uio_bvec->bv_len;
uiop->uio_bvec++;
uiop->uio_iovcnt--;
Expand Down

0 comments on commit 45838e3

Please sign in to comment.