]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.31.8/0003-jbd2-Fail-to-load-a-journal-if-it-is-too-short.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.31.8 / 0003-jbd2-Fail-to-load-a-journal-if-it-is-too-short.patch
CommitLineData
7f041dd7
GKH
1From 558b413137123c701eda6e62d927bff476655e3c Mon Sep 17 00:00:00 2001
2From: Jan Kara <jack@suse.cz>
3Date: Fri, 17 Jul 2009 10:40:01 -0400
4Subject: [PATCH 03/85] jbd2: Fail to load a journal if it is too short
5
6(cherry picked from commit f6f50e28f0cb8d7bcdfaacc83129f005dede11b1)
7
8Due to on disk corruption, it can happen that journal is too short. Fail
9to load it in such case so that we don't oops somewhere later.
10
11Signed-off-by: Jan Kara <jack@suse.cz>
12Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13Signed-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;