From 498513c7abeb6b0ee3ea551e9dafed81644b4730 Mon Sep 17 00:00:00 2001 From: Ricardo Mendoza Date: Wed, 18 Jan 2017 14:13:38 +0100 Subject: [PATCH] Add protection key to calc_vm_prot_bits() if building under kernel >= 4.5.0 --- kernel/ashmem/ashmem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/ashmem/ashmem.c b/kernel/ashmem/ashmem.c index d12ce74..c846db6 100644 --- a/kernel/ashmem/ashmem.c +++ b/kernel/ashmem/ashmem.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "ashmem.h" #define ASHMEM_NAME_PREFIX "dev/ashmem/" @@ -373,8 +374,13 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) } /* requested protection bits must match our allowed protection mask */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) + if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) & + calc_vm_prot_bits(PROT_MASK, 0))) { +#else if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask)) & calc_vm_prot_bits(PROT_MASK))) { +#endif ret = -EPERM; goto out; }