Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5589374imu; Mon, 26 Nov 2018 02:37:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/UkMPwPNwVKY1PK93qDTJd84VWzxleu8ghxdYBeTlGn8G0UapLUd3TkzGM8hGSwyHfLwGPp X-Received: by 2002:a17:902:7791:: with SMTP id o17mr26685507pll.60.1543228645653; Mon, 26 Nov 2018 02:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543228645; cv=none; d=google.com; s=arc-20160816; b=KwR6Bf3FoV5RStGgPGKeBZNqSKKCnYnRrO4VSKX/A6qpqMT5OnOYneXDjbVn9wwBHW uBqm3yVRwCbuKEc9ebdc4Fvv7ze7A5YvZESJzLAMg5UpWMz5PQApq+C2r8tre7lySKYu wzc7JxsvBXxgHuIyMlCcohu+L1VkJwwUbQcVh/Q+JkWCdGBnfncZjnYOQ0lYVqlAE7wF BMFsOu2CPWSToGAfU6dEF6q/1mc+9DdzkstbsnCyHQ0ITk/GDyMGRfXBDyuxwsDts4Yw Prfl1mbdgLtOCgzW/qibWFOxeM7RxAx4b8g1tZMVYfpQBfV3SHMh7w9PDWGPreu5Z1to 8D/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=/lgGfku1gWV1fcLw4wfxQkxc6DWHs5mkrsP+geSG0gU=; b=T5s/PBUu8DwEwwVfSIIJ7B4JM+lU+n+rPVlhXaaQEscU9JxWNgVprVQeqsdpHduP/w zL9dt4UtWqPoco52x9JHyhJdBa1RiFlrcK7cLeRYcENRf5kK4ApMsuOao8ne4leLuqMs 9R5TDgW+q91P/Gs8X7IcKF7W0F6Cy40f+4lCkBNkl0R9I6aaMMx6JpCjPPQ7V5l6YACs k5WRkgVuWUOXO1TjCsuTQ4SBTzENLU2EiSvedAj2xM+RofGuUi5QS9004b/tTq5d9y3Y NxYroYgdRoTuJXplvKHpuPKUmaOZ8DjFR2SF3VrLaJqQcmQ19qj8ZIkPLtNMRrwp3k/4 xIrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=S3VmWlKc; 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 b70si23567380pfe.168.2018.11.26.02.37.10; Mon, 26 Nov 2018 02:37:25 -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=S3VmWlKc; 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 S1726225AbeKZVaP (ORCPT + 99 others); Mon, 26 Nov 2018 16:30:15 -0500 Received: from m12-17.163.com ([220.181.12.17]:43797 "EHLO m12-17.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726176AbeKZVaO (ORCPT ); Mon, 26 Nov 2018 16:30:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=/lgGf ku1gWV1fcLw4wfxQkxc6DWHs5mkrsP+geSG0gU=; b=S3VmWlKco/m+z2ZOAc3uN HjTfSm/+FJRaGqZOMGv2adUlOA9MdCrJRAwWdjzIJaowyy+GE7o2q+1U0CruzcLO k9ntSOvSSCyzIo0T/jF0t4ra8O/ct0ZM42eKQATsq1kAq7bPGjbx6w50oqqeteL8 AraC4DjeMKkluhBJLjb3gI= Received: from bp (unknown [106.120.213.96]) by smtp13 (Coremail) with SMTP id EcCowABnbo6izPtb_mTHBg--.38780S2; Mon, 26 Nov 2018 18:36:18 +0800 (CST) Date: Mon, 26 Nov 2018 18:36:19 +0800 From: PanBian To: Carlos Maiolino Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, Brian Foster , Dave Chinner , linux-kernel@vger.kernel.org Subject: Re: [PATCH] xfs: libxfs: move xfs_perag_put late Message-ID: <20181126103619.GA95394@bp> Reply-To: PanBian References: <1543052660-58625-1-git-send-email-bianpan2016@163.com> <20181126093139.cgojlmtubzuzdb23@hades.usersys.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181126093139.cgojlmtubzuzdb23@hades.usersys.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-CM-TRANSID: EcCowABnbo6izPtb_mTHBg--.38780S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZr1xXF45KrWkZry5Cw1kAFb_yoW3KrXEgr W2qrZ7Cw4vgr4SgF47Wr43XF45KF4UGw48Wr93XFWS934UJw4rC397Grn5Zwn5XrZrtr45 uws8WaykJa429jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnWlk3UUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBUQMLclaD0UQEogAAsN Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 10:31:39AM +0100, Carlos Maiolino wrote: > On Sat, Nov 24, 2018 at 05:44:20PM +0800, Pan Bian wrote: > > The function xfs_alloc_get_freelist calls xfs_perag_put to drop the > > reference. In this case, pag may be released. However, > > pag->pagf_btreeblks is read and write after the put operation. This may > > result in a use-after-free bug. This patch moves the put operation late. > > > > The patch looks reasonable, can you detail more how did you find it? Via code > inspection of you hit this user-after-free in some way? I wrote a tool to check such bugs statically. It first scans the source code to extract paired alloc/free functions. Equipped with such functions, it performs an intra-procedural data flow analysis to detect mismatched alloc/free bugs and use-after-free bugs. Best regards, Pan Bian