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  PHC 
Open Source and information security mailing list archives
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 12 Feb 2017 14:34:16 -0800
From:   Dan Williams <>
Cc:     Michal Hocko <>, Toshi Kani <>,, Logan Gunthorpe <>,,,
        Ben Hutchings <>,
        Vlastimil Babka <>
Subject: [PATCH 1/2] mm, devm_memremap_pages: hold device_hotplug lock over
 mem_hotplug_{begin, done}

The mem_hotplug_{begin,done} lock coordinates with
{get,put}_online_mems() to hold off "readers" of the current state of
memory from new hotplug actions. mem_hotplug_begin() expects exclusive
access, via the device_hotplug lock, to set mem_hotplug.active_writer.
Calling mem_hotplug_begin() without locking device_hotplug can lead to
corrupting mem_hotplug.refcount and missed wakeups / soft lockups.

Cc: <>
Cc: Michal Hocko <>
Cc: Toshi Kani <>
Cc: Vlastimil Babka <>
Cc: Logan Gunthorpe <>
Fixes: f931ab479dd2 ("mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done}")
Reported-by: Ben Hutchings <>
Signed-off-by: Dan Williams <>
 kernel/memremap.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/memremap.c b/kernel/memremap.c
index e6476a8e8b6a..16640415c150 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -264,9 +264,12 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
 	/* pages are dead and unused, undo the arch mapping */
+	lock_device_hotplug();
 	arch_remove_memory(res->start, resource_size(res));
+	unlock_device_hotplug();
 	untrack_pfn(NULL, PHYS_PFN(res->start), resource_size(res));
 	dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc,
@@ -374,9 +377,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
 	if (error)
 		goto err_pfn_remap;
+	lock_device_hotplug();
 	error = arch_add_memory(nid, res->start, resource_size(res), true);
+	unlock_device_hotplug();
 	if (error)
 		goto err_add_memory;

Powered by blists - more mailing lists