From: Jingyi Sun <1045704958@qq.com>
To: Jens Wiklander <jenswi@kernel.org>, Sumit Garg <sumit.garg@kernel.org>
Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org,
Jingyi Sun <1045704958@qq.com>
Subject: [PATCH 0/2] tee: avoid phys_addr_t truncation in protected memory pools
Date: Sun, 6 Dec 2026 19:38:11 +0800 [thread overview]
Message-ID: <tencent_7DAE54F40875C253A281B7A09D9EB8BFEA0A@qq.com> (raw)
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
reply other threads:[~2026-12-06 11:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_7DAE54F40875C253A281B7A09D9EB8BFEA0A@qq.com \
--to=1045704958@qq.com \
--cc=jenswi@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=op-tee@lists.trustedfirmware.org \
--cc=sumit.garg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®