Update fixes for making ext4 more robust against malicious images
[ext4-patch-queue.git] / jbd2-no-update-tail-after-abort
blob41823208359821f9ed3bc28b4173f03f1708ea45
1 jbd2: if the journal is aborted then don't allow update of the log tail
3 This updates the jbd2 superblock unnecessarily, and on an abort we
4 shouldn't truncate the log.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 Cc: stable@vger.kernel.org
9 ---
10  fs/jbd2/journal.c | 5 ++++-
11  1 file changed, 4 insertions(+), 1 deletion(-)
13 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
14 index efa0c72a0b9f..dfb057900e79 100644
15 --- a/fs/jbd2/journal.c
16 +++ b/fs/jbd2/journal.c
17 @@ -974,7 +974,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
18  }
20  /*
21 - * This is a variaon of __jbd2_update_log_tail which checks for validity of
22 + * This is a variation of __jbd2_update_log_tail which checks for validity of
23   * provided log tail and locks j_checkpoint_mutex. So it is safe against races
24   * with other threads updating log tail.
25   */
26 @@ -1417,6 +1417,9 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
27         journal_superblock_t *sb = journal->j_superblock;
28         int ret;
30 +       if (is_journal_aborted(journal))
31 +               return -EIO;
33         BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
34         jbd_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
35                   tail_block, tail_tid);