aboutsummaryrefslogtreecommitdiff
path: root/core/lib
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2019-02-05 13:05:29 +0100
committerJérôme Forissier <jerome.forissier@linaro.org>2019-02-05 17:18:18 +0100
commitb2dd8747125be413f9b8b7fd7e52f457cabd709c (patch)
treefe55c2f8fccd2b6e0d3e5a330d66ef8b5bd4a45b /core/lib
parenta9392ffc9395dfb289084be923551d8e12cad247 (diff)
Fix alignment of data for mempool_alloc_pool()
Prior to this patch was _TEE_MathAPI_Init() in lib/libutee/tee_api_arith_mpi.c supplying a data buffer which was only 4 byte aligned while mempool_alloc_pool() requires the alignment of long. This will work in 32-bit mode, but could lead to alignment problem in 64-bit mode. The same problem can happen with lib/libutee/tee_api_arith_mpa.c, but so far it has remained hidden. Incorrect alignment can result in errors like: E/TA: assertion '!((vaddr_t)data & (POOL_ALIGN - 1))' failed at lib/libutils/ext/mempool.c:134 in mempool_alloc_pool() This fix introduces MEMPOOL_ALIGN which specifies required alignment of data supplied to mempool_alloc_pool(). Fixes: 062e3d01c039 ("ta: switch to to mbedtls for bignum") Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU v8) Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/lib')
-rw-r--r--core/lib/libtomcrypt/src/mpa_desc.c2
-rw-r--r--core/lib/libtomcrypt/src/mpi_desc.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/lib/libtomcrypt/src/mpa_desc.c b/core/lib/libtomcrypt/src/mpa_desc.c
index b407f54e..58aa2427 100644
--- a/core/lib/libtomcrypt/src/mpa_desc.c
+++ b/core/lib/libtomcrypt/src/mpa_desc.c
@@ -40,7 +40,7 @@ static struct mempool *get_mpa_scratch_memory_pool(void)
#else /* CFG_WITH_PAGER */
static struct mempool *get_mpa_scratch_memory_pool(void)
{
- static uint32_t data[LTC_MEMPOOL_U32_SIZE] __aligned(__alignof__(long));
+ static uint32_t data[LTC_MEMPOOL_U32_SIZE] __aligned(MEMPOOL_ALIGN);
return mempool_alloc_pool(data, sizeof(data), NULL);
}
diff --git a/core/lib/libtomcrypt/src/mpi_desc.c b/core/lib/libtomcrypt/src/mpi_desc.c
index a43fbb42..67bc3a72 100644
--- a/core/lib/libtomcrypt/src/mpi_desc.c
+++ b/core/lib/libtomcrypt/src/mpi_desc.c
@@ -38,7 +38,7 @@ static struct mempool *get_mp_scratch_memory_pool(void)
#else /* CFG_WITH_PAGER */
static struct mempool *get_mp_scratch_memory_pool(void)
{
- static uint8_t data[MPI_MEMPOOL_SIZE] __aligned(__alignof__(long));
+ static uint8_t data[MPI_MEMPOOL_SIZE] __aligned(MEMPOOL_ALIGN);
return mempool_alloc_pool(data, sizeof(data), NULL);
}