* [PATCH] fuse: break infinite loop in fuse_fill_write_pages()
@ 2015-09-21 10:02 Roman Gushchin
2015-10-02 11:21 ` Konstantin Khlebnikov
0 siblings, 1 reply; 8+ messages in thread
From: Roman Gushchin @ 2015-09-21 10:02 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: linux-kernel, fuse-devel, Roman Gushchin
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@yandex-team.ru>
Cc: Miklos Szeredi <miklos@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 f523f2f..195476a 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1049,6 +1049,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
flush_dcache_page(page);
+ iov_iter_advance(ii, tmp);
if (!tmp) {
unlock_page(page);
page_cache_release(page);
@@ -1061,7 +1062,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;
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] fuse: break infinite loop in fuse_fill_write_pages()
2015-09-21 10:02 [PATCH] fuse: break infinite loop in fuse_fill_write_pages() Roman Gushchin
@ 2015-10-02 11:21 ` Konstantin Khlebnikov
2015-10-02 19:27 ` [fuse-devel] " Maxim Patlasov
0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khlebnikov @ 2015-10-02 11:21 UTC (permalink / raw)
To: Roman Gushchin
Cc: Miklos Szeredi, Linux Kernel Mailing List, fuse-devel, Al Viro,
Andrew Morton
Bump. Add more peopple in CC.
On Mon, Sep 21, 2015 at 1:02 PM, Roman Gushchin <klamm@yandex-team.ru> wrote:
> 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@yandex-team.ru>
> Cc: Miklos Szeredi <miklos@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 f523f2f..195476a 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1049,6 +1049,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
> tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
> flush_dcache_page(page);
>
> + iov_iter_advance(ii, tmp);
> if (!tmp) {
> unlock_page(page);
> page_cache_release(page);
> @@ -1061,7 +1062,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;
> --
> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [fuse-devel] [PATCH] fuse: break infinite loop in fuse_fill_write_pages()
2015-10-02 11:21 ` Konstantin Khlebnikov
@ 2015-10-02 19:27 ` Maxim Patlasov
2015-10-02 22:04 ` Andrew Morton
0 siblings, 1 reply; 8+ messages in thread
From: Maxim Patlasov @ 2015-10-02 19:27 UTC (permalink / raw)
To: Konstantin Khlebnikov, Roman Gushchin
Cc: fuse-devel, Andrew Morton, Linux Kernel Mailing List, Al Viro,
Miklos Szeredi
On 10/02/2015 04:21 AM, Konstantin Khlebnikov wrote:
> Bump. Add more peopple in CC.
>
> On Mon, Sep 21, 2015 at 1:02 PM, Roman Gushchin <klamm@yandex-team.ru> wrote:
>> 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.
iov_iter_copy_from_user_atomic() eventually calls iterate_iovec(). The
latter silently consumes zero-length iov. So I don't think "iov's first
segment has zero length" can cause infinite loop.
Thanks,
Maxim
>>
>> 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@yandex-team.ru>
>> Cc: Miklos Szeredi <miklos@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 f523f2f..195476a 100644
>> --- a/fs/fuse/file.c
>> +++ b/fs/fuse/file.c
>> @@ -1049,6 +1049,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
>> tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
>> flush_dcache_page(page);
>>
>> + iov_iter_advance(ii, tmp);
>> if (!tmp) {
>> unlock_page(page);
>> page_cache_release(page);
>> @@ -1061,7 +1062,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;
>> --
>> 2.4.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
> ------------------------------------------------------------------------------
> _______________________________________________
> fuse-devel mailing list
> fuse-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fuse-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [fuse-devel] [PATCH] fuse: break infinite loop in fuse_fill_write_pages()
2015-10-02 19:27 ` [fuse-devel] " Maxim Patlasov
@ 2015-10-02 22:04 ` Andrew Morton
2015-10-03 1:58 ` Konstantin Khlebnikov
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2015-10-02 22:04 UTC (permalink / raw)
To: Maxim Patlasov
Cc: Konstantin Khlebnikov, Roman Gushchin, fuse-devel,
Linux Kernel Mailing List, Al Viro, Miklos Szeredi
On Fri, 2 Oct 2015 12:27:45 -0700 Maxim Patlasov <mpatlasov@parallels.com> wrote:
> On 10/02/2015 04:21 AM, Konstantin Khlebnikov wrote:
> > Bump. Add more peopple in CC.
> >
> > On Mon, Sep 21, 2015 at 1:02 PM, Roman Gushchin <klamm@yandex-team.ru> wrote:
> >> 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.
>
> iov_iter_copy_from_user_atomic() eventually calls iterate_iovec(). The
> latter silently consumes zero-length iov. So I don't think "iov's first
> segment has zero length" can cause infinite loop.
I'm suspecting it got stuck because local variable `bytes' is zero, so
the code does `goto again' repeatedly.
Or maybe not. A more complete description of the bug would help.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [fuse-devel] [PATCH] fuse: break infinite loop in fuse_fill_write_pages()
2015-10-02 22:04 ` Andrew Morton
@ 2015-10-03 1:58 ` Konstantin Khlebnikov
2015-10-05 18:37 ` Maxim Patlasov
0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khlebnikov @ 2015-10-03 1:58 UTC (permalink / raw)
To: Andrew Morton
Cc: Maxim Patlasov, Roman Gushchin, fuse-devel,
Linux Kernel Mailing List, Al Viro, Miklos Szeredi
On Sat, Oct 3, 2015 at 1:04 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Fri, 2 Oct 2015 12:27:45 -0700 Maxim Patlasov <mpatlasov@parallels.com> wrote:
>
>> On 10/02/2015 04:21 AM, Konstantin Khlebnikov wrote:
>> > Bump. Add more peopple in CC.
>> >
>> > On Mon, Sep 21, 2015 at 1:02 PM, Roman Gushchin <klamm@yandex-team.ru> wrote:
>> >> 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.
>>
>> iov_iter_copy_from_user_atomic() eventually calls iterate_iovec(). The
>> latter silently consumes zero-length iov. So I don't think "iov's first
>> segment has zero length" can cause infinite loop.
>
> I'm suspecting it got stuck because local variable `bytes' is zero, so
> the code does `goto again' repeatedly.
>
> Or maybe not. A more complete description of the bug would help.
I suspect here is the same scenario like in 124d3b7041f:
Zero-length segmend is followed by segment with invalid address:
iov_iter_fault_in_readable() checks only first segment (zero-length)
iov_iter_copy_from_user_atomic() skips it, fails at second and
returns zero -> goto again without skipping zero-length segment.
Patch calls iov_iter_advance() before goto again: we'll skip zero-length
segment at second iteraction and iov_iter_fault_in_readable() will detect
invalid address.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [fuse-devel] [PATCH] fuse: break infinite loop in fuse_fill_write_pages()
2015-10-03 1:58 ` Konstantin Khlebnikov
@ 2015-10-05 18:37 ` Maxim Patlasov
2015-10-12 13:33 ` [PATCH v2] " Roman Gushchin
0 siblings, 1 reply; 8+ messages in thread
From: Maxim Patlasov @ 2015-10-05 18:37 UTC (permalink / raw)
To: Konstantin Khlebnikov
Cc: Andrew Morton, Roman Gushchin, fuse-devel,
Linux Kernel Mailing List, Al Viro, Miklos Szeredi, fuse-devel,
linux-kernel
On 10/02/2015 06:58 PM, Konstantin Khlebnikov wrote:
> On Sat, Oct 3, 2015 at 1:04 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
>> On Fri, 2 Oct 2015 12:27:45 -0700 Maxim Patlasov <mpatlasov@parallels.com> wrote:
>>
>>> On 10/02/2015 04:21 AM, Konstantin Khlebnikov wrote:
>>>> Bump. Add more peopple in CC.
>>>>
>>>> On Mon, Sep 21, 2015 at 1:02 PM, Roman Gushchin <klamm@yandex-team.ru> wrote:
>>>>> 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.
>>> iov_iter_copy_from_user_atomic() eventually calls iterate_iovec(). The
>>> latter silently consumes zero-length iov. So I don't think "iov's first
>>> segment has zero length" can cause infinite loop.
>> I'm suspecting it got stuck because local variable `bytes' is zero, so
>> the code does `goto again' repeatedly.
>>
>> Or maybe not. A more complete description of the bug would help.
> I suspect here is the same scenario like in 124d3b7041f:
> Zero-length segmend is followed by segment with invalid address:
> iov_iter_fault_in_readable() checks only first segment (zero-length)
> iov_iter_copy_from_user_atomic() skips it, fails at second and
> returns zero -> goto again without skipping zero-length segment.
>
> Patch calls iov_iter_advance() before goto again: we'll skip zero-length
> segment at second iteraction and iov_iter_fault_in_readable() will detect
> invalid address.
Makes sense to me. The patch looks fine.
Thanks,
Maxim
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] fuse: break infinite loop in fuse_fill_write_pages()
2015-10-05 18:37 ` Maxim Patlasov
@ 2015-10-12 13:33 ` Roman Gushchin
2015-11-10 14:41 ` Miklos Szeredi
0 siblings, 1 reply; 8+ messages in thread
From: Roman Gushchin @ 2015-10-12 13:33 UTC (permalink / raw)
Cc: linux-kernel, viro, fuse-devel, Roman Gushchin, Miklos Szeredi,
Andrew Morton, Maxim Patlasov, Konstantin Khlebnikov
I got a report about unkillable task eating CPU. 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"). If zero-length segmend
is followed by segment with invalid address,
iov_iter_fault_in_readable() checks only first segment (zero-length),
iov_iter_copy_from_user_atomic() skips it, fails at second and
returns zero -> goto again without skipping zero-length segment.
Patch calls iov_iter_advance() before goto again: we'll skip zero-length
segment at second iteraction and iov_iter_fault_in_readable() will detect
invalid address.
Special thanks to Konstantin Khlebnikov, who helped a lot with the commit
description.
Signed-off-by: Roman Gushchin <klamm@yandex-team.ru>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Maxim Patlasov <mpatlasov@parallels.com>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Roman Gushchin <klamm@yandex-team.ru>
---
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 f523f2f..195476a 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1049,6 +1049,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
flush_dcache_page(page);
+ iov_iter_advance(ii, tmp);
if (!tmp) {
unlock_page(page);
page_cache_release(page);
@@ -1061,7 +1062,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;
--
2.4.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] fuse: break infinite loop in fuse_fill_write_pages()
2015-10-12 13:33 ` [PATCH v2] " Roman Gushchin
@ 2015-11-10 14:41 ` Miklos Szeredi
0 siblings, 0 replies; 8+ messages in thread
From: Miklos Szeredi @ 2015-11-10 14:41 UTC (permalink / raw)
To: Roman Gushchin
Cc: Kernel Mailing List, Al Viro, fuse-devel, Andrew Morton,
Maxim Patlasov, Konstantin Khlebnikov
On Mon, Oct 12, 2015 at 3:33 PM, Roman Gushchin <klamm@yandex-team.ru> wrote:
> I got a report about unkillable task eating CPU. 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.
Thanks, queued in
git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git for-next
Miklos
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-11-10 14:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-21 10:02 [PATCH] fuse: break infinite loop in fuse_fill_write_pages() Roman Gushchin
2015-10-02 11:21 ` Konstantin Khlebnikov
2015-10-02 19:27 ` [fuse-devel] " Maxim Patlasov
2015-10-02 22:04 ` Andrew Morton
2015-10-03 1:58 ` Konstantin Khlebnikov
2015-10-05 18:37 ` Maxim Patlasov
2015-10-12 13:33 ` [PATCH v2] " Roman Gushchin
2015-11-10 14:41 ` Miklos Szeredi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.