From: Jan Kara Date: Wed, 15 Jul 2009 18:36:08 +0000 (+0200) Subject: jbd: Fail to load a journal if it is too short X-Git-Tag: firefly_0821_release~13347^2~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7447a668a3860b66b3c9db86fdea91e355ba59ac;p=firefly-linux-kernel-4.4.55.git jbd: 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. Reported-by: Nageswara R Sastry Signed-off-by: Jan Kara --- diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 737f7246a4b5..94a64a199a63 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -848,6 +848,12 @@ static int journal_reset(journal_t *journal) first = be32_to_cpu(sb->s_first); last = be32_to_cpu(sb->s_maxlen); + if (first + JFS_MIN_JOURNAL_BLOCKS > last + 1) { + printk(KERN_ERR "JBD: Journal too short (blocks %lu-%lu).\n", + first, last); + journal_fail_superblock(journal); + return -EINVAL; + } journal->j_first = first; journal->j_last = last;