diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-06-01 13:34:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-06-01 13:34:35 -0400 |
commit | 1193755ac6328ad240ba987e6ec41d5e8baf0680 (patch) | |
tree | 40bf847d7e3ebaa57b107151d14e6cd1d280cc6d /mm/mmap.c | |
parent | 4edebed86690eb8db9af3ab85baf4a34e73266cc (diff) | |
parent | 0ef97dcfce4179a2eba046b855ee2f91d6f1b414 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs changes from Al Viro.
"A lot of misc stuff. The obvious groups:
* Miklos' atomic_open series; kills the damn abuse of
->d_revalidate() by NFS, which was the major stumbling block for
all work in that area.
* ripping security_file_mmap() and dealing with deadlocks in the
area; sanitizing the neighborhood of vm_mmap()/vm_munmap() in
general.
* ->encode_fh() switched to saner API; insane fake dentry in
mm/cleancache.c gone.
* assorted annotations in fs (endianness, __user)
* parts of Artem's ->s_dirty work (jff2 and reiserfs parts)
* ->update_time() work from Josef.
* other bits and pieces all over the place.
Normally it would've been in two or three pull requests, but
signal.git stuff had eaten a lot of time during this cycle ;-/"
Fix up trivial conflicts in Documentation/filesystems/vfs.txt (the
'truncate_range' inode method was removed by the VM changes, the VFS
update adds an 'update_time()' method), and in fs/btrfs/ulist.[ch] (due
to sparse fix added twice, with other changes nearby).
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (95 commits)
nfs: don't open in ->d_revalidate
vfs: retry last component if opening stale dentry
vfs: nameidata_to_filp(): don't throw away file on error
vfs: nameidata_to_filp(): inline __dentry_open()
vfs: do_dentry_open(): don't put filp
vfs: split __dentry_open()
vfs: do_last() common post lookup
vfs: do_last(): add audit_inode before open
vfs: do_last(): only return EISDIR for O_CREAT
vfs: do_last(): check LOOKUP_DIRECTORY
vfs: do_last(): make ENOENT exit RCU safe
vfs: make follow_link check RCU safe
vfs: do_last(): use inode variable
vfs: do_last(): inline walk_component()
vfs: do_last(): make exit RCU safe
vfs: split do_lookup()
Btrfs: move over to use ->update_time
fs: introduce inode operation ->update_time
reiserfs: get rid of resierfs_sync_super
reiserfs: mark the superblock as dirty a bit later
...
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 54 |
1 files changed, 6 insertions, 48 deletions
@@ -971,15 +971,13 @@ static inline unsigned long round_hint_to_min(unsigned long hint) | |||
971 | * The caller must hold down_write(¤t->mm->mmap_sem). | 971 | * The caller must hold down_write(¤t->mm->mmap_sem). |
972 | */ | 972 | */ |
973 | 973 | ||
974 | static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, | 974 | unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, |
975 | unsigned long len, unsigned long prot, | 975 | unsigned long len, unsigned long prot, |
976 | unsigned long flags, unsigned long pgoff) | 976 | unsigned long flags, unsigned long pgoff) |
977 | { | 977 | { |
978 | struct mm_struct * mm = current->mm; | 978 | struct mm_struct * mm = current->mm; |
979 | struct inode *inode; | 979 | struct inode *inode; |
980 | vm_flags_t vm_flags; | 980 | vm_flags_t vm_flags; |
981 | int error; | ||
982 | unsigned long reqprot = prot; | ||
983 | 981 | ||
984 | /* | 982 | /* |
985 | * Does the application expect PROT_READ to imply PROT_EXEC? | 983 | * Does the application expect PROT_READ to imply PROT_EXEC? |
@@ -1101,39 +1099,9 @@ static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, | |||
1101 | } | 1099 | } |
1102 | } | 1100 | } |
1103 | 1101 | ||
1104 | error = security_file_mmap(file, reqprot, prot, flags, addr, 0); | ||
1105 | if (error) | ||
1106 | return error; | ||
1107 | |||
1108 | return mmap_region(file, addr, len, flags, vm_flags, pgoff); | 1102 | return mmap_region(file, addr, len, flags, vm_flags, pgoff); |
1109 | } | 1103 | } |
1110 | 1104 | ||
1111 | unsigned long do_mmap(struct file *file, unsigned long addr, | ||
1112 | unsigned long len, unsigned long prot, | ||
1113 | unsigned long flag, unsigned long offset) | ||
1114 | { | ||
1115 | if (unlikely(offset + PAGE_ALIGN(len) < offset)) | ||
1116 | return -EINVAL; | ||
1117 | if (unlikely(offset & ~PAGE_MASK)) | ||
1118 | return -EINVAL; | ||
1119 | return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); | ||
1120 | } | ||
1121 | EXPORT_SYMBOL(do_mmap); | ||
1122 | |||
1123 | unsigned long vm_mmap(struct file *file, unsigned long addr, | ||
1124 | unsigned long len, unsigned long prot, | ||
1125 | unsigned long flag, unsigned long offset) | ||
1126 | { | ||
1127 | unsigned long ret; | ||
1128 | struct mm_struct *mm = current->mm; | ||
1129 | |||
1130 | down_write(&mm->mmap_sem); | ||
1131 | ret = do_mmap(file, addr, len, prot, flag, offset); | ||
1132 | up_write(&mm->mmap_sem); | ||
1133 | return ret; | ||
1134 | } | ||
1135 | EXPORT_SYMBOL(vm_mmap); | ||
1136 | |||
1137 | SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, | 1105 | SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, |
1138 | unsigned long, prot, unsigned long, flags, | 1106 | unsigned long, prot, unsigned long, flags, |
1139 | unsigned long, fd, unsigned long, pgoff) | 1107 | unsigned long, fd, unsigned long, pgoff) |
@@ -1165,10 +1133,7 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, | |||
1165 | 1133 | ||
1166 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | 1134 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); |
1167 | 1135 | ||
1168 | down_write(¤t->mm->mmap_sem); | 1136 | retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); |
1169 | retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); | ||
1170 | up_write(¤t->mm->mmap_sem); | ||
1171 | |||
1172 | if (file) | 1137 | if (file) |
1173 | fput(file); | 1138 | fput(file); |
1174 | out: | 1139 | out: |
@@ -1629,7 +1594,9 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, | |||
1629 | if (addr & ~PAGE_MASK) | 1594 | if (addr & ~PAGE_MASK) |
1630 | return -EINVAL; | 1595 | return -EINVAL; |
1631 | 1596 | ||
1632 | return arch_rebalance_pgtables(addr, len); | 1597 | addr = arch_rebalance_pgtables(addr, len); |
1598 | error = security_mmap_addr(addr); | ||
1599 | return error ? error : addr; | ||
1633 | } | 1600 | } |
1634 | 1601 | ||
1635 | EXPORT_SYMBOL(get_unmapped_area); | 1602 | EXPORT_SYMBOL(get_unmapped_area); |
@@ -1819,7 +1786,7 @@ int expand_downwards(struct vm_area_struct *vma, | |||
1819 | return -ENOMEM; | 1786 | return -ENOMEM; |
1820 | 1787 | ||
1821 | address &= PAGE_MASK; | 1788 | address &= PAGE_MASK; |
1822 | error = security_file_mmap(NULL, 0, 0, 0, address, 1); | 1789 | error = security_mmap_addr(address); |
1823 | if (error) | 1790 | if (error) |
1824 | return error; | 1791 | return error; |
1825 | 1792 | ||
@@ -2159,7 +2126,6 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) | |||
2159 | 2126 | ||
2160 | return 0; | 2127 | return 0; |
2161 | } | 2128 | } |
2162 | EXPORT_SYMBOL(do_munmap); | ||
2163 | 2129 | ||
2164 | int vm_munmap(unsigned long start, size_t len) | 2130 | int vm_munmap(unsigned long start, size_t len) |
2165 | { | 2131 | { |
@@ -2207,10 +2173,6 @@ static unsigned long do_brk(unsigned long addr, unsigned long len) | |||
2207 | if (!len) | 2173 | if (!len) |
2208 | return addr; | 2174 | return addr; |
2209 | 2175 | ||
2210 | error = security_file_mmap(NULL, 0, 0, 0, addr, 1); | ||
2211 | if (error) | ||
2212 | return error; | ||
2213 | |||
2214 | flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; | 2176 | flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; |
2215 | 2177 | ||
2216 | error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED); | 2178 | error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED); |
@@ -2563,10 +2525,6 @@ int install_special_mapping(struct mm_struct *mm, | |||
2563 | vma->vm_ops = &special_mapping_vmops; | 2525 | vma->vm_ops = &special_mapping_vmops; |
2564 | vma->vm_private_data = pages; | 2526 | vma->vm_private_data = pages; |
2565 | 2527 | ||
2566 | ret = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1); | ||
2567 | if (ret) | ||
2568 | goto out; | ||
2569 | |||
2570 | ret = insert_vm_struct(mm, vma); | 2528 | ret = insert_vm_struct(mm, vma); |
2571 | if (ret) | 2529 | if (ret) |
2572 | goto out; | 2530 | goto out; |