jbd2: if the journal is aborted then don't allow update of the log tail
authorTheodore Ts'o <tytso@mit.edu>
Mon, 19 Feb 2018 17:22:53 +0000 (12:22 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Apr 2018 07:36:30 +0000 (09:36 +0200)
commit 85e0c4e89c1b864e763c4e3bb15d0b6d501ad5d9 upstream.

This updates the jbd2 superblock unnecessarily, and on an abort we
shouldn't truncate the log.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/jbd2/journal.c

index 7d5ef3bf3f3e06410199e1240243a506b32b50b3..aeaa993d4849f94afaee3955ec03267691a7342d 100644 (file)
@@ -961,7 +961,7 @@ out:
 }
 
 /*
- * This is a variaon of __jbd2_update_log_tail which checks for validity of
+ * This is a variation of __jbd2_update_log_tail which checks for validity of
  * provided log tail and locks j_checkpoint_mutex. So it is safe against races
  * with other threads updating log tail.
  */
@@ -1404,6 +1404,9 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
        journal_superblock_t *sb = journal->j_superblock;
        int ret;
 
+       if (is_journal_aborted(journal))
+               return -EIO;
+
        BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
        jbd_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
                  tail_block, tail_tid);