diff options
author | Maxim Patlasov <MPatlasov@parallels.com> | 2013-08-16 15:51:41 +0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-10-01 16:44:53 +0200 |
commit | 2d033eaa0073d276ee6c324dd0ade0c5074a5542 (patch) | |
tree | 1d75adee60456c49cb680210fb85ed0dbd0cd639 /fs/pnode.c | |
parent | 26d614df1da9d7d255686af5d6d4508f77853c01 (diff) | |
download | op-kernel-dev-2d033eaa0073d276ee6c324dd0ade0c5074a5542.zip op-kernel-dev-2d033eaa0073d276ee6c324dd0ade0c5074a5542.tar.gz |
fuse: fix race in fuse_writepages()
The patch fixes a race between ftruncate(2), mmap-ed write and write(2):
1) An user makes a page dirty via mmap-ed write.
2) The user performs shrinking truncate(2) intended to purge the page.
3) Before fuse_do_setattr calls truncate_pagecache, the page goes to
writeback. fuse_writepages_fill attaches a new page to FUSE_WRITE request,
then releases the original page by end_page_writeback and unlock it.
4) fuse_do_setattr completes and successfully returns. Since now, i_mutex
is free.
5) Ordinary write(2) extends i_size back to cover the page. Note that
fuse_send_write_pages do wait for fuse writeback, but for another
page->index.
6) fuse_writepages_fill attaches more pages to the request (if any), then
fuse_writepages_send is eventually called. It is supposed to crop
inarg->size of the request, but it doesn't because i_size has already been
extended back.
Moving end_page_writeback behind fuse_writepages_send guarantees that
__fuse_release_nowrite (called from fuse_do_setattr) will crop inarg->size
of the request before write(2) gets the chance to extend i_size.
Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/pnode.c')
0 files changed, 0 insertions, 0 deletions