]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commit
jbd2: fix race when writing superblock
authorTheodore Ts'o <tytso@mit.edu>
Thu, 14 Feb 2019 21:27:14 +0000 (16:27 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 May 2019 18:55:24 +0000 (20:55 +0200)
commitbbbcc426ef758f357d545f0cbd1573cf2bf5a731
tree9476e0ae79fc1e6f3314eb0504e13ec522ad5cef
parente483ea5d005d86f72773b81fab4edb99541da2d0
jbd2: fix race when writing superblock

BugLink: https://bugs.launchpad.net/bugs/1828410
[ Upstream commit 538bcaa6261b77e71d37f5596c33127c1a3ec3f7 ]

The jbd2 superblock is lockless now, so there is probably a race
condition between writing it so disk and modifing contents of it, which
may lead to checksum error. The following race is the one case that we
have captured.

jbd2                                fsstress
jbd2_journal_commit_transaction
 jbd2_journal_update_sb_log_tail
  jbd2_write_superblock
   jbd2_superblock_csum_set         jbd2_journal_revoke
                                     jbd2_journal_set_features(revork)
                                     modify superblock
   submit_bh(checksum incorrect)

Fix this by locking the buffer head before modifing it.  We always
write the jbd2 superblock after we modify it, so this just means
calling the lock_buffer() a little earlier.

This checksum corruption problem can be reproduced by xfstests
generic/475.

Reported-by: zhangyi (F) <yi.zhang@huawei.com>
Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/jbd2/journal.c