From patchwork Tue Oct 10 16:33:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 9996693 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 5F54560216 for ; Tue, 10 Oct 2017 16:33:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F87E286AB for ; Tue, 10 Oct 2017 16:33:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42D28286AE; Tue, 10 Oct 2017 16:33:59 +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 E3E2D286AB for ; Tue, 10 Oct 2017 16:33:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D7B6521F3C194; Tue, 10 Oct 2017 09:30:29 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=jarkko.sakkinen@linux.intel.com; receiver=intel-sgx-kernel-dev@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 A4DEC21F3C194 for ; Tue, 10 Oct 2017 09:30:28 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2017 09:33:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.43,358,1503385200"; d="scan'208"; a="1204311929" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.92]) by fmsmga001.fm.intel.com with ESMTP; 10 Oct 2017 09:33:54 -0700 From: Jarkko Sakkinen To: intel-sgx-kernel-dev@lists.01.org Date: Tue, 10 Oct 2017 19:33:48 +0300 Message-Id: <20171010163348.6521-1-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.14.1 Subject: [intel-sgx-kernel-dev] [PATCH] intel_sgx: fix leak of a backing page in sgx_process_add_page_req() X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: =?iso-8859-1?q?Project=3A_Intel=AE_Software_Guard_Extensions_for_Linux*=3A_https=3A//01=2Eorg/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 Reported-by: Shay Katz-zamir Signed-off-by: Jarkko Sakkinen --- drivers/platform/x86/intel_sgx/sgx_encl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_sgx/sgx_encl.c b/drivers/platform/x86/intel_sgx/sgx_encl.c index aa0deed08cee..4a28cbb2baba 100644 --- a/drivers/platform/x86/intel_sgx/sgx_encl.c +++ b/drivers/platform/x86/intel_sgx/sgx_encl.c @@ -251,8 +251,10 @@ static bool sgx_process_add_page_req(struct sgx_add_page_req *req, } ret = vm_insert_pfn(vma, encl_page->addr, PFN_DOWN(epc_page->pa)); - if (ret) + if (ret) { + sgx_put_backing(backing, 0); return false; + } ret = sgx_eadd(encl->secs.epc_page, epc_page, encl_page->addr, &req->secinfo, backing);