diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-07-01 08:12:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-21 18:19:00 -0700 |
commit | 3cba6eb1c7cd51176b972ae47736d8e7a0720706 (patch) | |
tree | 28ec853cb9bd3fdefd7e8a5f2bf63772295c9fac /fs | |
parent | 76a4f3b621d867ea7e27a1b985d7e1430355fac6 (diff) | |
download | kernel-common-3cba6eb1c7cd51176b972ae47736d8e7a0720706.tar.gz kernel-common-3cba6eb1c7cd51176b972ae47736d8e7a0720706.tar.bz2 kernel-common-3cba6eb1c7cd51176b972ae47736d8e7a0720706.zip |
jbd2: fix theoretical race in jbd2__journal_restart
commit 39c04153fda8c32e85b51c96eb5511a326ad7609 upstream.
Once we decrement transaction->t_updates, if this is the last handle
holding the transaction from closing, and once we release the
t_handle_lock spinlock, it's possible for the transaction to commit
and be released. In practice with normal kernels, this probably won't
happen, since the commit happens in a separate kernel thread and it's
unlikely this could all happen within the space of a few CPU cycles.
On the other hand, with a real-time kernel, this could potentially
happen, so save the tid found in transaction->t_tid before we release
t_handle_lock. It would require an insane configuration, such as one
where the jbd2 thread was set to a very high real-time priority,
perhaps because a high priority real-time thread is trying to read or
write to a file system. But some people who use real-time kernels
have been known to do insane things, including controlling
laser-wielding industrial robots. :-)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jbd2/transaction.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 6075ac03b6d9..f5671271b5ba 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -500,10 +500,10 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask) &transaction->t_outstanding_credits); if (atomic_dec_and_test(&transaction->t_updates)) wake_up(&journal->j_wait_updates); + tid = transaction->t_tid; spin_unlock(&transaction->t_handle_lock); jbd_debug(2, "restarting handle %p\n", handle); - tid = transaction->t_tid; need_to_start = !tid_geq(journal->j_commit_request, tid); read_unlock(&journal->j_state_lock); if (need_to_start) |