+ kernel-fork-set-vmas-mm-prev-next-right-after-vm_area_dup-in-dup_mmap.patch added to -mm tree

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

 



The patch titled
     Subject: kernel/fork: set VMA's mm/prev/next right after vm_area_dup in dup_mmap
has been added to the -mm tree.  Its filename is
     kernel-fork-set-vmas-mm-prev-next-right-after-vm_area_dup-in-dup_mmap.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/kernel-fork-set-vmas-mm-prev-next-right-after-vm_area_dup-in-dup_mmap.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/kernel-fork-set-vmas-mm-prev-next-right-after-vm_area_dup-in-dup_mmap.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx>
Subject: kernel/fork: set VMA's mm/prev/next right after vm_area_dup in dup_mmap

Function vm_area_dup() makes exact copy of structure.  It's better to stop
referencing parent structures because various helpers use these pointers.

For example if VM_WIPEONFORK is set then anon_vma_prepare() will try to
merge anon_vma with previous and next VMA.  Poking parent VMAs and sharing
their anon_vma is safe for now but is not expected behavior.

Note: this will break commit 4e4a9eb92133 ("mm/rmap.c: reuse mergeable
anon_vma as parent when fork") without related fix because it contains
several flaws hidden by current initialization sequence in dup_mmap().

Link: http://lkml.kernel.org/r/157839239842.694.2288178566540902852.stgit@buzz
Signed-off-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx>
Reviewed-by: Li Xinhai <lixinhai.lxh@xxxxxxxxx>
Cc: Rik van Riel <riel@xxxxxxxxxx>
Cc: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 kernel/fork.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/kernel/fork.c~kernel-fork-set-vmas-mm-prev-next-right-after-vm_area_dup-in-dup_mmap
+++ a/kernel/fork.c
@@ -544,10 +544,12 @@ static __latent_entropy int dup_mmap(str
 		tmp = vm_area_dup(mpnt);
 		if (!tmp)
 			goto fail_nomem;
+		tmp->vm_mm = mm;
+		tmp->vm_prev = prev;
+		tmp->vm_next = NULL;
 		retval = vma_dup_policy(mpnt, tmp);
 		if (retval)
 			goto fail_nomem_policy;
-		tmp->vm_mm = mm;
 		retval = dup_userfaultfd(tmp, &uf);
 		if (retval)
 			goto fail_nomem_anon_vma_fork;
@@ -559,7 +561,6 @@ static __latent_entropy int dup_mmap(str
 		} else if (anon_vma_fork(tmp, mpnt, prev))
 			goto fail_nomem_anon_vma_fork;
 		tmp->vm_flags &= ~(VM_LOCKED | VM_LOCKONFAULT);
-		tmp->vm_next = tmp->vm_prev = NULL;
 		file = tmp->vm_file;
 		if (file) {
 			struct inode *inode = file_inode(file);
@@ -592,7 +593,6 @@ static __latent_entropy int dup_mmap(str
 		 */
 		*pprev = tmp;
 		pprev = &tmp->vm_next;
-		tmp->vm_prev = prev;
 		prev = tmp;
 
 		__vma_link_rb(mm, tmp, rb_link, rb_parent);
_

Patches currently in -mm which might be from khlebnikov@xxxxxxxxxxxxxx are

mm-rmap-fix-and-simplify-reusing-mergeable-anon_vma-as-parent-when-fork.patch
kernel-fork-set-vmas-mm-prev-next-right-after-vm_area_dup-in-dup_mmap.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux