From patchwork Mon Oct 27 07:37:09 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hidehiro Kawai X-Patchwork-Id: 5870 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 278A6DDD0B for ; Mon, 27 Oct 2008 18:37:36 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751901AbYJ0Hhe (ORCPT ); Mon, 27 Oct 2008 03:37:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751803AbYJ0Hhe (ORCPT ); Mon, 27 Oct 2008 03:37:34 -0400 Received: from mail9.hitachi.co.jp ([133.145.228.44]:35115 "EHLO mail9.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbYJ0Hhd (ORCPT ); Mon, 27 Oct 2008 03:37:33 -0400 Received: from mlsv6.hitachi.co.jp (unknown [133.144.234.166]) by mail9.hitachi.co.jp (Postfix) with ESMTP id 003BB37C8A; Mon, 27 Oct 2008 16:37:31 +0900 (JST) Received: from MFILTER-S5.hitachi.co.jp by mlsv6.hitachi.co.jp (8.13.1/8.13.1) id m9R7bV6m018355; Mon, 27 Oct 2008 16:37:31 +0900 Received: from vshuts2.hitachi.co.jp (unverified) by MFILTER-S5.hitachi.co.jp (Content Technologies SMTPRS 4.3.17) with ESMTP id ; Mon, 27 Oct 2008 16:37:31 +0900 X-AuditID: 0ac90647-aac4fba00000286d-70-49056fba9b9a Received: from hsdlgw92.sdl.hitachi.co.jp (unknown [133.144.7.20]) by vshuts2.hitachi.co.jp (Symantec Mail Security) with ESMTP id BEF558B01BC; Mon, 27 Oct 2008 16:37:30 +0900 (JST) Received: from vgate2.sdl.hitachi.co.jp by hsdlgw92.sdl.hitachi.co.jp (8.13.1/3.7W06092911) id m9R7bICa025679; Mon, 27 Oct 2008 16:37:29 +0900 Received: from sdl99w.sdl.hitachi.co.jp ([133.144.14.250]) by vgate2.sdl.hitachi.co.jp (SAVSMTP 3.1.1.32) with SMTP id M2008102716372909980; Mon, 27 Oct 2008 16:37:29 +0900 Received: from hitachi.com (IDENT:U2FsdGVkX19MTK5cbsqu3VCThDOKAVCYjnGPN6QiKK4@localhost.localdomain [127.0.0.1]) by sdl99w.sdl.hitachi.co.jp (8.13.1/3.7W04031011) with ESMTP id m9R7b9WF025878; Mon, 27 Oct 2008 16:37:09 +0900 Message-ID: <49056FA5.7070202@hitachi.com> Date: Mon, 27 Oct 2008 16:37:09 +0900 From: Hidehiro Kawai User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: ja MIME-Version: 1.0 To: Theodore Tso , Linus Torvalds Cc: 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: [PATCH 2/2] ext4: fix a bug accessing freed memory in ext4_abort References: <19f34abd0810250422t17990222x78fcf0fad2e6f04b@mail.gmail.com> <49056D29.2010700@hitachi.com> In-Reply-To: <49056D29.2010700@hitachi.com> X-Brightmail-Tracker: AAAAAA== Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- fs/ext4/super.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 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 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);