Skip to content

Commit 8869477

Browse files
eparisJames Morris
authored andcommitted
security: protect from stack expantion into low vm addresses
Add security checks to make sure we are not attempting to expand the stack into memory protected by mmap_min_addr Signed-off-by: Eric Paris <eparis@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
1 parent ab5a91a commit 8869477

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mm/mmap.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,15 +1615,19 @@ static inline int expand_downwards(struct vm_area_struct *vma,
16151615
*/
16161616
if (unlikely(anon_vma_prepare(vma)))
16171617
return -ENOMEM;
1618+
1619+
address &= PAGE_MASK;
1620+
error = security_file_mmap(0, 0, 0, 0, address, 1);
1621+
if (error)
1622+
return error;
1623+
16181624
anon_vma_lock(vma);
16191625

16201626
/*
16211627
* vma->vm_start/vm_end cannot change under us because the caller
16221628
* is required to hold the mmap_sem in read mode. We need the
16231629
* anon_vma lock to serialize against concurrent expand_stacks.
16241630
*/
1625-
address &= PAGE_MASK;
1626-
error = 0;
16271631

16281632
/* Somebody else might have raced and expanded it already */
16291633
if (address < vma->vm_start) {

0 commit comments

Comments
 (0)