Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp161520ybl; Thu, 9 Jan 2020 19:10:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzQOGHAlHaMS0dtAPIZVUbDgY8o7x7fWYcs0jNcWeqvZwrMYB7gxy+0GWOgHXZG7IMCmGmW X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr824471otc.123.1578625854749; Thu, 09 Jan 2020 19:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578625854; cv=none; d=google.com; s=arc-20160816; b=LN/X74FnmZ4UV/YoOmW9+ekVV2co6fNAkBZtqRFcypVePQpRLDiGrcmYlIfkyXRg3e cwO5WvftJFRDEBZQlvvH2a2JyzjNYb2CCTnJ2UkqoR8vs3HlH65WnVNnmXnE9LREJwaa liw+LcmiAM1zncxXqbFUU/fk8SCTS+lCcKPfFBHvOyn9cGv4qLZoQCp2DzMzAGcl227E hyxJbfhbobnVvKqV8r2pVinUwWxj9LZWRJXvaJOpXT6Rr7kjQbm5fzX6UCWA2IU+q6qd UPX6GiV/OrS22eWEFuxGxdhOmX/MaTdZIY4KfHQSgRn6q/dPO5uCVs08G2Eme/abA4fj 8RWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=eQjl3Y2BRowWngvo4q2TKHkVbSewp6n5dk4rdIA1K/M=; b=o/H+l3xkWD3aa7E57u1T48iJejPBZ9g63IJd1sM5fyZvLcCbQD9L8+Q5togBHhm938 dC0H25RiMwH1f9WoCqvGzUxn3tf8x/8bKBwvP02HCIOVx3MQXeW6AE5+wisMaCQBBfwu kR0fiBQ6EMku4hQyjCwxcHSnj7veZX2dGK7jSkSb5qy94CS8Z6kDIyajd1WMG8vJPsq+ M6EV7CvaIErW0ALeOnL9CqJQpf0HnZ3/dbPpAfl66Iuv51f3RvLi3XwE6UN132Nn+rPK o0KcHDYtX21dTDT5cOGtXilAQW9L+jal1yx5U6xPnwc4ZBpIwfFL9nzp+/oStjpZuTte 3Uew== ARC-Authentication-Results: i=1; mx.google.com; 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 d20si360396oti.311.2020.01.09.19.10.43; Thu, 09 Jan 2020 19:10:54 -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; 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 S1731110AbgAJDJM (ORCPT + 99 others); Thu, 9 Jan 2020 22:09:12 -0500 Received: from foss.arm.com ([217.140.110.172]:39080 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730952AbgAJDJM (ORCPT ); Thu, 9 Jan 2020 22:09:12 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9BF3A11FB; Thu, 9 Jan 2020 19:09:11 -0800 (PST) Received: from p8cg001049571a15.blr.arm.com (p8cg001049571a15.blr.arm.com [10.162.42.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 988163F703; Thu, 9 Jan 2020 19:09:05 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, catalin.marinas@arm.com, will@kernel.org Cc: mark.rutland@arm.com, david@redhat.com, cai@lca.pw, logang@deltatee.com, cpandya@codeaurora.org, arunks@codeaurora.org, dan.j.williams@intel.com, mgorman@techsingularity.net, osalvador@suse.de, ard.biesheuvel@arm.com, steve.capper@arm.com, broonie@kernel.org, valentin.schneider@arm.com, Robin.Murphy@arm.com, steven.price@arm.com, suzuki.poulose@arm.com, ira.weiny@intel.com, Anshuman Khandual Subject: [PATCH V11 4/5] arm64/mm: Hold memory hotplug lock while walking for kernel page table dump Date: Fri, 10 Jan 2020 08:39:14 +0530 Message-Id: <1578625755-11792-5-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1578625755-11792-1-git-send-email-anshuman.khandual@arm.com> References: <1578625755-11792-1-git-send-email-anshuman.khandual@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The arm64 page table dump code can race with concurrent modification of the kernel page tables. When a leaf entries are modified concurrently, the dump code may log stale or inconsistent information for a VA range, but this is otherwise not harmful. When intermediate levels of table are freed, the dump code will continue to use memory which has been freed and potentially reallocated for another purpose. In such cases, the dump code may dereference bogus addresses, leading to a number of potential problems. Intermediate levels of table may by freed during memory hot-remove, which will be enabled by a subsequent patch. To avoid racing with this, take the memory hotplug lock when walking the kernel page table. Cc: Catalin Marinas Cc: Will Deacon Acked-by: David Hildenbrand Acked-by: Mark Rutland Signed-off-by: Anshuman Khandual --- arch/arm64/mm/ptdump_debugfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/mm/ptdump_debugfs.c b/arch/arm64/mm/ptdump_debugfs.c index 064163f..b5eebc8 100644 --- a/arch/arm64/mm/ptdump_debugfs.c +++ b/arch/arm64/mm/ptdump_debugfs.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include @@ -7,7 +8,10 @@ static int ptdump_show(struct seq_file *m, void *v) { struct ptdump_info *info = m->private; + + get_online_mems(); ptdump_walk_pgd(m, info); + put_online_mems(); return 0; } DEFINE_SHOW_ATTRIBUTE(ptdump); -- 2.7.4