From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48770C46470 for ; Mon, 20 May 2019 12:29:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 155AA21479 for ; Mon, 20 May 2019 12:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355350; bh=cuCka6+D/zHu/Ia0WcLVoONDemKDc45zUEKXJ1Ae6fM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Y0IW/ZhWmeUouyd0v6AKtts1zqT+QpYULHM1apfC9aY4zd5anVSeWdoYzEQj5CDnZ IhhaIHk+cis1n4lvK/JQDUkXzl7fILhxs5hmfCWDq/bQiebHoV8p3SeR32gxi7Nbst Pj6XsZsY+iZbSsmErKrle91w0e2aDzpjTDwHw/z0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389232AbfETM3J (ORCPT ); Mon, 20 May 2019 08:29:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:45154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389824AbfETM3J (ORCPT ); Mon, 20 May 2019 08:29:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E18620645; Mon, 20 May 2019 12:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355348; bh=cuCka6+D/zHu/Ia0WcLVoONDemKDc45zUEKXJ1Ae6fM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v38jnpxCpQAZSJpH3i/Qj7PijDUFDTUxLbFEVRjskO5TEflYJAKL6zWdkHSPxKINC +tuMT4qQYYnK1FmZmYmAAFpBgQZAglUuRJi7cpiP3v/PElGdaWuLgsPx5lThzq7o0l r/jgEdS/2QOvQbmFuVSjteISvzJ2YR5aUkMPv1pQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Theodore Tso , Jan Kara , stable@kernel.org Subject: [PATCH 5.0 085/123] ext4: avoid drop reference to iloc.bh twice Date: Mon, 20 May 2019 14:14:25 +0200 Message-Id: <20190520115250.523168314@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pan Bian commit 8c380ab4b7b59c0c602743810be1b712514eaebc upstream. The reference to iloc.bh has been dropped in ext4_mark_iloc_dirty. However, the reference is dropped again if error occurs during ext4_handle_dirty_metadata, which may result in use-after-free bugs. Fixes: fb265c9cb49e("ext4: add ext4_sb_bread() to disambiguate ENOMEM cases") Signed-off-by: Pan Bian Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/resize.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -874,6 +874,7 @@ static int add_new_gdb(handle_t *handle, err = ext4_handle_dirty_metadata(handle, NULL, gdb_bh); if (unlikely(err)) { ext4_std_error(sb, err); + iloc.bh = NULL; goto errout; } brelse(dind);