Merge pull request #20 from ricmm/fix-new-kernels

Add protection key to calc_vm_prot_bits() on kernels >= 4.5.0
This commit is contained in:
Simon Fels 2017-01-18 14:15:57 +01:00 committed by GitHub
commit 509055876b

View file

@ -33,6 +33,7 @@
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/shmem_fs.h>
#include <linux/version.h>
#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;
}