From patchwork Fri Aug 18 18:42:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angie Chinchilla X-Patchwork-Id: 9909771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20661600CC for ; Fri, 18 Aug 2017 18:43:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC1728867 for ; Fri, 18 Aug 2017 18:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00C3828D43; Fri, 18 Aug 2017 18:43:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B33C028867 for ; Fri, 18 Aug 2017 18:43:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 667C321E79020; Fri, 18 Aug 2017 11:40:13 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3DAC321E79008 for ; Fri, 18 Aug 2017 11:40:12 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 18 Aug 2017 11:42:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.41,393,1498546800"; d="scan'208"; a="1184367029" Received: from skl-edmm.rd.intel.com ([10.243.12.156]) by fmsmga001.fm.intel.com with ESMTP; 18 Aug 2017 11:42:39 -0700 From: Angie Chinchilla To: intel-sgx-kernel-dev@lists.01.org Date: Fri, 18 Aug 2017 14:42:39 -0400 Message-Id: <1503081759-7979-1-git-send-email-angie.v.chinchilla@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [intel-sgx-kernel-dev] [PATCH] Change mmap_sem lock to write in enclave_create X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Project: Intel® Software Guard Extensions for Linux*: https://01.org/intel-software-guard-extensions" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-sgx-kernel-dev-bounces@lists.01.org Sender: "intel-sgx-kernel-dev" X-Virus-Scanned: ClamAV using ClamSMTP Change mmap_sem lock to write for writing to vma in enclave_create. Signed-off-by: Angie Chinchilla --- drivers/platform/x86/intel_sgx/sgx_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel_sgx/sgx_ioctl.c b/drivers/platform/x86/intel_sgx/sgx_ioctl.c index 1f2a269..85770ae 100644 --- a/drivers/platform/x86/intel_sgx/sgx_ioctl.c +++ b/drivers/platform/x86/intel_sgx/sgx_ioctl.c @@ -524,17 +524,17 @@ static long sgx_ioc_enclave_create(struct file *filep, unsigned int cmd, goto out; } - down_read(¤t->mm->mmap_sem); + down_write(¤t->mm->mmap_sem); vma = find_vma(current->mm, secs->base); if (!vma || vma->vm_ops != &sgx_vm_ops || vma->vm_start != secs->base || vma->vm_end != (secs->base + secs->size)) { ret = -EINVAL; - up_read(¤t->mm->mmap_sem); + up_write(¤t->mm->mmap_sem); goto out; } vma->vm_private_data = encl; - up_read(¤t->mm->mmap_sem); + up_write(¤t->mm->mmap_sem); mutex_lock(&sgx_tgid_ctx_mutex); list_add_tail(&encl->encl_list, &encl->tgid_ctx->encl_list);