Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: hi16xx_rng: replace mutex with spinlock #2440

Merged
merged 1 commit into from
Jul 4, 2018

Conversation

jforissier
Copy link
Contributor

hw_get_random_byte() may be called from a context where mutexes are not
allowed. Use a spinlock instead.

Fixes: #2437
Signed-off-by: Jerome Forissier jerome.forissier@linaro.org

@jforissier
Copy link
Contributor Author

Wrong analysis. There should be no problem with the use of a mutex in hw_get_random_byte(), because fortuna_read(), which is called instead of hw_get_random_byte() by crypto_rng_read() when CFG_WITH_SOFTWARE_PRNG is enabled, does use a mutex.

I'm keeping this PR because I think a spinlock still makes senses here, being more lightweight. I would change the commit text however.

@jenswi-linaro
Copy link
Contributor

With the commit message updated:
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

The mutex in hw_get_random_byte() protects a very short section of code.
A spinlock is more lightweight and therefore better suited to the task.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
@jforissier jforissier merged commit 6c9c7a3 into OP-TEE:master Jul 4, 2018
@jforissier jforissier deleted the d02-rng-fix branch July 4, 2018 15:56
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.

2 participants