* request for 4.14-stable: 15d36fecd0bd ("mm: disallow mappings that conflict for devm_memremap_pages()")
@ 2018-10-16 21:19 Sudip Mukherjee
2018-10-18 16:57 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2018-10-16 21:19 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: stable, Dan Williams, Robert Elliott, Jeff Moyer, Matthew Wilcox,
Andrew Morton, Linus Torvalds
[-- Attachment #1: Type: text/plain, Size: 89 bytes --]
Hi Greg,
This was missing in 4.14-stable. Please apply to your queue.
--
Regards
Sudip
[-- Attachment #2: 0001-mm-disallow-mappings-that-conflict-for-devm_memremap.patch --]
[-- Type: text/x-diff, Size: 3177 bytes --]
>From b8c7129d01bbe708530280f097e9e09287245f20 Mon Sep 17 00:00:00 2001
From: Dave Jiang <dave.jiang@intel.com>
Date: Thu, 26 Jul 2018 16:37:15 -0700
Subject: [PATCH] mm: disallow mappings that conflict for devm_memremap_pages()
commit 15d36fecd0bdc7510b70a0e5ec6671140b3fce0c upstream
When pmem namespaces created are smaller than section size, this can
cause an issue during removal and gpf was observed:
general protection fault: 0000 1 SMP PTI
CPU: 36 PID: 3941 Comm: ndctl Tainted: G W 4.14.28-1.el7uek.x86_64 #2
task: ffff88acda150000 task.stack: ffffc900233a4000
RIP: 0010:__put_page+0x56/0x79
Call Trace:
devm_memremap_pages_release+0x155/0x23a
release_nodes+0x21e/0x260
devres_release_all+0x3c/0x48
device_release_driver_internal+0x15c/0x207
device_release_driver+0x12/0x14
unbind_store+0xba/0xd8
drv_attr_store+0x27/0x31
sysfs_kf_write+0x3f/0x46
kernfs_fop_write+0x10f/0x18b
__vfs_write+0x3a/0x16d
vfs_write+0xb2/0x1a1
SyS_write+0x55/0xb9
do_syscall_64+0x79/0x1ae
entry_SYSCALL_64_after_hwframe+0x3d/0x0
Add code to check whether we have a mapping already in the same section
and prevent additional mappings from being created if that is the case.
Link: http://lkml.kernel.org/r/152909478401.50143.312364396244072931.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Robert Elliott <elliott@hpe.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
kernel/memremap.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 2b136d4988f7..790ddf3bce19 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -355,10 +355,27 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
struct dev_pagemap *pgmap;
struct page_map *page_map;
int error, nid, is_ram, i = 0;
+ struct dev_pagemap *conflict_pgmap;
align_start = res->start & ~(SECTION_SIZE - 1);
align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
- align_start;
+ align_end = align_start + align_size - 1;
+
+ conflict_pgmap = get_dev_pagemap(PHYS_PFN(align_start), NULL);
+ if (conflict_pgmap) {
+ dev_WARN(dev, "Conflicting mapping in same section\n");
+ put_dev_pagemap(conflict_pgmap);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ conflict_pgmap = get_dev_pagemap(PHYS_PFN(align_end), NULL);
+ if (conflict_pgmap) {
+ dev_WARN(dev, "Conflicting mapping in same section\n");
+ put_dev_pagemap(conflict_pgmap);
+ return ERR_PTR(-ENOMEM);
+ }
+
is_ram = region_intersects(align_start, align_size,
IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);
@@ -396,7 +413,6 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
mutex_lock(&pgmap_lock);
error = 0;
- align_end = align_start + align_size - 1;
foreach_order_pgoff(res, order, pgoff) {
struct dev_pagemap *dup;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: request for 4.14-stable: 15d36fecd0bd ("mm: disallow mappings that conflict for devm_memremap_pages()")
2018-10-16 21:19 request for 4.14-stable: 15d36fecd0bd ("mm: disallow mappings that conflict for devm_memremap_pages()") Sudip Mukherjee
@ 2018-10-18 16:57 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-18 16:57 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: stable, Dan Williams, Robert Elliott, Jeff Moyer, Matthew Wilcox,
Andrew Morton, Linus Torvalds
On Tue, Oct 16, 2018 at 10:19:49PM +0100, Sudip Mukherjee wrote:
> Hi Greg,
>
> This was missing in 4.14-stable. Please apply to your queue.
Applied, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-19 0:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 21:19 request for 4.14-stable: 15d36fecd0bd ("mm: disallow mappings that conflict for devm_memremap_pages()") Sudip Mukherjee
2018-10-18 16:57 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.