* [PATCH] Fix thinko in iov_iter_single_seg_count
@ 2014-11-13 9:15 Paul Mackerras
2014-11-13 13:05 ` Al Viro
0 siblings, 1 reply; 2+ messages in thread
From: Paul Mackerras @ 2014-11-13 9:15 UTC (permalink / raw)
To: Linus Torvalds, Al Viro; +Cc: linux-kernel
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>
---
diff --git a/mm/iov_iter.c b/mm/iov_iter.c
index eafcf60..e34a3cb 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)
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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix thinko in iov_iter_single_seg_count
2014-11-13 9:15 [PATCH] Fix thinko in iov_iter_single_seg_count Paul Mackerras
@ 2014-11-13 13:05 ` Al Viro
0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2014-11-13 13:05 UTC (permalink / raw)
To: Paul Mackerras; +Cc: Linus Torvalds, linux-kernel
On Thu, Nov 13, 2014 at 08:15:23PM +1100, Paul Mackerras wrote:
> 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.
ACK. Applied, will push today.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-13 13:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-13 9:15 [PATCH] Fix thinko in iov_iter_single_seg_count Paul Mackerras
2014-11-13 13:05 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox