From patchwork Mon Oct 27 11:44:31 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hidehiro Kawai X-Patchwork-Id: 5895 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 0E9D3DDDD8 for ; Mon, 27 Oct 2008 22:45:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752371AbYJ0Loq (ORCPT ); Mon, 27 Oct 2008 07:44:46 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752622AbYJ0Loq (ORCPT ); Mon, 27 Oct 2008 07:44:46 -0400 Received: from mail7.hitachi.co.jp ([133.145.228.42]:34955 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752371AbYJ0Lop (ORCPT ); Mon, 27 Oct 2008 07:44:45 -0400 Received: from mlsv4.hitachi.co.jp (unknown [133.144.234.166]) by mail7.hitachi.co.jp (Postfix) with ESMTP id AD69537AC8; Mon, 27 Oct 2008 20:44:43 +0900 (JST) Received: from MFILTER-S3.hitachi.co.jp by mlsv4.hitachi.co.jp (8.13.1/8.13.1) id m9RBih4n009219; Mon, 27 Oct 2008 20:44:43 +0900 Received: from vshuts2.hitachi.co.jp (unverified) by MFILTER-S3.hitachi.co.jp (Content Technologies SMTPRS 4.3.17) with ESMTP id ; Mon, 27 Oct 2008 20:44:42 +0900 X-AuditID: 0ac90647-ab650ba00000286d-da-4905a9aa0b9d Received: from hsdlgw92.sdl.hitachi.co.jp (unknown [133.144.7.20]) by vshuts2.hitachi.co.jp (Symantec Mail Security) with ESMTP id 933488B01F7; Mon, 27 Oct 2008 20:44:42 +0900 (JST) Received: from vgate2.sdl.hitachi.co.jp by hsdlgw92.sdl.hitachi.co.jp (8.13.1/3.7W06092911) id m9RBig8Q030592; Mon, 27 Oct 2008 20:44:42 +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 M2008102720444111299; Mon, 27 Oct 2008 20:44:41 +0900 Received: from hitachi.com (IDENT:U2FsdGVkX1+yijzvKRsv+kyhYDohz/5Rsq8PfuZiLQ8@localhost.localdomain [127.0.0.1]) by sdl99w.sdl.hitachi.co.jp (8.13.1/3.7W04031011) with ESMTP id m9RBiWr6000889; Mon, 27 Oct 2008 20:44:32 +0900 Message-ID: <4905A99F.8000605@hitachi.com> Date: Mon, 27 Oct 2008 20:44:31 +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: Ingo Molnar , Linus Torvalds , Andrew Morton Cc: Theodore Tso , Vegard Nossum , Jan Kara , Stephen Rothwell , Al Viro , linux-ext4@vger.kernel.org, "Rafael J. Wysocki" , Pekka Enberg , linux-kernel@vger.kernel.org, sugita , Satoshi OSHIMA Subject: [PATCH 1/2 take 2] ext3: fix a bug accessing freed memory in ext3_abort References: <19f34abd0810250422t17990222x78fcf0fad2e6f04b@mail.gmail.com> <49056D29.2010700@hitachi.com> <49056FA5.7070202@hitachi.com> <20081027104325.GA13641@elte.hu> In-Reply-To: <20081027104325.GA13641@elte.hu> X-Brightmail-Tracker: AAAAAA== Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Ingo Molnar wrote: > * Hidehiro Kawai wrote: > >>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 > > could you please put the word "kmemcheck" into the commit log? ("found > via kmemcheck" or so) We want to have an easily git-greppable track > record of upstream kernel bugs that were found via kmemcheck. (and > there's already a long list) Ah, OK. I fixed the commit log. Thanks, Subject: [PATCH 1/2] ext3: fix a bug accessing freed memory in ext3_abort Vegard Nossum reported a bug which accesses freed memory (found via kmemcheck). When journal has been aborted, ext3_put_super() calls ext3_abort() after freeing the journal_t object, and then ext3_abort() accesses it. This patch fix it. Signed-off-by: Hidehiro Kawai Acked-by: Jan Kara --- fs/ext3/super.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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/ext3/super.c =================================================================== --- linux-2.6.28-rc2.orig/fs/ext3/super.c +++ linux-2.6.28-rc2/fs/ext3/super.c @@ -281,7 +281,8 @@ void ext3_abort (struct super_block * sb EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; sb->s_flags |= MS_RDONLY; EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; - journal_abort(EXT3_SB(sb)->s_journal, -EIO); + if (EXT3_SB(sb)->s_journal) + journal_abort(EXT3_SB(sb)->s_journal, -EIO); } void ext3_warning (struct super_block * sb, const char * function, @@ -390,11 +391,14 @@ static void ext3_put_super (struct super { struct ext3_sb_info *sbi = EXT3_SB(sb); struct ext3_super_block *es = sbi->s_es; - int i; + int i, err; ext3_xattr_put_super(sb); - if (journal_destroy(sbi->s_journal) < 0) + err = journal_destroy(sbi->s_journal); + sbi->s_journal = NULL; + if (err < 0) ext3_abort(sb, __func__, "Couldn't clean up the journal"); + if (!(sb->s_flags & MS_RDONLY)) { EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); es->s_state = cpu_to_le16(sbi->s_mount_state);