Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753151AbYJ0IML (ORCPT ); Mon, 27 Oct 2008 04:12:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751904AbYJ0IL4 (ORCPT ); Mon, 27 Oct 2008 04:11:56 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:33775 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbYJ0ILz (ORCPT ); Mon, 27 Oct 2008 04:11:55 -0400 Date: Mon, 27 Oct 2008 09:11:54 +0100 From: Jan Kara To: Hidehiro Kawai Cc: Theodore Tso , Linus Torvalds , Vegard Nossum , Jan Kara , Stephen Rothwell , Al Viro , linux-ext4@vger.kernel.org, Andrew Morton , "Rafael J. Wysocki" , Ingo Molnar , Pekka Enberg , linux-kernel@vger.kernel.org, sugita , Satoshi OSHIMA Subject: Re: [PATCH 2/2] ext4: fix a bug accessing freed memory in ext4_abort Message-ID: <20081027081154.GC23804@atrey.karlin.mff.cuni.cz> References: <19f34abd0810250422t17990222x78fcf0fad2e6f04b@mail.gmail.com> <49056D29.2010700@hitachi.com> <49056FA5.7070202@hitachi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49056FA5.7070202@hitachi.com> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2044 Lines: 54 > Vegard Nossum reported a bug which accesses freed memory. When > journal has been aborted, ext4_put_super() calls ext4_abort() after > freeing the journal_t object, and then ext4_abort() accesses it. > This patch fix it. > > Signed-off-by: Hidehiro Kawai And this one as well. Acked-by: Jan Kara > --- > fs/ext4/super.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > Index: linux-2.6.28-rc2/fs/ext4/super.c > =================================================================== > --- linux-2.6.28-rc2.orig/fs/ext4/super.c > +++ linux-2.6.28-rc2/fs/ext4/super.c > @@ -333,7 +333,8 @@ void ext4_abort(struct super_block *sb, > EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; > sb->s_flags |= MS_RDONLY; > EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; > - jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); > + if (EXT4_SB(sb)->s_journal) > + jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); > } > > void ext4_warning(struct super_block *sb, const char *function, > @@ -442,14 +443,16 @@ static void ext4_put_super(struct super_ > { > struct ext4_sb_info *sbi = EXT4_SB(sb); > struct ext4_super_block *es = sbi->s_es; > - int i; > + int i, err; > > ext4_mb_release(sb); > ext4_ext_release(sb); > ext4_xattr_put_super(sb); > - if (jbd2_journal_destroy(sbi->s_journal) < 0) > - ext4_abort(sb, __func__, "Couldn't clean up the journal"); > + err = jbd2_journal_destroy(sbi->s_journal); > sbi->s_journal = NULL; > + if (err < 0) > + ext4_abort(sb, __func__, "Couldn't clean up the journal"); > + > if (!(sb->s_flags & MS_RDONLY)) { > EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); > es->s_state = cpu_to_le16(sbi->s_mount_state); > -- Jan Kara SuSE CR Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/