From patchwork Fri Dec 30 16:19:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 9492317 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 D13C762AB9 for ; Fri, 30 Dec 2016 16:19:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDF421FF15 for ; Fri, 30 Dec 2016 16:19:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2B6322638; Fri, 30 Dec 2016 16:19:14 +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 75F471FF15 for ; Fri, 30 Dec 2016 16:19:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 746C481864 for ; Fri, 30 Dec 2016 08:19:14 -0800 (PST) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 7EE3281864 for ; Fri, 30 Dec 2016 08:19:12 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP; 30 Dec 2016 08:19:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="47862453" Received: from arsehgal-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.6.21]) by orsmga005.jf.intel.com with ESMTP; 30 Dec 2016 08:19:10 -0800 From: Jarkko Sakkinen To: intel-sgx-kernel-dev@lists.01.org Date: Fri, 30 Dec 2016 18:19:02 +0200 Message-Id: <20161230161904.20777-2-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161230161904.20777-1-jarkko.sakkinen@linux.intel.com> References: <20161230161904.20777-1-jarkko.sakkinen@linux.intel.com> Subject: [intel-sgx-kernel-dev] [PATCH 1/3] intel_sgx: check the result of do_eldu X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.21 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 From: Sean Christopherson If ELDU returned an error, it was not properly checked. This commit fixes the issue. [jarkko.sakinen@linux.intel.com: I derived this commit from a small part of another commit done by Sean that did some additional stuff.] Signed-off-by: Sean Christopherson Signed-off-by: Jarkko Sakkinen --- drivers/platform/x86/intel_sgx_vma.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_sgx_vma.c b/drivers/platform/x86/intel_sgx_vma.c index c7b406b..e8a67b6 100644 --- a/drivers/platform/x86/intel_sgx_vma.c +++ b/drivers/platform/x86/intel_sgx_vma.c @@ -243,7 +243,13 @@ static struct sgx_encl_page *sgx_vma_do_fault(struct vm_area_struct *vma, goto out; } - do_eldu(encl, entry, epc_page, backing, false /* is_secs */); + rc = do_eldu(encl, entry, epc_page, backing, false /* is_secs */); + if (rc) { + sgx_put_backing(backing, 0); + entry = ERR_PTR(rc); + goto out; + } + rc = vm_insert_pfn(vma, entry->addr, PFN_DOWN(epc_page->pa)); sgx_put_backing(backing, 0);