]>
Commit | Line | Data |
---|---|---|
7f041dd7 GKH |
1 | From 558b413137123c701eda6e62d927bff476655e3c Mon Sep 17 00:00:00 2001 |
2 | From: Jan Kara <jack@suse.cz> | |
3 | Date: Fri, 17 Jul 2009 10:40:01 -0400 | |
4 | Subject: [PATCH 03/85] jbd2: Fail to load a journal if it is too short | |
5 | ||
6 | (cherry picked from commit f6f50e28f0cb8d7bcdfaacc83129f005dede11b1) | |
7 | ||
8 | Due to on disk corruption, it can happen that journal is too short. Fail | |
9 | to load it in such case so that we don't oops somewhere later. | |
10 | ||
11 | Signed-off-by: Jan Kara <jack@suse.cz> | |
12 | Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> | |
13 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
14 | --- | |
15 | fs/jbd2/journal.c | 6 ++++++ | |
16 | 1 file changed, 6 insertions(+) | |
17 | ||
18 | --- a/fs/jbd2/journal.c | |
19 | +++ b/fs/jbd2/journal.c | |
20 | @@ -1187,6 +1187,12 @@ static int journal_reset(journal_t *jour | |
21 | ||
22 | first = be32_to_cpu(sb->s_first); | |
23 | last = be32_to_cpu(sb->s_maxlen); | |
24 | + if (first + JBD2_MIN_JOURNAL_BLOCKS > last + 1) { | |
25 | + printk(KERN_ERR "JBD: Journal too short (blocks %llu-%llu).\n", | |
26 | + first, last); | |
27 | + journal_fail_superblock(journal); | |
28 | + return -EINVAL; | |
29 | + } | |
30 | ||
31 | journal->j_first = first; | |
32 | journal->j_last = last; |