Skip to content

Commit

Permalink
VM/Security: add security hook to do_brk
Browse files Browse the repository at this point in the history
Given a specifically crafted binary do_brk() can be used to get low pages
available in userspace virtual memory and can thus be used to circumvent
the mmap_min_addr low memory protection.  Add security checks in do_brk().

Signed-off-by: Eric Paris <[email protected]>
Acked-by: Alan Cox <[email protected]>
Cc: Stephen Smalley <[email protected]>
Cc: James Morris <[email protected]>
Cc: Chris Wright <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
eparis authored and Linus Torvalds committed Dec 5, 2007
1 parent 294a80a commit ecaf18c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,10 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
if (is_hugepage_only_range(mm, addr, len))
return -EINVAL;

error = security_file_mmap(0, 0, 0, 0, addr, 1);
if (error)
return error;

flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;

error = arch_mmap_check(addr, len, flags);
Expand Down

0 comments on commit ecaf18c

Please sign in to comment.