[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <E1JjcgO-0004q2-VJ@pomaz-ex.szeredi.hu>
Date: Wed, 09 Apr 2008 17:57:56 +0200
From: Miklos Szeredi <miklos@...redi.hu>
To: akpm@...ux-foundation.org, jens.axboe@...cle.com
CC: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: [patch] fix infinite loop in generic_file_splice_read()
generic_file_splice_read() goes into an infinite loop if it races with
truncation. I've found this with fsx-linux on NFS over fuse.
Perhaps the whole while() loop is bogus, but I can't tell from a
cursory glance at __generic_file_splice_read() if it will return zero
only on EOF, or it can do that for other reasons as well. In the
latter case the loop is obviously needed.
This simplistic patch fixes the issue for me.
Signed-off-by: Miklos Szeredi <mszeredi@...e.cz>
---
fs/splice.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
Index: linux/fs/splice.c
===================================================================
--- linux.orig/fs/splice.c 2008-04-02 13:34:58.000000000 +0200
+++ linux/fs/splice.c 2008-04-09 17:35:06.000000000 +0200
@@ -481,19 +481,20 @@ ssize_t generic_file_splice_read(struct
{
ssize_t spliced;
int ret;
- loff_t isize, left;
-
- isize = i_size_read(in->f_mapping->host);
- if (unlikely(*ppos >= isize))
- return 0;
-
- left = isize - *ppos;
- if (unlikely(left < len))
- len = left;
ret = 0;
spliced = 0;
while (len && !spliced) {
+ loff_t isize, left;
+
+ isize = i_size_read(in->f_mapping->host);
+ if (unlikely(*ppos >= isize))
+ return 0;
+
+ left = isize - *ppos;
+ if (unlikely(left < len))
+ len = left;
+
ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
if (ret < 0)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists