[PATCH] fix mmap return value when vma is merged after call_mmap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On success, mmap should return the begin address of newly mapped area,
but patch "mm: mmap: merge vma after call_mmap() if possible" 
set vm_start of newly merged vma to return value addr.
Users of mmap will get wrong address if vma is merged after call_mmap().
We fix this by moving the assignment to addr before merging vma.

Fixes: d70cec898324 ("mm: mmap: merge vma after call_mmap() if possible")

Signed-off-by: Liu Zixian <liuzixian4@xxxxxxxxxx>
---
 mm/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index d91ecb00d38c..9199b5e8cc1e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1820,12 +1820,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
 				 * and cause general protection fault ultimately.
 				 */
 				fput(vma->vm_file);
-				vm_area_free(vma);
-				vma = merge;
 				/* Update vm_flags and possible addr to pick up the change. We don't
 				 * warn here if addr changed as the vma is not linked by vma_link().
 				 */
 				addr = vma->vm_start;
+				vm_area_free(vma);
+				vma = merge;
 				vm_flags = vma->vm_flags;
 				goto unmap_writable;
 			}
-- 
2.23.0






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux