mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] tee: avoid phys_addr_t truncation in protected memory pools
@ 2026-12-06 11:38 Jingyi Sun
  0 siblings, 0 replies; only message in thread
From: Jingyi Sun @ 2026-12-06 11:38 UTC (permalink / raw)
  To: Jens Wiklander, Sumit Garg; +Cc: op-tee, linux-kernel, Jingyi Sun

Both the static protected memory pool in drivers/tee/tee_heap.c and the
dynamic protected memory pool in drivers/tee/optee/protmem.c pass 64-bit
phys_addr_t values directly to gen_pool_add(), gen_pool_alloc(), and
gen_pool_free(). Because gen_pool tracks addresses as unsigned long and
treats 0 as an allocation failure, physical addresses at or above 4 GiB
on 32-bit LPAE kernels silently lose their upper 32 bits, leading to
false -ENOMEM errors, wrong struct page mappings, and offset underflows.

Switch both pools to use gen_pool_add_virt() with PAGE_SIZE as a non-zero
synthetic virtual base and gen_pool_virt_to_phys() on allocation
(matching drivers/tee/tee_shm_pool.c), and validate that the pool size
is non-zero and does not overflow the synthetic range.

Jingyi Sun (2):
  tee: avoid phys_addr_t truncation in static protected memory pool
  optee: avoid phys_addr_t truncation in dynamic protected memory pool

 drivers/tee/optee/protmem.c | 21 +++++++++++++++------
 drivers/tee/tee_heap.c      | 19 ++++++++++++-------
 2 files changed, 27 insertions(+), 13 deletions(-)


base-commit: 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-06 11:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-06 11:38 [PATCH 0/2] tee: avoid phys_addr_t truncation in protected memory pools Jingyi Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®