Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198630
b: refs/heads/master
c: 3c7b204
h: refs/heads/master
v: v3
  • Loading branch information
Bernd Schmidt authored and Linus Torvalds committed May 26, 2010
1 parent d3a7daa commit e43c79d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0cae3457b1a6e88f31020272bcfd90c178716053
refs/heads/master: 3c7b204547bc3d342a4e31196fe14803581d279f
32 changes: 18 additions & 14 deletions trunk/mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,14 +918,6 @@ static int validate_mmap_request(struct file *file,
if (!(capabilities & BDI_CAP_MAP_DIRECT))
return -ENODEV;

if (((prot & PROT_READ) && !(capabilities & BDI_CAP_READ_MAP)) ||
((prot & PROT_WRITE) && !(capabilities & BDI_CAP_WRITE_MAP)) ||
((prot & PROT_EXEC) && !(capabilities & BDI_CAP_EXEC_MAP))
) {
printk("MAP_SHARED not completely supported on !MMU\n");
return -EINVAL;
}

/* we mustn't privatise shared mappings */
capabilities &= ~BDI_CAP_MAP_COPY;
}
Expand All @@ -941,6 +933,20 @@ static int validate_mmap_request(struct file *file,
capabilities &= ~BDI_CAP_MAP_DIRECT;
}

if (capabilities & BDI_CAP_MAP_DIRECT) {
if (((prot & PROT_READ) && !(capabilities & BDI_CAP_READ_MAP)) ||
((prot & PROT_WRITE) && !(capabilities & BDI_CAP_WRITE_MAP)) ||
((prot & PROT_EXEC) && !(capabilities & BDI_CAP_EXEC_MAP))
) {
capabilities &= ~BDI_CAP_MAP_DIRECT;
if (flags & MAP_SHARED) {
printk(KERN_WARNING
"MAP_SHARED not completely supported on !MMU\n");
return -EINVAL;
}
}
}

/* handle executable mappings and implied executable
* mappings */
if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) {
Expand Down Expand Up @@ -996,22 +1002,20 @@ static unsigned long determine_vm_flags(struct file *file,
unsigned long vm_flags;

vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
vm_flags |= VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
/* vm_flags |= mm->def_flags; */

if (!(capabilities & BDI_CAP_MAP_DIRECT)) {
/* attempt to share read-only copies of mapped file chunks */
vm_flags |= VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
if (file && !(prot & PROT_WRITE))
vm_flags |= VM_MAYSHARE;
}
else {
} else {
/* overlay a shareable mapping on the backing device or inode
* if possible - used for chardevs, ramfs/tmpfs/shmfs and
* romfs/cramfs */
vm_flags |= VM_MAYSHARE | (capabilities & BDI_CAP_VMFLAGS);
if (flags & MAP_SHARED)
vm_flags |= VM_MAYSHARE | VM_SHARED;
else if ((((vm_flags & capabilities) ^ vm_flags) & BDI_CAP_VMFLAGS) == 0)
vm_flags |= VM_MAYSHARE;
vm_flags |= VM_SHARED;
}

/* refuse to let anyone share private mappings with this process if
Expand Down

0 comments on commit e43c79d

Please sign in to comment.