linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] mm: lock a vma before stack expansion
@ 2023-07-08 19:12 Suren Baghdasaryan
  2023-07-08 19:12 ` [PATCH v2 2/3] mm: lock newly mapped VMA which can be modified after it becomes visible Suren Baghdasaryan
  2023-07-08 19:12 ` [PATCH v2 3/3] fork: lock VMAs of the parent process when forking Suren Baghdasaryan
  0 siblings, 2 replies; 22+ messages in thread
From: Suren Baghdasaryan @ 2023-07-08 19:12 UTC (permalink / raw)
  To: torvalds
  Cc: jacobly.alt, regressions, david, gregkh, linux-kernel,
	liam.howlett, Suren Baghdasaryan, linux-mm, peterx, regressions,
	willy, bagasdotme, stable, akpm, ldufour, linuxppc-dev,
	linux-arm-kernel

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>
---
 mm/mmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/mmap.c b/mm/mmap.c
index 204ddcd52625..c66e4622a557 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1977,6 +1977,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
@@ -2064,6 +2066,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
-- 
2.41.0.390.g38632f3daf-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-08-10 20:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-08 19:12 [PATCH v2 1/3] mm: lock a vma before stack expansion Suren Baghdasaryan
2023-07-08 19:12 ` [PATCH v2 2/3] mm: lock newly mapped VMA which can be modified after it becomes visible Suren Baghdasaryan
2023-07-08 19:12 ` [PATCH v2 3/3] fork: lock VMAs of the parent process when forking Suren Baghdasaryan
2023-07-08 19:22   ` Suren Baghdasaryan
2023-07-08 21:18   ` Linus Torvalds
2023-07-08 22:36     ` Suren Baghdasaryan
2023-07-08 22:53       ` Linus Torvalds
2023-07-08 23:03         ` Suren Baghdasaryan
2023-08-04 21:46   ` Mateusz Guzik
2023-08-04 22:49     ` Linus Torvalds
2023-08-04 23:25       ` Mateusz Guzik
2023-08-05  0:14         ` Linus Torvalds
2023-08-05  0:26           ` Suren Baghdasaryan
2023-08-05  0:34             ` Suren Baghdasaryan
2023-08-05  0:49               ` Mateusz Guzik
2023-08-05  1:06                 ` Suren Baghdasaryan
2023-08-05  1:16                   ` Mateusz Guzik
2023-08-05  1:36                     ` Suren Baghdasaryan
2023-08-05  1:06           ` Mateusz Guzik
2023-08-05  1:42             ` Suren Baghdasaryan
2023-08-09 21:07               ` Mateusz Guzik
2023-08-10 20:31                 ` Suren Baghdasaryan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).