diff mbox

ext4: Fix a possible corruption in dx_probe.

Message ID 1314806452-8763-1-git-send-email-tm@tao.ma
State Rejected, archived
Headers show

Commit Message

Tao Ma Aug. 31, 2011, 4 p.m. UTC
From: Tao Ma <boyu.mt@taobao.com>

For all the callers of dx_probe, frame_in is passed in uninitialized.
So we should set frame->bh to NULL in the beginning of while, not
the end. Otherwise, the first "goto fail2" will try to brelse(frame->bh)
while frame->bh is still invalid.

Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/ext4/namei.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Theodore Ts'o Sept. 4, 2011, 1:57 p.m. UTC | #1
On Thu, Sep 01, 2011 at 12:00:52AM +0800, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> For all the callers of dx_probe, frame_in is passed in uninitialized.
> So we should set frame->bh to NULL in the beginning of while, not
> the end. Otherwise, the first "goto fail2" will try to brelse(frame->bh)
> while frame->bh is still invalid.

There's a "frame->bh = NULL" statement at the very beginning of
dx_probe().   Shouldn't that do the trick?

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tao Ma Sept. 5, 2011, 2:17 a.m. UTC | #2
On 09/04/2011 09:57 PM, Ted Ts'o wrote:
> On Thu, Sep 01, 2011 at 12:00:52AM +0800, Tao Ma wrote:
>> From: Tao Ma <boyu.mt@taobao.com>
>>
>> For all the callers of dx_probe, frame_in is passed in uninitialized.
>> So we should set frame->bh to NULL in the beginning of while, not
>> the end. Otherwise, the first "goto fail2" will try to brelse(frame->bh)
>> while frame->bh is still invalid.
> 
> There's a "frame->bh = NULL" statement at the very beginning of
> dx_probe().   Shouldn't that do the trick?
Oh, sorry for the false alarm.

Thanks
Tao
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index b754b77..86c5c69 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -404,6 +404,7 @@  dx_probe(const struct qstr *d_name, struct inode *dir,
 	dxtrace(printk("Look up %x", hash));
 	while (1)
 	{
+		frame->bh = NULL;
 		count = dx_get_count(entries);
 		if (!count || count > dx_get_limit(entries)) {
 			ext4_warning(dir->i_sb,
@@ -458,7 +459,6 @@  dx_probe(const struct qstr *d_name, struct inode *dir,
 			goto fail2;
 		}
 		frame++;
-		frame->bh = NULL;
 	}
 fail2:
 	while (frame >= frame_in) {