Skip to content

core: libtomcrypt: increase MPI_MEMPOOL_SIZE to 46kB#5065

Merged
jforissier merged 1 commit intoOP-TEE:masterfrom
sahilnxp:mempool
Dec 17, 2021
Merged

core: libtomcrypt: increase MPI_MEMPOOL_SIZE to 46kB#5065
jforissier merged 1 commit intoOP-TEE:masterfrom
sahilnxp:mempool

Conversation

@sahilnxp
Copy link
Copy Markdown
Contributor

This value is increased because xtest pkcs11_1019 when run
in loop, leads to extensive use of memory pool which
sometimes leads to memory allocation failure.

Problem is the way mempool_alloc() is implemented in combination
with how it's used from ltc_ecc_projective_add_point().

mempool_alloc() has a stack like allocation scheme. When freeing
the top element that memory is returned to the pool, but if memory
further down is free it's not returned until all elements above has
been freed. If two or more elements gets allocated and freed in a
cycle they can continue to use more and more memory with nothing
returned.

Signed-off-by: Sahil Malhotra [email protected]
Fixes: #5022

@jenswi-linaro
Copy link
Copy Markdown
Contributor

Reviewed-by: Jens Wiklander <[email protected]>

@sahilnxp
Copy link
Copy Markdown
Contributor Author

Reviewed-by: Jens Wiklander <[email protected]>

Tag updated

Copy link
Copy Markdown
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acked-by: Etienne Carriere <[email protected]>

This value is increased because xtest pkcs11_1019 when run
in loop, leads to extensive use of memory pool which
sometimes leads to memory allocation failure.

Problem is the way mempool_alloc() is implemented in combination
with how it's used from ltc_ecc_projective_add_point().

mempool_alloc() has a stack like allocation scheme. When freeing
the top element that memory is returned to the pool, but if memory
further down is free it's not returned until all elements above has
been freed. If two or more elements gets allocated and freed in a
cycle they can continue to use more and more memory with nothing
returned.

Signed-off-by: Sahil Malhotra <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
Fixes: OP-TEE#5022
@sahilnxp
Copy link
Copy Markdown
Contributor Author

Acked-by: Etienne Carriere <[email protected]>

Tag updated

@jforissier jforissier merged commit bfb19bc into OP-TEE:master Dec 17, 2021
@sahilnxp sahilnxp deleted the mempool branch November 14, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NXP: i.MX and LS Platforms: Stability issue with PKCS11 TA

4 participants