commit | 13a26601fb269c3e5da27de97288b9fcd63b61a2 | [log] [tgz] |
---|---|---|
author | Jerome Forissier <jerome.forissier@linaro.org> | Tue Mar 12 16:21:10 2019 +0100 |
committer | Jérôme Forissier <jerome.forissier@linaro.org> | Mon May 13 15:58:03 2019 +0200 |
tree | 60f6343978c9172436684d2bdbb66ea8042d594d | |
parent | cc6bc5f94210ea24b774c997fd482c936735db71 [diff] |
core: thread: use READ_ONCE() when accessing data in shared memory In some places we read a value from shared memory, then based on the value we take some actions. When multiple tests are done, we should make sure that the value is not read multiple times because there is no guarantee that Normal World has not changed the value in the mean time, which could break the logic. Consider for instance: if (shared && shared->value) do_something(); If "shared" resides in shared memory, it might change between "if (shared)" and "if (shared->value)". If it happens to be set to NULL for example, the code will crash. To ensure consistency, a temporary variable has to be used to hold the value, and the READ_ONCE() macro is required to prevent the compiler from emitting multiple loads of the memory location. Reported-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
This git contains source code for the secure side implementation of OP-TEE project.
All official OP-TEE documentation has moved to http://optee.readthedocs.io.
// OP-TEE core maintainers