Skip to content

Commit

Permalink
ext4: annotate data race in start_this_handle()
Browse files Browse the repository at this point in the history
commit 3b1833e upstream.

Access to journal->j_running_transaction is not protected by appropriate
lock and thus is racy. We are well aware of that and the code handles
the race properly. Just add a comment and data_race() annotation.

Cc: stable@kernel.org
Reported-by: syzbot+30774a6acf6a2cf6d535@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20210406161804.20150-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jankara authored and gregkh committed May 12, 2021
1 parent 8cb6d87 commit cfc9b6d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/jbd2/transaction.c
Expand Up @@ -349,7 +349,12 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
}

alloc_transaction:
if (!journal->j_running_transaction) {
/*
* This check is racy but it is just an optimization of allocating new
* transaction early if there are high chances we'll need it. If we
* guess wrong, we'll retry or free unused transaction.
*/
if (!data_race(journal->j_running_transaction)) {
/*
* If __GFP_FS is not present, then we may be being called from
* inside the fs writeback layer, so we MUST NOT fail.
Expand Down

0 comments on commit cfc9b6d

Please sign in to comment.