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=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 E8D2DC433E2 for ; Wed, 16 Sep 2020 15:00:17 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1304022287 for ; Wed, 16 Sep 2020 15:00:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1304022287 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DE1D713FE81AB; Wed, 16 Sep 2020 08:00:16 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=195.135.220.15; helo=mx2.suse.de; envelope-from=jack@suse.cz; receiver= Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 85B7813FE81A8 for ; Wed, 16 Sep 2020 08:00:14 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3F569AC98; Wed, 16 Sep 2020 15:00:28 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 96E861E12E1; Wed, 16 Sep 2020 17:00:12 +0200 (CEST) Date: Wed, 16 Sep 2020 17:00:12 +0200 From: Jan Kara To: Adrian Huang Subject: Re: [PATCH v2 1/1] dax: Fix stack overflow when mounting fsdax pmem device Message-ID: <20200916150012.GI3607@quack2.suse.cz> References: <20200916133923.31-1-adrianhuang0701@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200916133923.31-1-adrianhuang0701@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Message-ID-Hash: MLYEM3U3YQ4MBJ2FWCFLN6ITAJRVSGXW X-Message-ID-Hash: MLYEM3U3YQ4MBJ2FWCFLN6ITAJRVSGXW X-MailFrom: jack@suse.cz X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: linux-nvdimm@lists.01.org, Coly Li , Jan Kara , Mikulas Patocka , Alasdair Kergon , Mike Snitzer , Adrian Huang X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed 16-09-20 21:39:23, Adrian Huang wrote: > From: Adrian Huang > > When mounting fsdax pmem device, commit 6180bb446ab6 ("dax: fix > detection of dax support for non-persistent memory block devices") > introduces the stack overflow [1][2]. Here is the call path for > mounting ext4 file system: > ext4_fill_super > bdev_dax_supported > __bdev_dax_supported > dax_supported > generic_fsdax_supported > __generic_fsdax_supported > bdev_dax_supported > > The call path leads to the infinite calling loop, so we cannot > call bdev_dax_supported() in __generic_fsdax_supported(). The sanity > checking of the variable 'dax_dev' is moved prior to the two > bdev_dax_pgoff() checks [3][4]. > > [1] https://lists.01.org/hyperkitty/list/linux-nvdimm@lists.01.org/thread/BULZHRILK7N2WS2JVISNF2QZNRQK6JU4/ > [2] https://lists.01.org/hyperkitty/list/linux-nvdimm@lists.01.org/thread/OOZGFY3RNQGTGJJCH52YXCSYIDXMOPXO/ > [3] https://lists.01.org/hyperkitty/list/linux-nvdimm@lists.01.org/message/SMQW2LY3QHPXOAW76RKNSCGG3QJFO7HT/ > [4] https://lists.01.org/hyperkitty/list/linux-nvdimm@lists.01.org/message/7E2X6UGX5RQ2ISGYNAF66VLY5BKBFI4M/ > > Fixes: 6180bb446ab6 ("dax: fix detection of dax support for non-persistent memory block devices") > Cc: Coly Li > Cc: Jan Kara > Cc: Ira Weiny > Cc: John Pittman > Cc: Mikulas Patocka > Cc: Alasdair Kergon > Cc: Mike Snitzer > Signed-off-by: Adrian Huang The patch looks good to me. You can add: Reviewed-by: Jan Kara Honza > --- > v1->v2 > * Remove the checking for the returned value '-EOPNOTSUPP' of > dax_direct_access(). Jan has prepared a patch to address the > issue in dm. > --- > drivers/dax/super.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/dax/super.c b/drivers/dax/super.c > index e5767c83ea23..11d0541e6f8f 100644 > --- a/drivers/dax/super.c > +++ b/drivers/dax/super.c > @@ -85,6 +85,12 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev, > return false; > } > > + if (!dax_dev) { > + pr_debug("%s: error: dax unsupported by block device\n", > + bdevname(bdev, buf)); > + return false; > + } > + > err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff); > if (err) { > pr_info("%s: error: unaligned partition for dax\n", > @@ -100,12 +106,6 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev, > return false; > } > > - if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) { > - pr_debug("%s: error: dax unsupported by block device\n", > - bdevname(bdev, buf)); > - return false; > - } > - > id = dax_read_lock(); > len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); > len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn); > -- > 2.17.1 > -- Jan Kara SUSE Labs, CR _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org