linux-stable/fs/jbd2
Theodore Ts'o 9154420173 jbd2: fix race when writing superblock
[ Upstream commit 538bcaa626 ]

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>
2019-04-05 22:33:07 +02:00
..
Kconfig jbd2: remove debug dependency on debug_fs and update Kconfig help text 2013-06-12 23:07:51 -04:00
Makefile
checkpoint.c jbd2: fix use after free in jbd2_log_do_checkpoint() 2018-11-13 11:08:43 -08:00
commit.c jbd2: fix invalid descriptor block checksum 2019-04-05 22:33:00 +02:00
journal.c jbd2: fix race when writing superblock 2019-04-05 22:33:07 +02:00
recovery.c jbd2: clarify bad journal block checksum message 2018-02-18 21:33:13 -05:00
revoke.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
transaction.c jbd2: fix compile warning when using JBUFFER_TRACE 2019-03-23 20:10:06 +01:00