aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2011-12-20 19:49:50 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-21 16:40:23 -0500
commit56f76fc68492af718fff88927bc296635d634b78 (patch)
treea0ae1c024fb951ad978451fae16a8789d8412c8a /drivers/staging
parent853ca7ae292f9c4809e1e42914e81453eaa15367 (diff)
ashmem: Fix ASHMEM_SET_PROT_MASK.
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/android/ashmem.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 6f1a0bbc9a5..0b923b01da5 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -236,6 +236,13 @@ out:
236 return ret; 236 return ret;
237} 237}
238 238
239static inline unsigned long
240calc_vm_may_flags(unsigned long prot)
241{
242 return _calc_vm_trans(prot, PROT_READ, VM_MAYREAD ) |
243 _calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |
244 _calc_vm_trans(prot, PROT_EXEC, VM_MAYEXEC);
245}
239 246
240static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) 247static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
241{ 248{
@@ -251,10 +258,12 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
251 } 258 }
252 259
253 /* requested protection bits must match our allowed protection mask */ 260 /* requested protection bits must match our allowed protection mask */
254 if (unlikely((vma->vm_flags & ~asma->prot_mask) & PROT_MASK)) { 261 if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask)) &
262 calc_vm_prot_bits(PROT_MASK))) {
255 ret = -EPERM; 263 ret = -EPERM;
256 goto out; 264 goto out;
257 } 265 }
266 vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask);
258 267
259 if (!asma->file) { 268 if (!asma->file) {
260 char *name = ASHMEM_NAME_DEF; 269 char *name = ASHMEM_NAME_DEF;