Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3289304imu; Sat, 24 Nov 2018 01:58:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/W8H/V5q3e2Byhl95HtoEtwF899Re06KgD+H+cAMCJA+yvyn/h6tFNPmc+xEI0x9WA/yVYp X-Received: by 2002:a17:902:b592:: with SMTP id a18mr19661066pls.182.1543053519928; Sat, 24 Nov 2018 01:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543053519; cv=none; d=google.com; s=arc-20160816; b=AMY/NS0BLOGJi48dPQ9sFW6F09G0KRuPM3GTTipiYM8btkD3aXFdvnJCFrGZuX8O+P LAIVrP8ZFtH3k0MQOgtLZSnm+sSe7cUUtxtRGYFo3w/YjDC/npuxs/lUgSdeJNvuSXFi 19GXLVNqvA4dzcsY+8E+ksjKaLtUMhtyPa8TYUyO65Pcry+PkrLJyEvwO2UfGznEMuyv aWWz+iu2yHOA6ETzEvmwCJCGrRyl3KMIVUK5AnuqpuemMTe1CGvUeLnHevOdMWf+YGbX ih9WZJ9GHp91vRGGcWJCRTwUmKhJwgYjWyIxyDjaTlTi5o10vl6CKcnWRsAEZCUKjy5K Pigg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=7J89eZ5fW8/oS2WhaNDIG5+D61MYEvp2nIuYqqeYPZo=; b=CGkJY9xQpUhkjrEzAFjw19vorVHIpnj+Fd0gMpRCOMc9mOEHEYaOOtJqYip8b/DuYK qKWPHr8roePj+HTiYnhNFtO2Cz/SM5GaJid5CW/oeITUQ2FJSOUqx6GuD53bn4Vj+eWw a617uabNObHCoy3Szig6/5wS4JIO8FSfW6BX6cPzT0k4+L5dWTkqOPsY99EZ8KhUyQas vv9+oUE/hBlUGsVGw+ib0VyIL/ptk7u70zKIn6gunn4uJM7+q5G1E9o1UV8rqVekxxsU +ym02dYuvJ7D5cWU2L5y9WzwcsLztO7wPUFHOiOo3fDMwmMmwa4sDRiD7Q7MnWyH9ccL qowA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=fmBaIyev; 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 e125si3648802pfe.14.2018.11.24.01.58.25; Sat, 24 Nov 2018 01:58: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=@163.com header.s=s110527 header.b=fmBaIyev; 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 S1726135AbeKXUpb (ORCPT + 99 others); Sat, 24 Nov 2018 15:45:31 -0500 Received: from m12-13.163.com ([220.181.12.13]:60059 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbeKXUpb (ORCPT ); Sat, 24 Nov 2018 15:45:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=7J89eZ5fW8/oS2WhaN DIG5+D61MYEvp2nIuYqqeYPZo=; b=fmBaIyevuH37KFRuqYQlE+vZXg0cDhTzch E6T+fbPBnm8z5k02XPNduecKKA8HX7k6+IHZiDbBSDGnDB1YGGkQCMzr3lzC1BK1 X7t/umUNcP+CTI3IEl6U91MTU8tWsnUGv8S2wKHMnpDmCEIDn/uCWEW4Zqh+0/B8 MAcUAO/UU= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp9 (Coremail) with SMTP id DcCowAA3zhaAIPlb6G5XBg--.53608S3; Sat, 24 Nov 2018 17:57:25 +0800 (CST) From: Pan Bian To: Andrew Morton , ernesto.mnd.fernandez@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] hfsplus: do not free node before using Date: Sat, 24 Nov 2018 17:57:21 +0800 Message-Id: <1543053441-66942-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DcCowAA3zhaAIPlb6G5XBg--.53608S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr1DCw1xCFy5WF43tF48Xrb_yoWfGFc_Xa 1I9as7t3yrJFZ7JrZxArZ8t3sFgF4rG3s7Ww4xtF1Yk3yjyan8Jr1kZrnYkryfurWYqr15 JrWktry5Ga4UXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0sYFJUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQAIJclSIYSB5fQAAsg Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function hfs_bmap_free frees 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 node only when it is never used. Signed-off-by: Pan Bian --- fs/hfsplus/btree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index 236efe5..66774f4 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c @@ -466,14 +466,15 @@ 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.7.4