Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp432750imm; Mon, 4 Jun 2018 21:23:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK10swLXzSxZgBintBI3NabdahUkZPXmdUpvJAuEZx1y62W55B8PMdJMGVIJ7012jjTHWV8 X-Received: by 2002:a63:79c5:: with SMTP id u188-v6mr2987755pgc.111.1528172600759; Mon, 04 Jun 2018 21:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528172600; cv=none; d=google.com; s=arc-20160816; b=x9iZ82BAKRfX9KlwoaTMwd/CkGLhOMHpFYY88IUD5eAASzDskwckghKtaHxv7UrLQJ h2OsTLskVDu8YC/WfVIlThx4KESocxOmekOrfYO/xseCFWJGJnXe/18iJpU2546Ob8P5 KkWTHwpcHGY74lg2eUL9YJ2y6guycRuwKZ9kWBrdVhVhSr2gFhBNbmMICFr2U9zBos/B 6oQKz/SKFG3M7H4SGgd7B4Ol6uMrgZtD5Hj77SbQqaexjdFaV8VhVBYkpnr0uXV+8LKu uhI88TYph29Em3m3wf3mpxqzWgU8epJ8VCgSMBlSMXYet5GrJPj2oPO5pNr7B1o5zAzK RLZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature:arc-authentication-results; bh=aP44Q7bEnNH9/y6vG8hzll+BA1J/EaMTG/r5z6W3XcE=; b=ThH5yBr9wjLt20B143fInE9O0IKWgkX3whHpdRG0m5pyj47VzoH4ZYD9BY3ywHQS/k BwmvkXSPpR4GaSVqkpniNDC6JrK6beGlOtonNNJCbHs3mOvpHn7hu9vhVQkluYNgV7gl rIKFNMAPbFy27NkFGoSWd7IOgU2Z/QCkrFnocqEaJF4WohOsNhrv5Q+HNAThHxxRyZi9 AMXzsBnCDvN4B67hBUzVr45NAYczOAyswqoO5IG3oOnrO/LGHTA2IAhrzR7hsPO/GoVz 7Nf4L/CfyF8HMbEtBlXhF+DpWxRNT8sRClcjPtYp0yNpkrX4QKBzmoMZyVophQ/4fvSY mljQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=xNH02ml3; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4-v6si6591958plm.181.2018.06.04.21.22.54; Mon, 04 Jun 2018 21:23:20 -0700 (PDT) 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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=xNH02ml3; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751458AbeFEEWT (ORCPT + 99 others); Tue, 5 Jun 2018 00:22:19 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:35332 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbeFEEWR (ORCPT ); Tue, 5 Jun 2018 00:22:17 -0400 Received: by mail-ot0-f193.google.com with SMTP id q17-v6so1170445otg.2 for ; Mon, 04 Jun 2018 21:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=aP44Q7bEnNH9/y6vG8hzll+BA1J/EaMTG/r5z6W3XcE=; b=xNH02ml34DUCz+k2boku7eI/lALZqyF05589XZ2hX/Qxjg2CMjdLjeRQxe/d9FjMx4 nvOhEwBEx0rip6VAToGqsfyxpHOJk77zpRRfTNJU7x7G0nMg/bznVpm2zKkkEi65rJn1 aeSnJnpFBIqFSAauXcjH7PFPgC39/1ZrS1TaodXmZrWJ19fu8V1I2xJpOsKPGkLfXAYe GzTTqyKodbmX6wnWT0vvCEpGzpKaJvHVne/yMFt6YYEnl12Tbg6/Oak+JL6pHdX2mxgu ZSA+XhiYV1ag3KOX87XVXqj/PS+YuD5DGQDf9i7YFU/8nkFhHcpu+J/VHZyyNbaUzeFh sdLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=aP44Q7bEnNH9/y6vG8hzll+BA1J/EaMTG/r5z6W3XcE=; b=PXv0UzBuKcdR8ITAxhSp3XRxQfDvd8BdGtnEiGp1CJxQXfHjxYOoosLEwxHQuVhRdP i463Ksn9KQFj1N0CVrpNR6jpLjHSYk+ClnFGZOhbv9A6RxsV5o6eb8948dAkCpqgRpuu ByjpWdC9/4RhVjSJP6p/q+prNm/RufarTaLpgm9kpAo9IdXdlPAA+si0Yg8GNFLVlkGq h0OfH8SwXFwnYaDOXMZ2+EY9+1Q4yxT1Xa1QvkD8i4jtCB4VBRr3SE4/wbEyDiEuqRv8 xjB82kHI0GyfTZKT15jryjDAJ61hXc66bkKxnxhw2S1d1mAah2RCvR3/fpSVLTKDORAy W1Yw== X-Gm-Message-State: APt69E1Rt546L0PQykWtVHpao+l82M3POizFElg2OxBDAYF+MvJ3ZptV uWSmT9JISQb2zPwlwUNxdzHnN5uGFhF6aWdWOy9sNg== X-Received: by 2002:a9d:de3:: with SMTP id 90-v6mr17488106ots.117.1528172536865; Mon, 04 Jun 2018 21:22:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2ea9:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 21:22:15 -0700 (PDT) From: Dan Williams Date: Mon, 4 Jun 2018 21:22:15 -0700 Message-ID: Subject: KASAN vs ZONE_DEVICE (was: Re: [PATCH v2 2/7] dax: change bdev_dax_supported()...) To: Dave Chinner Cc: "Darrick J. Wong" , Mike Snitzer , linux-nvdimm , Linux Kernel Mailing List , linux-xfs , device-mapper development , linux-fsdevel , Dmitry Vyukov , Alexander Potapenko , Andrey Ryabinin Content-Type: multipart/mixed; boundary="00000000000037aa32056ddd659f" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --00000000000037aa32056ddd659f Content-Type: text/plain; charset="UTF-8" On Mon, Jun 4, 2018 at 8:32 PM, Dan Williams wrote: > [ adding KASAN devs...] > > On Mon, Jun 4, 2018 at 4:40 PM, Dan Williams wrote: >> On Sun, Jun 3, 2018 at 6:48 PM, Dan Williams wrote: >>> On Sun, Jun 3, 2018 at 5:25 PM, Dave Chinner wrote: >>>> On Mon, Jun 04, 2018 at 08:20:38AM +1000, Dave Chinner wrote: >>>>> On Thu, May 31, 2018 at 09:02:52PM -0700, Dan Williams wrote: >>>>> > On Thu, May 31, 2018 at 7:24 PM, Dave Chinner wrote: >>>>> > > On Thu, May 31, 2018 at 06:57:33PM -0700, Dan Williams wrote: >>>>> > >> > FWIW, XFS+DAX used to just work on this setup (I hadn't even >>>>> > >> > installed ndctl until this morning!) but after changing the kernel >>>>> > >> > it no longer works. That would make it a regression, yes? >>>>> >>>>> [....] >>>>> >>>>> > >> I suspect your kernel does not have CONFIG_ZONE_DEVICE enabled which >>>>> > >> has the following dependencies: >>>>> > >> >>>>> > >> depends on MEMORY_HOTPLUG >>>>> > >> depends on MEMORY_HOTREMOVE >>>>> > >> depends on SPARSEMEM_VMEMMAP >>>>> > > >>>>> > > Filesystem DAX now has a dependency on memory hotplug? >>>>> >>>>> [....] >>>>> >>>>> > > OK, works now I've found the magic config incantantions to turn >>>>> > > everything I now need on. >>>>> >>>>> By enabling these options, my test VM now has a ~30s pause in the >>>>> boot very soon after the nvdimm subsystem is initialised. >>>>> >>>>> [ 1.523718] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled >>>>> [ 1.550353] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A >>>>> [ 1.552175] Non-volatile memory driver v1.3 >>>>> [ 2.332045] tsc: Refined TSC clocksource calibration: 2199.909 MHz >>>>> [ 2.333280] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x1fb5dcd4620, max_idle_ns: 440795264143 ns >>>>> [ 37.217453] brd: module loaded >>>>> [ 37.225423] loop: module loaded >>>>> [ 37.228441] virtio_blk virtio2: [vda] 10485760 512-byte logical blocks (5.37 GB/5.00 GiB) >>>>> [ 37.245418] virtio_blk virtio3: [vdb] 146800640 512-byte logical blocks (75.2 GB/70.0 GiB) >>>>> [ 37.255794] virtio_blk virtio4: [vdc] 1073741824000 512-byte logical blocks (550 TB/500 TiB) >>>>> [ 37.265403] nd_pmem namespace1.0: unable to guarantee persistence of writes >>>>> [ 37.265618] nd_pmem namespace0.0: unable to guarantee persistence of writes >>>>> >>>>> The system does not appear to be consuming CPU, but it is blocking >>>>> NMIs so I can't get a CPU trace. For a VM that I rely on booting in >>>>> a few seconds because I reboot it tens of times a day, this is a >>>>> problem.... >>>> >>>> And when I turn on KASAN, the kernel fails to boot to a login prompt >>>> because: >>> >>> What's your qemu and kernel command line? I'll take look at this first >>> thing tomorrow. >> >> I was able to reproduce this crash by just turning on KASAN... >> investigating. It would still help to have your config for our own >> regression testing purposes it makes sense for us to prioritize >> "Dave's test config", similar to the priority of not breaking Linus' >> laptop. > > I believe this is a bug in KASAN, or a bug in devm_memremap_pages(), > depends on your point of view. At the very least it is a mismatch of > assumptions. KASAN learns of hot added memory via the memory hotplug > notifier. However, the devm_memremap_pages() implementation is > intentionally limited to the "first half" of the memory hotplug > procedure. I.e. it does just enough to setup the linear map for > pfn_to_page() and initialize the "struct page" memmap, but then stops > short of onlining the pages. This is why we are getting a NULL ptr > deref and not a KASAN report, because KASAN has no shadow area setup > for the linearly mapped pmem range. > > In terms of solving it we could refactor kasan_mem_notifier() so that > devm_memremap_pages() can call it outside of the notifier... I'll give > this a shot. Well, the attached patch got me slightly further, but only slightly... [ 14.998394] BUG: KASAN: unknown-crash in pmem_do_bvec+0x19e/0x790 [nd_pmem] [ 15.000006] Read of size 4096 at addr ffff880200000000 by task systemd-udevd/915 [ 15.001991] [ 15.002590] CPU: 15 PID: 915 Comm: systemd-udevd Tainted: G OE 4.17.0-rc5+ #1 982 [ 15.004783] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.1-0-g0551a 4be2c-prebuilt.qemu-project.org 04/01/2014 [ 15.007652] Call Trace: [ 15.008339] dump_stack+0x9a/0xeb [ 15.009344] print_address_description+0x73/0x280 [ 15.010524] kasan_report+0x258/0x380 [ 15.011528] ? pmem_do_bvec+0x19e/0x790 [nd_pmem] [ 15.012747] memcpy+0x1f/0x50 [ 15.013659] pmem_do_bvec+0x19e/0x790 [nd_pmem] ...I've exhausted my limited kasan internals knowledge, any ideas what it's missing? --00000000000037aa32056ddd659f Content-Type: application/octet-stream; name=patch Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_ji16cnvt0 ZGlmZiAtLWdpdCBhL2tlcm5lbC9tZW1yZW1hcC5jIGIva2VybmVsL21lbXJlbWFwLmMKaW5kZXgg ODk1ZTZiNzZiMjVlLi5iNmY0Nzg2NTg3MTkgMTAwNjQ0Ci0tLSBhL2tlcm5lbC9tZW1yZW1hcC5j CisrKyBiL2tlcm5lbC9tZW1yZW1hcC5jCkBAIC0yMCw2ICsyMCwxMCBAQAogI2luY2x1ZGUgPGxp bnV4L3N3YXAuaD4KICNpbmNsdWRlIDxsaW51eC9zd2Fwb3BzLmg+CiAKKy8qIGZvciBtYW51YWxs eSBub3RpZnlpbmcgb2YgbGluZWFyIG1hcCBhZGRpdG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