Skip to contentSkip to conversation

mm-memoryc-make-remap_pfn_range-reject-unaligned-addr.patch removed from -mm tree

merged [email protected] 1 participant 1 message Aug 10, 2020

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: mm/memory.c: make remap_pfn_range() reject unaligned addr
has been removed from the -mm tree. Its filename was
mm-memoryc-make-remap_pfn_range-reject-unaligned-addr.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Alex Zhang <[email protected]>
Subject: mm/memory.c: make remap_pfn_range() reject unaligned addr

This function implicitly assumes that the addr passed in is page aligned. A non page aligned addr could ultimately cause a kernel bug in remap_pte_range as the exit condition in the logic loop may never be satisfied. This patch documents the need for the requirement, as well as explicitly adds a check for it.

---

 mm/memory.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/memory.c renamed from mm/memory.c~mm-memoryc-make-remap_pfn_range-reject-unaligned-addr +4 -1
@@ -2082,7 +2082,7 @@ static inline int remap_p4d_range(struct
 /**
  * remap_pfn_range - remap kernel memory to userspace
  * @vma: user vma to map to
- * @addr: target user address to start at
+ * @addr: target page aligned user address to start at
  * @pfn: page frame number of kernel physical memory address
  * @size: size of mapping area
  * @prot: page protection flags for this mapping
@@ -2101,6 +2101,9 @@ int remap_pfn_range(struct vm_area_struc
 	unsigned long remap_pfn = pfn;
 	int err;
 
+	if (WARN_ON_ONCE(!PAGE_ALIGNED(addr)))
+		return -EINVAL;
+
 	/*
 	 * Physically remapped pages are special. Tell the
 	 * rest of the world about it:

_

Patches currently in -mm which might be from [email protected] are