From patchwork Tue May 22 14:40:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10418785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 55E4F60224 for ; Tue, 22 May 2018 14:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 446E928F1D for ; Tue, 22 May 2018 14:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 413C228EEF; Tue, 22 May 2018 14:50:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E31E28E3A for ; Tue, 22 May 2018 14:50:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9FA76B000D; Tue, 22 May 2018 10:50:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E78156B000E; Tue, 22 May 2018 10:50:07 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D903D6B0010; Tue, 22 May 2018 10:50:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 8B1AB6B000D for ; Tue, 22 May 2018 10:50:07 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id bd7-v6so12291436plb.20 for ; Tue, 22 May 2018 07:50:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=/qsMFmy3ICmwBuCYG6RW4PGQhlYealfmqA2bX7lTmCM=; b=JXzv23puCH51Sb3omj+77bp/ZvKCAsiVb9+2yf0N5/ybSLInZIzzo/mOqdTpFkR2VH 83PM9AUVwJg2WZVUv/NLTaKCny7gMO4Fu+NkahshSFgWTt+XqiSdOWcg5L+v6+fXSPDE LQSbaNbPE3+OYqKojbAOVwYL47stNuxmpZJxc1olJDoGwmZUKf/L+kmvbsAWGBqqft5x 1h2/5ae0KyZF9ONQKYNjiTuTVmaJJyEDRdGdTOrHtNjdajY/QqB0OeYwARxRngYkqPHn /3YlRrznW5tpWN2dA8S6Y3ZBhySmTO0rk8OnfYifPdWuc64f3cHdpNXEFjFB//0GgSCF 5Xwg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ALKqPwcdw8i3Zhys1Z9vwY3BYHS9awwwBPzo1t8xsNXe7ECF4y4XV58c RFxz2Spu9vNdAKSzCLGoy7oXAvk3brdUFdGg7BL/caCXfGTfjMLhPUDwzyxnDhE3YtgT4fTbqSO jLQNzRxSy3+42/H/K7JT9TAmg9Jm6z8JlEv5K2tGqN/6BPQ/ZgBav8PnvOZGZfH5+Mw== X-Received: by 2002:a62:4b16:: with SMTP id y22-v6mr24642353pfa.29.1527000607258; Tue, 22 May 2018 07:50:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZphUsuiioNusWszDGg8AZrqurPJZsJfLGczA2us1hJ6CC2sdupkuIINv6jXbmTTX4NX8Cu3 X-Received: by 2002:a62:4b16:: with SMTP id y22-v6mr24642320pfa.29.1527000606583; Tue, 22 May 2018 07:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527000606; cv=none; d=google.com; s=arc-20160816; b=gnby/3UVqxxckyf5/lbYvmvmiAr+fglNo9vJqjTEC8t0Zr8B922BkPC6c4rZtHoi44 XVtjvxOn1J/mgSahXCfhiz09rOroshqNTZZyFYB5YqK0zy2vCvEZr9W73nspWja3prN8 e5u3+wSj9lP7c0GQoH3tGz0XO07V7BPl44itOYnAiQ2nt7mUP1864V22cgC8tloYSSgr NNtR5MBBCfxfsXzYr4G2EuAo4YrKby4wndJwH3eS4im1X6edb1HeWqz5B2Vc9fWvmG0Z v/lIcHAE2wp6ILLtJWX8dpHkGZHiz5moZtD5enmkYVRC9f05c4CfFfSaV4jymgd8oFLP U+pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=/qsMFmy3ICmwBuCYG6RW4PGQhlYealfmqA2bX7lTmCM=; b=Rp99I7J7fCsT2XN4lQAhu2rigWPLcLljmyYcSDeJsSUb5cp20eQsLMk2sw2LWv3+S9 jkBRPiiOylXDxadslXPcFBmjmaywh9faeaMTOEwqvl232SKCN+935rw01xC1Y+CKhTp9 Qbz1z8fPuRIi6xsiikbj3tUlqu7mmXHP/OnsgKlfP0GO6rkfJ45R/tfuihYHIpDefsfk l81NmEfEndiTUew701XgWksC6YRaMusRnzjU4oOgYCu65u7SB3ndPRFYtTj3jWEyXOGz VIkphs44qJRgudbG6NcsRTqTFKZkRZwelQifLkX3qOCa5X37ma1DKhCc8JkBYzXczs6T daRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id k7-v6si17061384pls.368.2018.05.22.07.50.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:50:06 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2018 07:50:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,430,1520924400"; d="scan'208";a="226336489" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga005.jf.intel.com with ESMTP; 22 May 2018 07:50:05 -0700 Subject: [PATCH 07/11] mm, madvise_inject_error: fix page count leak From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Michal Hocko , Andi Kleen , Wu Fengguang , hch@lst.de, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, tony.luck@intel.com Date: Tue, 22 May 2018 07:40:09 -0700 Message-ID: <152700000922.24093.14813242965473482705.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152699997165.24093.12194490924829406111.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152699997165.24093.12194490924829406111.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The madvise_inject_error() routine uses get_user_pages() to lookup the pfn and other information for injected error, but it fails to release that pin. The dax-dma-vs-truncate warning catches this failure with the following signature: Injecting memory failure for pfn 0x208900 at process virtual address 0x7f3908d00000 Memory failure: 0x208900: reserved kernel page still referenced by 1 users Memory failure: 0x208900: recovery action for reserved kernel page: Failed WARNING: CPU: 37 PID: 9566 at fs/dax.c:348 dax_disassociate_entry+0x4e/0x90 CPU: 37 PID: 9566 Comm: umount Tainted: G W OE 4.17.0-rc6+ #1900 [..] RIP: 0010:dax_disassociate_entry+0x4e/0x90 RSP: 0018:ffffc9000a9b3b30 EFLAGS: 00010002 RAX: ffffea0008224000 RBX: 0000000000208a00 RCX: 0000000000208900 RDX: 0000000000000001 RSI: ffff8804058c6160 RDI: 0000000000000008 RBP: 000000000822000a R08: 0000000000000002 R09: 0000000000208800 R10: 0000000000000000 R11: 0000000000208801 R12: ffff8804058c6168 R13: 0000000000000000 R14: 0000000000000002 R15: 0000000000000001 FS: 00007f4548027fc0(0000) GS:ffff880431d40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000056316d5f8988 CR3: 00000004298cc000 CR4: 00000000000406e0 Call Trace: __dax_invalidate_mapping_entry+0xab/0xe0 dax_delete_mapping_entry+0xf/0x20 truncate_exceptional_pvec_entries.part.14+0x1d4/0x210 truncate_inode_pages_range+0x291/0x920 ? kmem_cache_free+0x1f8/0x300 ? lock_acquire+0x9f/0x200 ? truncate_inode_pages_final+0x31/0x50 ext4_evict_inode+0x69/0x740 Cc: Fixes: bd1ce5f91f54 ("HWPOISON: avoid grabbing the page count...") Cc: Michal Hocko Cc: Andi Kleen Cc: Wu Fengguang Signed-off-by: Dan Williams --- mm/madvise.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 4d3c922ea1a1..246fa4d4eee2 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -631,11 +631,13 @@ static int madvise_inject_error(int behavior, for (; start < end; start += PAGE_SIZE << order) { + unsigned long pfn; int ret; ret = get_user_pages_fast(start, 1, 0, &page); if (ret != 1) return ret; + pfn = page_to_pfn(page); /* * When soft offlining hugepages, after migrating the page @@ -651,17 +653,20 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", - page_to_pfn(page), start); + pfn, start); ret = soft_offline_page(page, MF_COUNT_INCREASED); + put_page(page); if (ret) return ret; continue; } + put_page(page); + pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", - page_to_pfn(page), start); + pfn, start); - ret = memory_failure(page_to_pfn(page), MF_COUNT_INCREASED); + ret = memory_failure(pfn, MF_COUNT_INCREASED); if (ret) return ret; }