diff mbox series

[for_v22,v2,2/8] x86/sgx: Require EADD source to be page aligned

Message ID 20190813011252.4121-3-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series x86/sgx: Remove EADD worker and page copy | expand

Commit Message

Sean Christopherson Aug. 13, 2019, 1:12 a.m. UTC
Reject the EADD ioctl() if the source address provided by userspace is
not page aligned.  Page alignment is required by hardware, but this is
not enforced on userspace as the kernel first copies the source page to
an internal (page aligned) buffer.  Require the userspace address to be
page aligned in preparation for reworking EADD to directly consume the
userspace address.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kernel/cpu/sgx/driver/ioctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jarkko Sakkinen Aug. 16, 2019, 2:15 p.m. UTC | #1
On Mon, Aug 12, 2019 at 06:12:46PM -0700, Sean Christopherson wrote:
> Reject the EADD ioctl() if the source address provided by userspace is
> not page aligned.  Page alignment is required by hardware, but this is
> not enforced on userspace as the kernel first copies the source page to
> an internal (page aligned) buffer.  Require the userspace address to be
> page aligned in preparation for reworking EADD to directly consume the
> userspace address.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

I missed that there was this change.

For most, supporting a fast path does make sense. Removing slow path
needs to be brought up separately in the patch set review.

Even if this is still a patch set, bundling major shifts to semantics
like this is against my maintainer ethics.

I hope you get my point of view here.

/Jarkko
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/sgx/driver/ioctl.c b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
index 9b784a061a47..bc65249ed5df 100644
--- a/arch/x86/kernel/cpu/sgx/driver/ioctl.c
+++ b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
@@ -624,7 +624,8 @@  static long sgx_ioc_enclave_add_page(struct file *filep, void __user *arg)
 	if (copy_from_user(&addp, arg, sizeof(addp)))
 		return -EFAULT;
 
-	if (!IS_ALIGNED(addp.addr, PAGE_SIZE))
+	if (!IS_ALIGNED(addp.addr, PAGE_SIZE) ||
+	    !IS_ALIGNED(addp.src, PAGE_SIZE))
 		return -EINVAL;
 
 	if (addp.addr < encl->base || addp.addr - encl->base >= encl->size)