Skip to content

Commit

Permalink
Fix thinko in iov_iter_single_seg_count
Browse files Browse the repository at this point in the history
The branches of the if (i->type & ITER_BVEC) statement in
iov_iter_single_seg_count() are the wrong way around; if ITER_BVEC is
clear then we use i->bvec, when we should be using i->iov.  This fixes
it.

In my case, the symptom that this caused was that a KVM guest doing
filesystem operations on a virtual disk would result in one of qemu's
threads on the host going into an infinite loop in
generic_perform_write().  The loop would hit the copied == 0 case and
call iov_iter_single_seg_count() to reduce the number of bytes to try
to process, but because of the error, iov_iter_single_seg_count()
would just return i->count and the loop made no progress and continued
forever.

Cc: [email protected] # 3.16+
Signed-off-by: Paul Mackerras <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
paulusmack authored and Al Viro committed Nov 13, 2014
1 parent 7e8631e commit ad0eab9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/iov_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,9 @@ size_t iov_iter_single_seg_count(const struct iov_iter *i)
if (i->nr_segs == 1)
return i->count;
else if (i->type & ITER_BVEC)
return min(i->count, i->iov->iov_len - i->iov_offset);
else
return min(i->count, i->bvec->bv_len - i->iov_offset);
else
return min(i->count, i->iov->iov_len - i->iov_offset);
}
EXPORT_SYMBOL(iov_iter_single_seg_count);

Expand Down

0 comments on commit ad0eab9

Please sign in to comment.