From: Eric Sandeen <sandeen@redhat.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Make the extent validity check more paranoid
Date: Wed, 22 Apr 2009 21:04:30 -0500 [thread overview]
Message-ID: <49EFCCAE.6050602@redhat.com> (raw)
In-Reply-To: <1240450174-25868-1-git-send-email-tytso@mit.edu>
Theodore Ts'o wrote:
> Instead of just checking that the extent block number is greater or
> equal than s_first_data_block, make sure it it is not pointing into
> the block group descriptors, since that is clearly wrong. This helps
> prevent filesystem from getting very badly corrupted in case an extent
> block is corrupted.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Good idea. Maybe we can get our friends with the corrupted fs to run
with these validation patches... I can get this into rawhide at least.
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> ---
> fs/ext4/extents.c | 18 ++++++++++++------
> 1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 6132353..c28ffe2 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -326,11 +326,14 @@ ext4_ext_max_entries(struct inode *inode, int depth)
>
> static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
> {
> - ext4_fsblk_t block = ext_pblock(ext);
> + ext4_fsblk_t block = ext_pblock(ext), valid_block;
> int len = ext4_ext_get_actual_len(ext);
> struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
> - if (unlikely(block < le32_to_cpu(es->s_first_data_block) ||
> - ((block + len) > ext4_blocks_count(es))))
> +
> + valid_block = le32_to_cpu(es->s_first_data_block) +
> + EXT4_SB(inode->i_sb)->s_gdb_count;
> + if (unlikely(block <= valid_block ||
> + ((block + len) > ext4_blocks_count(es))))
> return 0;
> else
> return 1;
> @@ -339,10 +342,13 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
> static int ext4_valid_extent_idx(struct inode *inode,
> struct ext4_extent_idx *ext_idx)
> {
> - ext4_fsblk_t block = idx_pblock(ext_idx);
> + ext4_fsblk_t block = idx_pblock(ext_idx), valid_block;
> struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
> - if (unlikely(block < le32_to_cpu(es->s_first_data_block) ||
> - (block >= ext4_blocks_count(es))))
> +
> + valid_block = le32_to_cpu(es->s_first_data_block) +
> + EXT4_SB(inode->i_sb)->s_gdb_count;
> + if (unlikely(block <= valid_block ||
> + (block >= ext4_blocks_count(es))))
> return 0;
> else
> return 1;
next prev parent reply other threads:[~2009-04-23 2:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-23 1:29 [PATCH] ext4: Make the extent validity check more paranoid Theodore Ts'o
2009-04-23 2:04 ` Eric Sandeen [this message]
2009-04-23 4:19 ` Theodore Tso
2009-04-23 12:52 ` Eric Sandeen
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=49EFCCAE.6050602@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).