Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1998650imu; Fri, 14 Dec 2018 04:16:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/XHc1lT63kU4nXc3tD0xlHJifkmRDRxWy+uKyVR272PMZRTZx17myfMu8IfzytB7POeSEma X-Received: by 2002:a65:514c:: with SMTP id g12mr2473432pgq.169.1544789799058; Fri, 14 Dec 2018 04:16:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789799; cv=none; d=google.com; s=arc-20160816; b=Z46s5pJMBTAwoAUnnGd/yhA7wF6mIXXkc1sMw2TxL5XwXgVed323QxDaaARyJ1db1X 8YYBGBJUy5l3CjyMoJgHhaKHGezgmF0eV9PzeHAoAKjBZkhrELUgaDxnJohE4lBkhrEN 8LXw6JrhqUKxZTPhzouKtTj0S8Pg+PEuTozs/ZufnKU0ZP3LwrdYftdf/W8MruUphNac jFbxxeVuHOAtduVg7tIQITJmmmf4NPR97NwXrUKRkIqABt79CiURlSnbVr/FddHppXSb BANn+W0czJBhSNzFzO0ISKHekHHH/g3mx1/BFEXTCPBWs1+/IFaxsG7y/lWk94Q5qbD0 pRJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WzvMItWhGag+HLOgocNHCXKZpXUqXVpO4FfsP8rGnuc=; b=azSWuSAxpMZWzKbaUxfj2MWTebN1SfbmfxKK8xabUAXQ/OI0D/NVTvheZjfmDwepi8 hBe5m+iax0hHyfiduF/MUmlv/RB3dmhEyhcMF5HwpnayerpuIfsBhrmiIjZXEWjLUcA5 7aeY1nkk8dZAe4iNdAOd/Ms/tbVHH46Vs9JcI8g8E6RS5E7fL5Sb8deA2oj7hncq/bse bG6BK8tackyk48Ww5OjxAF+zozGWWaqlyaklH05Oj6uP0qSHUQLLOlGwlfwx1fWHuPem swMDajRHiUv0NfkpAPhM6bMXZ+2wUAEeb5nQT7eoxzazri2O8NFXCpQkRwpzIhHzo7uP 0kBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G3VswmCO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g69si4102802pfg.225.2018.12.14.04.16.22; Fri, 14 Dec 2018 04:16:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G3VswmCO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732579AbeLNMPc (ORCPT + 99 others); Fri, 14 Dec 2018 07:15:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:35514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731971AbeLNMPa (ORCPT ); Fri, 14 Dec 2018 07:15:30 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 C42C9214C1; Fri, 14 Dec 2018 12:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789730; bh=wiyMdCrwgYJjHWDxh/E+3HQQVZ+WYViMEUcK/+HT+bY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3VswmCObZ1phtjpOVL56kpSxG4kwrFdHXBiAkK1aYSMSdcM4uvhp6Ge86iaL9Bcs UZ0epEoRwtqDL6nobk8vypHoETJW9ACf9AOdgkLf+txaEYHU6htEsZpHu6486EWy7a /ZFeixCIughLjx7E7lhjqqivyiGZ9H/8T40ZT5TA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Andrew Morton , Joe Perches , "Ernesto A. Fernandez" , Viacheslav Dubeyko , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 35/88] hfs: do not free node before using Date: Fri, 14 Dec 2018 13:00:09 +0100 Message-Id: <20181214115705.066773597@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit ce96a407adef126870b3f4a1b73529dd8aa80f49 ] hfs_bmap_free() frees the node via hfs_bnode_put(node). However, it then reads node->this when dumping error message on an error path, which may result in a use-after-free bug. This patch frees the node only when it is never again used. Link: http://lkml.kernel.org/r/1542963889-128825-1-git-send-email-bianpan2016@163.com Fixes: a1185ffa2fc ("HFS rewrite") Signed-off-by: Pan Bian Reviewed-by: Andrew Morton Cc: Joe Perches Cc: Ernesto A. Fernandez Cc: Viacheslav Dubeyko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/hfs/btree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c index 1ab19e660e69..1ff5774a5382 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -328,13 +328,14 @@ void hfs_bmap_free(struct hfs_bnode *node) nidx -= len * 8; i = node->next; - hfs_bnode_put(node); if (!i) { /* panic */; pr_crit("unable to free bnode %u. bmap not found!\n", node->this); + hfs_bnode_put(node); return; } + hfs_bnode_put(node); node = hfs_bnode_find(tree, i); if (IS_ERR(node)) return; -- 2.19.1