diff options
author | Paul Mackerras <paulus@samba.org> | 2014-11-13 04:15:23 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-13 13:28:55 -0500 |
commit | ad0eab9293485d1c06237e9249f6d4dfa3d93d4d (patch) | |
tree | d0153dd69d25cfa259bdadd8b17f79e4d5be7ec5 | |
parent | 7e8631e8b9d4e9f698c09c7e7309c96249180ff9 (diff) |
Fix thinko in iov_iter_single_seg_count
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: stable@vger.kernel.org # 3.16+
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | mm/iov_iter.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/iov_iter.c b/mm/iov_iter.c index eafcf60f6b83..e34a3cb6aad6 100644 --- a/mm/iov_iter.c +++ b/mm/iov_iter.c | |||
@@ -911,9 +911,9 @@ size_t iov_iter_single_seg_count(const struct iov_iter *i) | |||
911 | if (i->nr_segs == 1) | 911 | if (i->nr_segs == 1) |
912 | return i->count; | 912 | return i->count; |
913 | else if (i->type & ITER_BVEC) | 913 | else if (i->type & ITER_BVEC) |
914 | return min(i->count, i->iov->iov_len - i->iov_offset); | ||
915 | else | ||
916 | return min(i->count, i->bvec->bv_len - i->iov_offset); | 914 | return min(i->count, i->bvec->bv_len - i->iov_offset); |
915 | else | ||
916 | return min(i->count, i->iov->iov_len - i->iov_offset); | ||
917 | } | 917 | } |
918 | EXPORT_SYMBOL(iov_iter_single_seg_count); | 918 | EXPORT_SYMBOL(iov_iter_single_seg_count); |
919 | 919 | ||