diff options
author | Jan Kara <jack@suse.cz> | 2009-07-17 10:40:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-14 08:06:02 -0800 |
commit | 34dd3ffe4b57ce9e38ad3258dae5051c7c6a204b (patch) | |
tree | 93c661de46ce944159f6f2e78d4f36bee5a947a5 | |
parent | 4ef61f0aecd7792e7678f29434d1b34860e78280 (diff) |
jbd2: Fail to load a journal if it is too short
(cherry picked from commit f6f50e28f0cb8d7bcdfaacc83129f005dede11b1)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-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 e378cb38397..a8a358bc0f2 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; |