ntfs: require page-aligned full-page attribute writes
Hyunchul Lee
maintainerPATCH 1/1 ntfs: require page-aligned full-page attribute writes
__ntfs_inode_non_resident_attr_pwrite() treats count == PAGE_SIZE as proof that the request covers the complete folio. it allocates the folio without reading it and copies at offset zero. That proof is valid only when pos is page aligned.
Signed-off-by Hyunchul Lee <[email protected]>
Cc Marek Wesołowski <[email protected]>
--- fs/ntfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ntfs/inode.c +2 -2
@@ -3720,7 +3720,7 @@ static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi, index = pos >>PAGE_SHIFT ;while (count) { -if (count ==PAGE_SIZE ) { +if (count ==PAGE_SIZE && !offset_in_page (pos)) { folio =__filemap_get_folio (vi->i_mapping, index,FGP_CREAT |FGP_LOCK ,mapping_gfp_mask (mapping));
@@ -3742,7 +3742,7 @@ static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi,folio_wait_writeback (folio); -if (count ==PAGE_SIZE ) { +if (count ==PAGE_SIZE && !offset_in_page (pos)) { offset =0 ; attr_len = count; }else {
Signature · 1 line
2.43.0
Quoted 25 lines · Hyunchul Lee
__ntfs_inode_non_resident_attr_pwrite()treats count ==PAGE_SIZEas proof that the request covers the complete folio. it allocates the folio without reading it and copies at offset zero. That proof is valid only when pos is page aligned.Signed-off-by Hyunchul Lee <[email protected]>Cc Marek Wesołowski <[email protected]>--- fs/ntfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/ntfs/inode.c +1
-1@@ -3720,7 +3720,7 @@ static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi, index = pos >>PAGE_SHIFT ;while (count) { -if (count ==PAGE_SIZE ) { +if (count ==PAGE_SIZE && !offset_in_page (pos)) { folio =__filemap_get_folio (vi->i_mapping, index,FGP_CREAT |FGP_LOCK ,mapping_gfp_mask (mapping));
fs/ntfs/inode.c static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi, · line 3748
Quoted 8 lines
fs/ntfs/inode.c +1
-1@@ -3742,7 +3742,7 @@ static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi,folio_wait_writeback (folio); -if (count ==PAGE_SIZE ) { +if (count ==PAGE_SIZE && !offset_in_page (pos)) { offset =0 ; attr_len = count; }else {
Hi Hyunchul,
Looks good to me.
Reviewed-by Baolin Liu <[email protected]>
Thanks,
Baolin.