linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: linux-ext4@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 1/5] jbd: Fail to load a journal if it is too short
Date: Tue, 21 Jul 2009 12:04:15 +0200	[thread overview]
Message-ID: <1248170659-11771-2-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1248170659-11771-1-git-send-email-jack@suse.cz>

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 <rnsastry@linux.vnet.ibm.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/jbd/journal.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 737f724..94a64a1 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;
-- 
1.6.0.2


  reply	other threads:[~2009-07-21 10:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-21 10:04 [PATCH 0/5] ext3/jbd patches in my patch queue Jan Kara
2009-07-21 10:04 ` Jan Kara [this message]
2009-07-21 16:19   ` [PATCH 1/5] jbd: Fail to load a journal if it is too short Andrew Morton
2009-07-21 16:50     ` Andreas Dilger
2009-07-21 21:35     ` Theodore Tso
2009-07-22  9:52       ` Jan Kara
2009-07-21 10:04 ` [PATCH 2/5] ext3: Fix truncation of symlinks after failed write Jan Kara
2009-07-21 10:04 ` [PATCH 3/5] jbd: Fix a race between checkpointing code and journal_get_write_access() Jan Kara
2009-07-21 10:04 ` [PATCH 4/5] ext3: Get rid of extenddisksize parameter of ext3_get_blocks_handle() Jan Kara
2009-07-21 10:04 ` [PATCH 5/5] jbd: fix race between write_metadata_buffer and get_write_access Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1248170659-11771-2-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).