Commit 5b0caf3
mm/vma: enforce VMA fork limit on unfaulted,faulted mremap merge too
[ Upstream commit 3b617fd ]
The is_mergeable_anon_vma() function uses vmg->middle as the source VMA.
However when merging a new VMA, this field is NULL.
In all cases except mremap(), the new VMA will either be newly established
and thus lack an anon_vma, or will be an expansion of an existing VMA thus
we do not care about whether VMA is CoW'd or not.
In the case of an mremap(), we can end up in a situation where we can
accidentally allow an unfaulted/faulted merge with a VMA that has been
forked, violating the general rule that we do not permit this for reasons
of anon_vma lock scalability.
Now we have the ability to be aware of the fact we are copying a VMA and
also know which VMA that is, we can explicitly check for this, so do so.
This is pertinent since commit 879bca0 ("mm/vma: fix incorrectly
disallowed anonymous VMA merges"), as this patch permits unfaulted/faulted
merges that were previously disallowed running afoul of this issue.
While we are here, vma_had_uncowed_parents() is a confusing name, so make
it simple and rename it to vma_is_fork_child().
Link: https://lkml.kernel.org/r/6e2b9b3024ae1220961c8b81d74296d4720eaf2b.1767638272.git.lorenzo.stoakes@oracle.com
Fixes: 879bca0 ("mm/vma: fix incorrectly disallowed anonymous VMA merges")
Signed-off-by: Lorenzo Stoakes <[email protected]>
Reviewed-by: Harry Yoo <[email protected]>
Reviewed-by: Jeongjun Park <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: David Hildenbrand (Red Hat) <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Liam Howlett <[email protected]>
Cc: Pedro Falcato <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Yeoreum Yun <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
[ with upstream commit 61f67c2 backported, this simply applied correctly. Built + tested ]
Signed-off-by: Lorenzo Stoakes <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent a4d9dbf commit 5b0caf3
1 file changed
Lines changed: 15 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 68 | + | |
| 69 | + | |
76 | 70 | | |
77 | 71 | | |
78 | 72 | | |
79 | | - | |
| 73 | + | |
| 74 | + | |
80 | 75 | | |
81 | 76 | | |
82 | 77 | | |
| |||
121 | 116 | | |
122 | 117 | | |
123 | 118 | | |
124 | | - | |
125 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | | - | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
0 commit comments