diff options
author | Jan Kara <jack@suse.cz> | 2009-07-17 16:40:01 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-07-17 16:40:01 +0200 |
commit | f6f50e28f0cb8d7bcdfaacc83129f005dede11b1 (patch) | |
tree | f7a0ee7cc686c0687cd4020185265ae0cd29471b /fs | |
parent | ext4: Avoid null pointer dereference when decoding EROFS w/o a journal (diff) | |
download | linux-f6f50e28f0cb8d7bcdfaacc83129f005dede11b1.tar.xz linux-f6f50e28f0cb8d7bcdfaacc83129f005dede11b1.zip |
jbd2: Fail to load a journal if it is too short
Due to on disk corruption, it can happen that journal is too short. Fail
to load it in such case so that we don't oops somewhere later.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jbd2/journal.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index e378cb383979..a8a358bc0f21 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1187,6 +1187,12 @@ static int journal_reset(journal_t *journal) first = be32_to_cpu(sb->s_first); last = be32_to_cpu(sb->s_maxlen); + if (first + JBD2_MIN_JOURNAL_BLOCKS > last + 1) { + printk(KERN_ERR "JBD: Journal too short (blocks %llu-%llu).\n", + first, last); + journal_fail_superblock(journal); + return -EINVAL; + } journal->j_first = first; journal->j_last = last; |