Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2019704imu; Fri, 14 Dec 2018 04:36:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/WI5uHE/VOkb/Z7SkTAyIZYykKFUcNYzu1fkrpEYAjEVnJwLp2tUooeYyeLf81chzn993rQ X-Received: by 2002:a63:3858:: with SMTP id h24mr2495778pgn.300.1544790995377; Fri, 14 Dec 2018 04:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790995; cv=none; d=google.com; s=arc-20160816; b=B9DxTUPqdaj69bjwxyyWnwqcuDVYMCt+zsEpzDvJ9yXf2SKO3ItDUXIvr/Jvv6pnLr MyDTU6AvDU+aSjLS3d9v67sZUl69ql/38laXWOMWF+VMWUBYCMT+T0IVIozyWZbpZVls Eby49wW1c7IcyZQvZhzOHHZOzsOipX8IxIliQCunDaFMLq3Ljq/bdyNwIFewzLM8arR2 qbgtxbXe4wk606sB1t/zAsF4w+upXAaas/OpK4AY/dnE1OykIKAAOgh1ej0sBkwGBZ7O /6VivGvc2ZQspSydBU1mHe2yIPrbA/HrOoRh/0hdACzxXbMr//IGsrkBOXpFogOj/flx AlWQ== 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=akNdGH8yB2N7/dqs861IZ6DyaErGE7+4SOpITm8Hb1E=; b=kqIdneav3i8pTePbvnJp+hK+11vdiH1q1FwhDcNbw+JMaHp9H5BPn4bMonruk8g0k+ /+GjtFP//pnusvdrC9TWC0FkW/PzLxVmXIOgUmEfXMnNuyYNCueT6k0meh6MPg2Hcqnp tN+PJwzC84KmGkeFGoMCb7AXd/U9VYTMZGhODIGbE9grvVucx2tdRGw8CIRklkILCKo9 pMzZmgmq2i48rQWnVjnun4Ds0rnQiwiDS4OhyzvGlhku/z9QZ99rmbNvFhmmkRy1Vbzj r8axOD6nKgck0UJiZUaeElyXXPGSs2dvRAgQ3q4mDy3sj7gcidGvkrWbzU5XUbQpAOMI 12DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="w/OtSJdP"; 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 l30si4018976plg.113.2018.12.14.04.36.16; Fri, 14 Dec 2018 04:36:35 -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="w/OtSJdP"; 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 S1731112AbeLNMHY (ORCPT + 99 others); Fri, 14 Dec 2018 07:07:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:52556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731077AbeLNMHU (ORCPT ); Fri, 14 Dec 2018 07:07:20 -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 74675214C1; Fri, 14 Dec 2018 12:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789239; bh=EhUrk7zXXhMAqfOkEHm4PPxPh1G5SSHaw8CGlPAOB8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w/OtSJdPUpQ9m67jFI83Gvawkv0O/oVg58/GYtlJKw6bVtLMnM5OthgbAa1npM/ml u0JaoTnFu6xyzvQp6T61PUFiBBlhTKIc3oLPAV3yDE4G6Snd3bPFmBF+X6YAfV2j1B nB9ska2TcdNN0v73x2iHDmdC49Qc/hYgJ5szh6CM= 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.19 126/142] hfs: do not free node before using Date: Fri, 14 Dec 2018 13:00:11 +0100 Message-Id: <20181214115752.077848478@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@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.19-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 374b5688e29e..9bdff5e40626 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -329,13 +329,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