Skip to content

Commit

Permalink
core: mm: fix mobj_tee_ram_rw initialization
Browse files Browse the repository at this point in the history
Until this patch, for CFG_CORE_RWDATA_NOEXEC=n and CFG_CORE_ASLR=y
there's an error in mobj_init() when the length of the combined
TEE_RAM_RWX is calculated.

The relocatable address VCORE_UNPG_RW_PA is mixed with the absolute
address TEE_RAM_START. Relocated addresses only changes with
CFG_CORE_ASLR=y so before ASLR this expression was correct.

The combined TEE_RAM_RWX is only used with CFG_CORE_RWDATA_NOEXEC=n so
that is also a perquisite for the error. The calculated length field is
usually not more wrong than code depending on
mobj_tee_ram_rw/mobj_tee_ram_rx still works. So the error wasn't visible
until length checks for phys_to_virt() was introduced with the commit
c2e4eb4 ("core_mmu: fix phys_to_virt() to check length").

Fix this by using VCORE_START_VA instead of TEE_RAM_START since the
former is a relocated address.

Fixes: c2e4eb4 ("core_mmu: fix phys_to_virt() to check length")
Fixes: 170e908 ("core: add support for CFG_CORE_ASLR")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jenswi-linaro committed Oct 21, 2024
1 parent 1868eb2 commit e280c55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/mm/mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ static TEE_Result mobj_init(void)
mobj_tee_ram_rw = mobj_phys_init(TEE_RAM_START,
VCORE_UNPG_RW_PA +
VCORE_UNPG_RW_SZ -
TEE_RAM_START,
VCORE_START_VA,
TEE_MATTR_MEM_TYPE_CACHED,
CORE_MEM_TEE_RAM,
MEM_AREA_TEE_RAM_RW_DATA);
Expand Down

0 comments on commit e280c55

Please sign in to comment.