[intel-sgx-kernel-dev,1/3] intel_sgx: check the result of do_eldu
diff mbox

Message ID 20161230161904.20777-2-jarkko.sakkinen@linux.intel.com
State New
Headers show

Commit Message

Jarkko Sakkinen Dec. 30, 2016, 4:19 p.m. UTC
From: Sean Christopherson <sean.j.christopherson@intel.com>

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 <sean.j.christopherson@intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/platform/x86/intel_sgx_vma.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch
diff mbox

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);