Skip to content

Commit

Permalink
ashmem: Fix ASHMEM_SET_PROT_MASK.
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Hjønnevåg <arve@android.com>
CC: Brian Swetland <swetland@google.com>
CC: Colin Cross <ccross@android.com>
CC: Arve Hjønnevåg <arve@android.com>
CC: Dima Zavin <dima@android.com>
CC: Robert Love <rlove@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Arve Hjønnevåg authored and Greg Kroah-Hartman committed Dec 21, 2011
1 parent 853ca7a commit 56f76fc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ static ssize_t ashmem_read(struct file *file, char __user *buf,
return ret;
}

static inline unsigned long
calc_vm_may_flags(unsigned long prot)
{
return _calc_vm_trans(prot, PROT_READ, VM_MAYREAD ) |
_calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |
_calc_vm_trans(prot, PROT_EXEC, VM_MAYEXEC);
}

static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
{
Expand All @@ -251,10 +258,12 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
}

/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~asma->prot_mask) & PROT_MASK)) {
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask)) &
calc_vm_prot_bits(PROT_MASK))) {
ret = -EPERM;
goto out;
}
vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask);

if (!asma->file) {
char *name = ASHMEM_NAME_DEF;
Expand Down

0 comments on commit 56f76fc

Please sign in to comment.