[intel-sgx-kernel-dev,1/3] intel_sgx: Abort sgx_vma_do_fault if do_eldu fails
diff mbox

Message ID 1483477647-12054-2-git-send-email-sean.j.christopherson@intel.com
State New
Headers show

Commit Message

Sean Christopherson Jan. 3, 2017, 9:07 p.m. UTC
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 drivers/platform/x86/intel_sgx_vma.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Jarkko Sakkinen Jan. 4, 2017, 1:48 p.m. UTC | #1
On Tue, Jan 03, 2017 at 01:07:25PM -0800, Sean Christopherson wrote:
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>

/Jarkko

> ---
>  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);
>  
> -- 
> 2.7.4
> 
> _______________________________________________
> intel-sgx-kernel-dev mailing list
> intel-sgx-kernel-dev@lists.01.org
> https://lists.01.org/mailman/listinfo/intel-sgx-kernel-dev

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