Message ID | 20191010225530.26400-3-sean.j.christopherson@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/sgx: Fix add page bugs | expand |
diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c index 62965d003fda..61a2a7b6677e 100644 --- a/arch/x86/kernel/cpu/sgx/ioctl.c +++ b/arch/x86/kernel/cpu/sgx/ioctl.c @@ -492,6 +492,9 @@ static long sgx_ioc_enclave_add_page(struct sgx_encl *encl, void __user *arg) !IS_ALIGNED(addp.src, PAGE_SIZE)) return -EINVAL; + if (!(access_ok(addp.src, PAGE_SIZE))) + return -EFAULT; + if (addp.addr < encl->base || addp.addr - encl->base >= encl->size) return -EINVAL;
Add an explicit access_ok() check on EADD's source page to avoid passing garbage to gup(). Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- arch/x86/kernel/cpu/sgx/ioctl.c | 3 +++ 1 file changed, 3 insertions(+)