aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-10-22 09:21:47 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-11-03 19:07:37 -0500
commit9234f3190bf8b25b11b105191d408ac50a107948 (patch)
treed53dde5cb1cce2ca8e8007e41d33833a6400464c /fs/f2fs
parent2cc221861132e0ca54e3f52d506520ded8520e80 (diff)
f2fs: fix possible data corruption in f2fs_write_begin()
f2fs_write_begin() doesn't initialize the 'dn' variable if the inode has inline data. However it uses its contents to decide whether it should just zero out the page or load data to it. Thus if we are unlucky we can zero out page contents instead of loading inline data into a page. CC: stable@vger.kernel.org CC: Changman Lee <cm224.lee@samsung.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/data.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 973fd7770d56..e3788bd206d8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1017,21 +1017,19 @@ inline_data:
1017 goto out; 1017 goto out;
1018 } 1018 }
1019 1019
1020 if (dn.data_blkaddr == NEW_ADDR) { 1020 if (f2fs_has_inline_data(inode)) {
1021 err = f2fs_read_inline_data(inode, page);
1022 if (err) {
1023 page_cache_release(page);
1024 goto fail;
1025 }
1026 } else if (dn.data_blkaddr == NEW_ADDR) {
1021 zero_user_segment(page, 0, PAGE_CACHE_SIZE); 1027 zero_user_segment(page, 0, PAGE_CACHE_SIZE);
1022 } else { 1028 } else {
1023 if (f2fs_has_inline_data(inode)) { 1029 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
1024 err = f2fs_read_inline_data(inode, page); 1030 READ_SYNC);
1025 if (err) { 1031 if (err)
1026 page_cache_release(page); 1032 goto fail;
1027 goto fail;
1028 }
1029 } else {
1030 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
1031 READ_SYNC);
1032 if (err)
1033 goto fail;
1034 }
1035 1033
1036 lock_page(page); 1034 lock_page(page);
1037 if (unlikely(!PageUptodate(page))) { 1035 if (unlikely(!PageUptodate(page))) {