fix O_SYNC|O_APPEND syncing the wrong range on write()
It actually goes back to 2004 ([PATCH] Concurrent O_SYNC write support)
when sync_page_range() had been introduced; generic_file_write{,v}() correctly
synced
pos_after_write - written .. pos_after_write - 1
but generic_file_aio_write() synced
pos_before_write .. pos_before_write + written - 1
instead. Which is not the same thing with O_APPEND, obviously.
A couple of years later correct variant had been killed off when
everything switched to use of generic_file_aio_write().
All users of generic_file_aio_write() are affected, and the same bug
has been copied into other instances of ->aio_write().
The fix is trivial; the only subtle point is that generic_write_sync()
ought to be inlined to avoid calculations useless for the majority of
calls.
Signed-off-by:
Al Viro <viro@zeniv.linux.org.uk>
Showing
- fs/cifs/file.c 2 additions, 2 deletionsfs/cifs/file.c
- fs/ext4/file.c 1 addition, 1 deletionfs/ext4/file.c
- fs/ntfs/file.c 1 addition, 1 deletionfs/ntfs/file.c
- fs/sync.c 0 additions, 17 deletionsfs/sync.c
- fs/xfs/xfs_file.c 1 addition, 1 deletionfs/xfs/xfs_file.c
- include/linux/fs.h 7 additions, 1 deletioninclude/linux/fs.h
- mm/filemap.c 2 additions, 2 deletionsmm/filemap.c
Loading
Please register or sign in to comment