summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorSheng Yong <shengyong1@huawei.com>2018-01-29 19:13:15 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2018-04-08 03:15:33 -0700
commit39575737bb62fc391c8cc8ea5dfea09daed57d5d (patch)
treef0385d7254ad10ee526d375a867c0586011d90a2 /fs
parent7e0e7995ee97a285ca764c854c7e899aecd75949 (diff)
f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET
sb_getblk does not guarantee the buffer head is uptodate. If bh is not uptodate, the data (may be used as boot code) in area before F2FS_SUPER_OFFSET may get corrupted when super block is committed. Signed-off-by: Sheng Yong <shengyong1@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/super.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index aaeba346e9d7..63729184bcc4 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1898,7 +1898,6 @@ static int __f2fs_commit_super(struct buffer_head *bh,
lock_buffer(bh);
if (super)
memcpy(bh->b_data + F2FS_SUPER_OFFSET, super, sizeof(*super));
- set_buffer_uptodate(bh);
set_buffer_dirty(bh);
unlock_buffer(bh);
@@ -2338,7 +2337,7 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
}
/* write back-up superblock first */
- bh = sb_getblk(sbi->sb, sbi->valid_super_block ? 0: 1);
+ bh = sb_bread(sbi->sb, sbi->valid_super_block ? 0 : 1);
if (!bh)
return -EIO;
err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));
@@ -2349,7 +2348,7 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
return err;
/* write current valid superblock */
- bh = sb_getblk(sbi->sb, sbi->valid_super_block);
+ bh = sb_bread(sbi->sb, sbi->valid_super_block);
if (!bh)
return -EIO;
err = __f2fs_commit_super(bh, F2FS_RAW_SUPER(sbi));