From: Tao Ma <tm@tao.ma>
To: linux-ext4@vger.kernel.org
Cc: dan.carpenter@oracle.com, "Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH] ext4: Check extent overflow with the right range.
Date: Mon, 17 Oct 2011 16:45:28 +0800 [thread overview]
Message-ID: <1318841128-4540-1-git-send-email-tm@tao.ma> (raw)
In-Reply-To: <20111017081036.GN30887@longonot.mountain>
From: Tao Ma <boyu.mt@taobao.com>
In 4fd30c033, we move the range check before we change ix to avoid the memory stamp.
But actually we should check against the EXT_MAX_INDEX, not EXT_LAST_INDEX.
So this patch revert the old patch and adds a new check before we setting ix.
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
Ted, since 4fd30c033 is in your dev branch, I am fine to integrate these 2 patches to one.
fs/ext4/extents.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2dff31e..5c48612 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -779,8 +779,8 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
ix = curp->p_idx;
}
- if (unlikely(ix > EXT_LAST_INDEX(curp->p_hdr))) {
- EXT4_ERROR_INODE(inode, "ix > EXT_LAST_INDEX!");
+ if (unlikely(ix > EXT_MAX_INDEX(curp->p_hdr))) {
+ EXT4_ERROR_INODE(inode, "ix > EXT_MAX_INDEX!");
return -EIO;
}
@@ -788,6 +788,11 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
ext4_idx_store_pblock(ix, ptr);
le16_add_cpu(&curp->p_hdr->eh_entries, 1);
+ if (unlikely(ix > EXT_LAST_INDEX(curp->p_hdr))) {
+ EXT4_ERROR_INODE(inode, "ix > EXT_LAST_INDEX!");
+ return -EIO;
+ }
+
err = ext4_ext_dirty(handle, inode, curp);
ext4_std_error(inode->i_sb, err);
--
1.6.3.3.334.g916e1.dirty
next prev parent reply other threads:[~2011-10-17 8:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-17 6:57 corruption on 3.1.0-rc9-next-20111011+ Dan Carpenter
2011-10-17 8:10 ` Dan Carpenter
2011-10-17 8:45 ` Tao Ma [this message]
2011-10-17 9:10 ` [PATCH] ext4: Check extent overflow with the right range Yongqiang Yang
2011-10-17 14:16 ` Ted Ts'o
2011-10-18 2:27 ` Tao Ma
2011-10-18 15:07 ` Ted Ts'o
2011-10-17 8:51 ` corruption on 3.1.0-rc9-next-20111011+ Tao Ma
2011-10-17 9:08 ` Dan Carpenter
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=1318841128-4540-1-git-send-email-tm@tao.ma \
--to=tm@tao.ma \
--cc=dan.carpenter@oracle.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).