mm: nommu: fix remap_pfn_range()
Subsystems (2)
PATCH 1/1 mm: nommu: fix remap_pfn_range()
remap_pfn_range() does not update vma->end on no mmu arch which will cause munmap() fail because it can't match the vma.
eg. fb_mmap() in fbmem.c will call io_remap_pfn_range() which is remap_pfn_range() on nommu arch, if an address is not page aligned vma->start will be changed in remap_pfn_range(), but neither size nor vma->end will be updated. Then munmap(start, len) can't find the vma to free, because it need to compare (start + len) with vma->end.
--- mm/nommu.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
mm/nommu.c +1 -0
@@ -1817,6 +1817,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long to, unsigned long size, pgprot_t prot) { vma->vm_start = vma->vm_pgoff << PAGE_SHIFT; + vma->vm_end = vma->vm_start + size;return 0 ; }EXPORT_SYMBOL (remap_pfn_range);
Signature · 9 lines
1.6.3.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 19 lines · On Fri, 27 May 2011 11:50:03 +0800 Bob Liu <[email protected]> wrote:
remap_pfn_range()does not updatevma->endon no mmu arch which will causemunmap()fail because it can't match the vma.eg.
fb_mmap()infbmem.cwill callio_remap_pfn_range()which isremap_pfn_range()on nommu arch, if an address is not page alignedvma->startwill be changed inremap_pfn_range(), but neither size norvma->endwill be updated. Thenmunmap(start, len)can't find the vma to free, because it need to compare (start + len) withvma->end.Signed-off-by Bob Liu <[email protected]>--- mm/nommu.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)mm/nommu.c +0
-0
mm/nommu.c int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, · line 1823
Quoted 7 lines
mm/nommu.c +1
-0@@ -1817,6 +1817,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long to, unsigned long size, pgprot_t prot) { vma->vm_start = vma->vm_pgoff << PAGE_SHIFT; + vma->vm_end = vma->vm_start + size;return 0 ; }EXPORT_SYMBOL (remap_pfn_range);
hm.
The MMU version of remap_pfn_range() doesn't do this. Seems that it just leaves the omitted parts of the vma unmapped. Obviously nommu can't do that, but the divergence is always a concern.
Thsi implementation could lead to overlapping vmas. Should we be checking that it fits?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 9 lines · On Fri, 27 May 2011 11:50:03 +0800 Bob Liu <[email protected]> wrote:
remap_pfn_range()does not updatevma->endon no mmu arch which will causemunmap()fail because it can't match the vma.eg.
fb_mmap()infbmem.cwill callio_remap_pfn_range()which isremap_pfn_range()on nommu arch, if an address is not page alignedvma->startwill be changed inremap_pfn_range(), but neither size norvma->endwill be updated. Thenmunmap(start, len)can't find the vma to free, because it need to compare (start + len) withvma->end.
Also, I tagged the patch (or its successor) for -stable backporting as the problem appears to be present in 2.6.38 (at least).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 32 lines · Andrew Morton
Quoted 19 lines · On Fri, 27 May 2011 11:50:03 +0800 Bob Liu <[email protected]> wrote:
remap_pfn_range()does not updatevma->endon no mmu arch which will causemunmap()fail because it can't match the vma.eg.
fb_mmap()infbmem.cwill callio_remap_pfn_range()which isremap_pfn_range()on nommu arch, if an address is not page alignedvma->startwill be changed inremap_pfn_range(), but neither size norvma->endwill be updated. Thenmunmap(start, len)can't find the vma to free, because it need to compare (start + len) withvma->end.Signed-off-by Bob Liu <[email protected]>---
mm/nommu.c | 1 +1 files changed, 1 insertions(+), 0 deletions(-)mm/nommu.c +0
-0mm/nommu.c int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, · line 1823
Quoted 7 lines
mm/nommu.c +1
-0@@ -1817,6 +1817,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long to, unsigned long size, pgprot_t prot) { vma->vm_start = vma->vm_pgoff << PAGE_SHIFT; + vma->vm_end = vma->vm_start + size; return 0; } EXPORT_SYMBOL(remap_pfn_range);hm.
Quoted 7 lines
The MMU version of
remap_pfn_range()doesn't do this. Seems that it just leaves the omitted parts of the vma unmapped. Obviously nommu can't do that, but the divergence is always a concern.Thsi implementation could lead to overlapping vmas. Should we be checking that it fits?
Hi, Andrew
Sorry for the late response and thanks for your review. I think the overlapping vmas could exist whether this patch or not. Maybe extra check is needed but since nobody run into that cases, could we check it in future patches?
Thanks
Signature · 9 lines
Regards, --Bob -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>