UPSTREAM: mm: lock a vma before stack expansion
With recent changes necessitating mmap_lock to be held for write while expanding a stack, per-VMA locks should follow the same rules and be write-locked to prevent page faults into the VMA being expanded. Add the necessary locking. Cc: stable@vger.kernel.org Signed-off-by: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit c137381f71aec755fbf47cd4e9bd4dce752c054c) Change-Id: I3e6a8c89c1fb7c0669e1232176bb04ea6b09bc0a Signed-off-by: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
c0ba567af1
commit
05f7c7fe72
@ -2029,6 +2029,8 @@ static int expand_upwards(struct vm_area_struct *vma, unsigned long address)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Lock the VMA before expanding to prevent concurrent page faults */
|
||||
vma_start_write(vma);
|
||||
/*
|
||||
* vma->vm_start/vm_end cannot change under us because the caller
|
||||
* is required to hold the mmap_lock in read mode. We need the
|
||||
@ -2116,6 +2118,8 @@ int expand_downwards(struct vm_area_struct *vma, unsigned long address)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Lock the VMA before expanding to prevent concurrent page faults */
|
||||
vma_start_write(vma);
|
||||
/*
|
||||
* vma->vm_start/vm_end cannot change under us because the caller
|
||||
* is required to hold the mmap_lock in read mode. We need the
|
||||
|
Loading…
Reference in New Issue
Block a user