Skip to contentSkip to conversation

jbd: Fail to load a journal if it is too short

PATCH New Jan Kara 2 participants 3 messages Jul 15, 2009 – Jul 17, 2009 Journalling layer for block devices (JBD2)

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 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.

---
 fs/jbd/journal.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
fs/jbd/journal.c +6 -0
index 737f724..94a64a1 100644
@@ -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;
Signature · 1 line
1.6.0.2
author
#1 lore raw

PATCH 1/1 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.

---
 fs/jbd2/journal.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
fs/jbd2/journal.c +6 -0
index e378cb3..a8a358b 100644
@@ -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;
Signature · 1 line
1.6.0.2
maintainer Applied
#2 lore raw

Re: [PATCH] jbd2: Fail to load a journal if it is too short

Quoted 4 lines · Jan Kara

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.

Thanks, applied.

- Ted