x86/sgx: Create utility to validate user provided offset and length
authorReinette Chatre <reinette.chatre@intel.com>
Tue, 10 May 2022 18:08:46 +0000 (11:08 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Dec 2022 16:41:00 +0000 (17:41 +0100)
commitb5a838ba47f285aa123eb08c0c790b1345c41859
treec35fd0e30ff8d0f6159060033588463a91b98029
parent2f6e2de3a5289004650118b61f138fe7c28e1905
x86/sgx: Create utility to validate user provided offset and length

[ Upstream commit dda03e2c331b9fc7bbc8fc0de12a6d92d8c18661 ]

User provided offset and length is validated when parsing the parameters
of the SGX_IOC_ENCLAVE_ADD_PAGES ioctl(). Extract this validation
(with consistent use of IS_ALIGNED) into a utility that can be used
by the SGX2 ioctl()s that will also provide these values.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lkml.kernel.org/r/767147bc100047abed47fe27c592901adfbb93a2.1652137848.git.reinette.chatre@intel.com
Stable-dep-of: f0861f49bd94 ("x86/sgx: Add overflow check in sgx_validate_offset_length()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/cpu/sgx/ioctl.c