提交 a626ca6a 编写于 作者: L Linus Torvalds

vm: fix vm_pgoff wrap in stack expansion

Commit 982134ba ("mm: avoid wrapping vm_pgoff in mremap()") fixed
the case of a expanding mapping causing vm_pgoff wrapping when you used
mremap.  But there was another case where we expand mappings hiding in
plain sight: the automatic stack expansion.

This fixes that case too.

This one also found by Robert Święcki, using his nasty system call
fuzzer tool.  Good job.
Reported-and-tested-by: NRobert Święcki <robert@swiecki.net>
Cc: stable@kernel.org
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 60d48c1e
...@@ -1814,11 +1814,14 @@ static int expand_downwards(struct vm_area_struct *vma, ...@@ -1814,11 +1814,14 @@ static int expand_downwards(struct vm_area_struct *vma,
size = vma->vm_end - address; size = vma->vm_end - address;
grow = (vma->vm_start - address) >> PAGE_SHIFT; grow = (vma->vm_start - address) >> PAGE_SHIFT;
error = acct_stack_growth(vma, size, grow); error = -ENOMEM;
if (!error) { if (grow <= vma->vm_pgoff) {
vma->vm_start = address; error = acct_stack_growth(vma, size, grow);
vma->vm_pgoff -= grow; if (!error) {
perf_event_mmap(vma); vma->vm_start = address;
vma->vm_pgoff -= grow;
perf_event_mmap(vma);
}
} }
} }
vma_unlock_anon_vma(vma); vma_unlock_anon_vma(vma);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册