diff options
author | Jan Kara <jack@suse.cz> | 2020-12-16 11:18:39 +0100 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2020-12-22 19:08:46 +0100 |
commit | 05c2c00f3769abb9e323fcaca70d2de0b48af7ba (patch) | |
tree | 503246bd2db7415e5552acbca2126f4a7e2a8c07 /fs/ext4/file.c | |
parent | ext4: drop sync argument of ext4_commit_super() (diff) | |
download | linux-05c2c00f3769abb9e323fcaca70d2de0b48af7ba.tar.xz linux-05c2c00f3769abb9e323fcaca70d2de0b48af7ba.zip |
ext4: protect superblock modifications with a buffer lock
Protect all superblock modifications (including checksum computation)
with a superblock buffer lock. That way we are sure computed checksum
matches current superblock contents (a mismatch could cause checksum
failures in nojournal mode or if an unjournalled superblock update races
with a journalled one). Also we avoid modifying superblock contents
while it is being written out (which can cause DIF/DIX failures if we
are running in nojournal mode).
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20201216101844.22917-4-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/file.c')
-rw-r--r-- | fs/ext4/file.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 3ed8c048fb12..26907d5835d0 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -809,8 +809,11 @@ static int ext4_sample_last_mounted(struct super_block *sb, err = ext4_journal_get_write_access(handle, sbi->s_sbh); if (err) goto out_journal; + lock_buffer(sbi->s_sbh); strlcpy(sbi->s_es->s_last_mounted, cp, sizeof(sbi->s_es->s_last_mounted)); + ext4_superblock_csum_set(sb); + unlock_buffer(sbi->s_sbh); ext4_handle_dirty_super(handle, sb); out_journal: ext4_journal_stop(handle); |