Skip to content

Commit

Permalink
move security_mmap_addr() to saner place
Browse files Browse the repository at this point in the history
it really should be done by get_unmapped_area(); that cuts down on
the amount of callers considerably and it's the right place for
that stuff anyway.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jun 1, 2012
1 parent 8b3ec68 commit 9ac4ed4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
17 changes: 3 additions & 14 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,6 @@ static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
struct mm_struct * mm = current->mm;
struct inode *inode;
vm_flags_t vm_flags;
int error;

/*
* Does the application expect PROT_READ to imply PROT_EXEC?
Expand Down Expand Up @@ -1100,10 +1099,6 @@ static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
}
}

error = security_mmap_addr(addr);
if (error)
return error;

return mmap_region(file, addr, len, flags, vm_flags, pgoff);
}

Expand Down Expand Up @@ -1633,7 +1628,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
if (addr & ~PAGE_MASK)
return -EINVAL;

return arch_rebalance_pgtables(addr, len);
addr = arch_rebalance_pgtables(addr, len);
error = security_mmap_addr(addr);
return error ? error : addr;
}

EXPORT_SYMBOL(get_unmapped_area);
Expand Down Expand Up @@ -2210,10 +2207,6 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
if (!len)
return addr;

error = security_mmap_addr(addr);
if (error)
return error;

flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;

error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
Expand Down Expand Up @@ -2566,10 +2559,6 @@ int install_special_mapping(struct mm_struct *mm,
vma->vm_ops = &special_mapping_vmops;
vma->vm_private_data = pages;

ret = security_mmap_addr(vma->vm_start);
if (ret)
goto out;

ret = insert_vm_struct(mm, vma);
if (ret)
goto out;
Expand Down
7 changes: 0 additions & 7 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,6 @@ static unsigned long mremap_to(unsigned long addr,
if ((addr <= new_addr) && (addr+old_len) > new_addr)
goto out;

ret = security_mmap_addr(new_addr);
if (ret)
goto out;

ret = do_munmap(mm, new_addr, new_len);
if (ret)
goto out;
Expand Down Expand Up @@ -532,9 +528,6 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
goto out;
}

ret = security_mmap_addr(new_addr);
if (ret)
goto out;
ret = move_vma(vma, addr, old_len, new_len, new_addr);
}
out:
Expand Down

0 comments on commit 9ac4ed4

Please sign in to comment.