From 3294ec95af7965be835479886d3dbf1002fc552d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 12 Oct 2016 23:21:32 -0400 Subject: [PATCH] add patch fix-incorrect-unlock-on-j_list_lock --- fix-incorrect-unlock-on-j_list_lock | 52 +++++++++++++++++++++++++++++++++++++ series | 1 + timestamps | 7 ++--- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 fix-incorrect-unlock-on-j_list_lock diff --git a/fix-incorrect-unlock-on-j_list_lock b/fix-incorrect-unlock-on-j_list_lock new file mode 100644 index 00000000..3095ceb7 --- /dev/null +++ b/fix-incorrect-unlock-on-j_list_lock @@ -0,0 +1,52 @@ +jbd2: fix incorrect unlock on j_list_lock + +From: Taesoo Kim + +When 'jh->b_transaction == transaction' (asserted by below) + + J_ASSERT_JH(jh, (jh->b_transaction == transaction || ... + +'journal->j_list_lock' will be incorrectly unlocked, since +the the lock is aquired only at the end of if / else-if +statements (missing the else case). + +Signed-off-by: Taesoo Kim +Signed-off-by: Theodore Ts'o +Reviewed-by: Andreas Dilger +Fixes: 6e4862a5bb9d12be87e4ea5d9a60836ebed71d28 +Cc: stable@vger.kernel.org # 3.14+ +--- + fs/jbd2/transaction.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c +index 5f09370..edb7f59 100644 +--- a/fs/jbd2/transaction.c ++++ b/fs/jbd2/transaction.c +@@ -1091,6 +1091,7 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) + JBUFFER_TRACE(jh, "file as BJ_Reserved"); + spin_lock(&journal->j_list_lock); + __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved); ++ spin_unlock(&journal->j_list_lock); + } else if (jh->b_transaction == journal->j_committing_transaction) { + /* first access by this transaction */ + jh->b_modified = 0; +@@ -1098,8 +1099,8 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) + JBUFFER_TRACE(jh, "set next transaction"); + spin_lock(&journal->j_list_lock); + jh->b_next_transaction = transaction; ++ spin_unlock(&journal->j_list_lock); + } +- spin_unlock(&journal->j_list_lock); + jbd_unlock_bh_state(bh); + + /* +-- +2.3.3 + +-- +To unsubscribe from this list: send the line "unsubscribe linux-kernel" in +the body of a message to majordomo@vger.kernel.org +More majordomo info at http://vger.kernel.org/majordomo-info.html +Please read the FAQ at http://www.tux.org/lkml/ + diff --git a/series b/series index dbec60fe..964e51c7 100644 --- a/series +++ b/series @@ -1,6 +1,7 @@ # b67be92feb48 update-logging-style-using-PR_CONT +fix-incorrect-unlock-on-j_list_lock #################################################### # unstable patches diff --git a/timestamps b/timestamps index 22745116..7cf722a7 100755 --- a/timestamps +++ b/timestamps @@ -41,6 +41,7 @@ touch -d @1470933535 avoid-deadlock-while-expanding-inode-size touch -d @1474558786 save-patch touch -d @1475216156 stable-boundary touch -d @1476328373 update-logging-style-using-PR_CONT -touch -d @1476328459 series -touch -d @1476328465 status -touch -d @1476328777 timestamps +touch -d @1476328758 fix-incorrect-unlock-on-j_list_lock +touch -d @1476328798 series +touch -d @1476328805 status +touch -d @1476328883 timestamps -- 2.11.4.GIT