[Devel] [PATCH rh7] fuse: break infinite loop in fuse_fill_write_pages()

Maxim Patlasov mpatlasov at virtuozzo.com
Thu Oct 8 17:38:11 PDT 2015


Backport bugfix from LKML. Original patch description:

I got a report about unkillable task eating CPU. Thge further
investigation shows, that the problem is in the fuse_fill_write_pages()
function. If iov's first segment has zero length, we get an infinite
loop, because we never reach iov_iter_advance() call.

Fix this by calling iov_iter_advance() before repeating an attempt to
copy data from userspace.

A similar problem is described in 124d3b7041f ("fix writev regression:
pan hanging unkillable and un-straceable").

Signed-off-by: Roman Gushchin <klamm at yandex-team.ru>
Cc: Miklos Szeredi <miklos at szeredi.hu>
---
 fs/fuse/file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
Backport bugfix from LKML. Original patch description:

I got a report about unkillable task eating CPU. Thge further
investigation shows, that the problem is in the fuse_fill_write_pages()
function. If iov's first segment has zero length, we get an infinite
loop, because we never reach iov_iter_advance() call.

Fix this by calling iov_iter_advance() before repeating an attempt to
copy data from userspace.

A similar problem is described in 124d3b7041f ("fix writev regression:
pan hanging unkillable and un-straceable").

Signed-off-by: Roman Gushchin <klamm at yandex-team.ru>
Cc: Miklos Szeredi <miklos at szeredi.hu>
---
 fs/fuse/file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a5c4125..88e6e46 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1327,6 +1327,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
 
 		mark_page_accessed(page);
 
+		iov_iter_advance(ii, tmp);
 		if (!tmp) {
 			unlock_page(page);
 			page_cache_release(page);
@@ -1339,7 +1340,6 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
 		req->page_descs[req->num_pages].length = tmp;
 		req->num_pages++;
 
-		iov_iter_advance(ii, tmp);
 		count += tmp;
 		pos += tmp;
 		offset += tmp;


More information about the Devel mailing list