core: add more overflow checks in ree_fs_ta_open()

Adds more overflow checks in ree_fs_ta_open() and also checks that the
encrypted header (struct shdr_encrypted_ta) also fits in the size of the
TA binary.

The latter check is needed to guard against fabricated values in struct
shdr_encrypted_ta for iv_size and/or tag_size which could trick OP-TEE
to read beyond the end of the buffer where the TA was loaded.

Reading beyond the end of the TA buffer would normally result in a crash
or if there's a valid mappings just after just a failure to load the TA.
No unchecked code will be executed, but it may result in a secure world
crash.

So this commit will check that the iv_size and tag_size values can point
to a valid buffer before attempting to read and thus prevent a crash.

Reviewed-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Ruchika Gupta <ruchika.gupta@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reported-by: Patrik Lantz <Patrik.Lantz@axis.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
1 file changed
tree: 08ac2ec3db2f4397e90302c2aaa29af2524eb36d
  1. .github/
  2. core/
  3. keys/
  4. ldelf/
  5. lib/
  6. mk/
  7. scripts/
  8. ta/
  9. .azure-pipelines.yml
  10. .checkpatch.conf
  11. .gitattributes
  12. .gitignore
  13. .travis.yml
  14. CHANGELOG.md
  15. LICENSE
  16. MAINTAINERS
  17. Makefile
  18. README.md
  19. typedefs.checkpatch
README.md

OP-TEE Trusted OS

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