linux/arch
Jarkko Sakkinen 6d099f3f7b x86/sgx: Fix size overflows in sgx_encl_create()
[ Upstream commit 0d3e0dfd68 ]

The total size calculated for EPC can overflow u64 given the added up page
for SECS.  Further, the total size calculated for shmem can overflow even
when the EPC size stays within limits of u64, given that it adds the extra
space for 128 byte PCMD structures (one for each page).

Address this by pre-evaluating the micro-architectural requirement of
SGX: the address space size must be power of two. This is eventually
checked up by ECREATE but the pre-check has the additional benefit of
making sure that there is some space for additional data.

Fixes: 888d249117 ("x86/sgx: Add SGX_IOC_ENCLAVE_CREATE")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20250305050006.43896-1-jarkko@kernel.org

Closes: https://lore.kernel.org/linux-sgx/c87e01a0-e7dd-4749-a348-0980d3444f04@stanley.mountain/
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-03-13 12:51:06 +01:00
..
alpha alpha: replace hardcoded stack offsets with autogenerated ones 2025-03-13 12:50:45 +01:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:28:49 +01:00
arm ARM: dts: dra7: Add bus_dma_limit for l4 cfg bus 2025-03-13 12:50:46 +01:00
arm64 arm64: dts: mediatek: mt8183: Disable DSI display output by default 2025-03-13 12:50:49 +01:00
csky csky, hexagon: fix broken sys_sync_file_range 2024-07-05 09:14:48 +02:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-01 08:27:21 +01:00
hexagon hexagon: Fix unbalanced spinlock in die() 2025-03-13 12:50:14 +01:00
ia64 arch: Introduce CONFIG_FUNCTION_ALIGNMENT 2024-04-10 16:18:49 +02:00
m68k m68k: vga: Fix I/O defines 2025-03-13 12:50:23 +01:00
microblaze microblaze: don't treat zero reserved memory regions as error 2024-10-17 15:10:38 +02:00
mips MIPS: ftrace: Declare ftrace_get_parent_ra_addr() as static 2025-03-13 12:50:33 +01:00
nds32 exit: Add and use make_task_dead. 2023-02-01 08:27:20 +01:00
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:59:14 +02:00
openrisc openrisc: Call setup_memory() earlier in the init sequence 2024-09-04 13:23:27 +02:00
parisc Revert "parisc: fix a possible DMA corruption" 2024-12-19 18:07:22 +01:00
powerpc powerpc/code-patching: Fix KASAN hit by not flagging text patching area as VM_ALLOC 2025-03-13 12:50:52 +01:00
riscv riscv: Fix sleeping in invalid context in die() 2025-01-23 17:15:52 +01:00
s390 s390/traps: Fix test_monitor_call() inline assembly 2025-03-13 12:51:03 +01:00
sh sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2024-12-14 19:51:16 +01:00
sparc sparc64: Fix incorrect function signature and add prototype for prom_cif_init 2024-08-19 05:45:04 +02:00
um um: Always dump trace for specified task in show_stack 2024-12-14 19:51:19 +01:00
x86 x86/sgx: Fix size overflows in sgx_encl_create() 2025-03-13 12:51:06 +01:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-06 13:18:14 +02:00
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-05-02 16:24:48 +02:00