From patchwork Fri Dec 16 02:50:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5796 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 64B1824055 for ; Fri, 16 Dec 2011 02:51:24 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5C103A18971 for ; Fri, 16 Dec 2011 02:51:24 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id k10so3114749eaa.11 for ; Thu, 15 Dec 2011 18:51:24 -0800 (PST) Received: by 10.204.157.12 with SMTP id z12mr2642814bkw.18.1324003884157; Thu, 15 Dec 2011 18:51:24 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs59558bkc; Thu, 15 Dec 2011 18:51:24 -0800 (PST) Received: by 10.68.197.161 with SMTP id iv1mr13182713pbc.25.1324003880976; Thu, 15 Dec 2011 18:51:20 -0800 (PST) Received: from e3.ny.us.ibm.com (e3.ny.us.ibm.com. [32.97.182.143]) by mx.google.com with ESMTPS id k1si12484534pbh.51.2011.12.15.18.51.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Dec 2011 18:51:20 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.143 as permitted sender) client-ip=32.97.182.143; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.143 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 21:51:19 -0500 Received: from d01relay01.pok.ibm.com (9.56.227.233) by e3.ny.us.ibm.com (192.168.1.103) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Dec 2011 21:51:17 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBG2pGw4290852; Thu, 15 Dec 2011 21:51:16 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBG2pEXw009592; Fri, 16 Dec 2011 00:51:16 -0200 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBG2pDgF009547; Fri, 16 Dec 2011 00:51:14 -0200 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 4CEEA1E7500; Thu, 15 Dec 2011 18:51:12 -0800 (PST) From: John Stultz To: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Brian Swetland , Colin Cross , Dima Zavin , Robert Love , Greg KH , John Stultz Subject: [PATCH 05/10] ashmem: Fix ASHMEM_SET_PROT_MASK. Date: Thu, 15 Dec 2011 18:50:59 -0800 Message-Id: <1324003864-26776-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1324003864-26776-1-git-send-email-john.stultz@linaro.org> References: <1324003864-26776-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11121602-8974-0000-0000-00000448214A From: Arve Hjønnevåg Change-Id: I1412cc9560de8c4feb1162fc30922f0e3362a476 Signed-off-by: Arve Hjønnevåg CC: Brian Swetland CC: Colin Cross CC: Arve Hjønnevåg CC: Dima Zavin CC: Robert Love CC: Greg KH Signed-off-by: John Stultz --- drivers/staging/android/ashmem.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 6f1a0bb..0b923b0 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -236,6 +236,13 @@ out: 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) { @@ -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;