lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191018220525.9042-5-sashal@kernel.org>
Date:   Fri, 18 Oct 2019 18:03:50 -0400
From:   Sasha Levin <sashal@...nel.org>
To:     linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc:     David Hildenbrand <david@...hat.com>,
        Pavel Tatashin <pavel.tatashin@...rosoft.com>,
        Rashmica Gupta <rashmica.g@...il.com>,
        Balbir Singh <bsingharora@...il.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>,
        Michael Neuling <mikey@...ling.org>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Heiko Carstens <heiko.carstens@...ibm.com>,
        John Allen <jallen@...ux.vnet.ibm.com>,
        Jonathan Corbet <corbet@....net>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Juergen Gross <jgross@...e.com>,
        Kate Stewart <kstewart@...uxfoundation.org>,
        "K. Y. Srinivasan" <kys@...rosoft.com>,
        Len Brown <lenb@...nel.org>,
        Martin Schwidefsky <schwidefsky@...ibm.com>,
        Mathieu Malaterre <malat@...ian.org>,
        Michal Hocko <mhocko@...e.com>,
        Nathan Fontenot <nfont@...ux.vnet.ibm.com>,
        Oscar Salvador <osalvador@...e.de>,
        Philippe Ombredanne <pombredanne@...b.com>,
        "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Vlastimil Babka <vbabka@...e.cz>,
        YASUAKI ISHIMATSU <yasu.isimatu@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Sasha Levin <sashal@...nel.org>, linuxppc-dev@...ts.ozlabs.org
Subject: [PATCH AUTOSEL 4.19 005/100] powerpc/powernv: hold device_hotplug_lock when calling memtrace_offline_pages()

From: David Hildenbrand <david@...hat.com>

[ Upstream commit 5666848774ef43d3db5151ec518f1deb63515c20 ]

Let's perform all checking + offlining + removing under
device_hotplug_lock, so nobody can mess with these devices via sysfs
concurrently.

[david@...hat.com: take device_hotplug_lock outside of loop]
  Link: http://lkml.kernel.org/r/20180927092554.13567-6-david@redhat.com
Link: http://lkml.kernel.org/r/20180925091457.28651-6-david@redhat.com
Signed-off-by: David Hildenbrand <david@...hat.com>
Reviewed-by: Pavel Tatashin <pavel.tatashin@...rosoft.com>
Reviewed-by: Rashmica Gupta <rashmica.g@...il.com>
Acked-by: Balbir Singh <bsingharora@...il.com>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Rashmica Gupta <rashmica.g@...il.com>
Cc: Michael Neuling <mikey@...ling.org>
Cc: Boris Ostrovsky <boris.ostrovsky@...cle.com>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Haiyang Zhang <haiyangz@...rosoft.com>
Cc: Heiko Carstens <heiko.carstens@...ibm.com>
Cc: John Allen <jallen@...ux.vnet.ibm.com>
Cc: Jonathan Corbet <corbet@....net>
Cc: Joonsoo Kim <iamjoonsoo.kim@....com>
Cc: Juergen Gross <jgross@...e.com>
Cc: Kate Stewart <kstewart@...uxfoundation.org>
Cc: "K. Y. Srinivasan" <kys@...rosoft.com>
Cc: Len Brown <lenb@...nel.org>
Cc: Martin Schwidefsky <schwidefsky@...ibm.com>
Cc: Mathieu Malaterre <malat@...ian.org>
Cc: Michal Hocko <mhocko@...e.com>
Cc: Nathan Fontenot <nfont@...ux.vnet.ibm.com>
Cc: Oscar Salvador <osalvador@...e.de>
Cc: Philippe Ombredanne <pombredanne@...b.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
Cc: "Rafael J. Wysocki" <rjw@...ysocki.net>
Cc: Stephen Hemminger <sthemmin@...rosoft.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Vlastimil Babka <vbabka@...e.cz>
Cc: YASUAKI ISHIMATSU <yasu.isimatu@...il.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
 arch/powerpc/platforms/powernv/memtrace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index a29fdf8a2e56e..232bf5987f91d 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -70,6 +70,7 @@ static int change_memblock_state(struct memory_block *mem, void *arg)
 	return 0;
 }
 
+/* called with device_hotplug_lock held */
 static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages)
 {
 	u64 end_pfn = start_pfn + nr_pages - 1;
@@ -110,6 +111,7 @@ static u64 memtrace_alloc_node(u32 nid, u64 size)
 	/* Trace memory needs to be aligned to the size */
 	end_pfn = round_down(end_pfn - nr_pages, nr_pages);
 
+	lock_device_hotplug();
 	for (base_pfn = end_pfn; base_pfn > start_pfn; base_pfn -= nr_pages) {
 		if (memtrace_offline_pages(nid, base_pfn, nr_pages) == true) {
 			/*
@@ -118,7 +120,6 @@ static u64 memtrace_alloc_node(u32 nid, u64 size)
 			 * we never try to remove memory that spans two iomem
 			 * resources.
 			 */
-			lock_device_hotplug();
 			end_pfn = base_pfn + nr_pages;
 			for (pfn = base_pfn; pfn < end_pfn; pfn += bytes>> PAGE_SHIFT) {
 				remove_memory(nid, pfn << PAGE_SHIFT, bytes);
@@ -127,6 +128,7 @@ static u64 memtrace_alloc_node(u32 nid, u64 size)
 			return base_pfn << PAGE_SHIFT;
 		}
 	}
+	unlock_device_hotplug();
 
 	return 0;
 }
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ