[PATCH v1 0/3] fit: cipher: bounds checks on the ciphered image path
Pranav Rajendran <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
Three fixes in the FIT cipher path, found while auditing for image-
controlled values used as buffer lengths without validation. They were
reported to the list earlier; these are the fixes.
Patch 1 is an out-of-bounds write. image_aes_decrypt() sizes its output
buffer with cipher_len but decrypts DIV_ROUND_UP(cipher_len, block)
blocks into it, so a 'data' length that is not block aligned writes past
the end of the allocation.
Patches 2 and 3 are the two halves of the unciphered size never being
checked: the 'data-size-unciphered' property is read without asking for
its length, and the value it yields is never related to the amount of
data that was actually decrypted. The second matters because that
property sits outside the per-image hash and signature, so it can be
changed on a signed FIT without disturbing verification.
I have kept them as separate patches since they are independent defects
with different consequences, but I am happy to squash 1 and 3 if you
would rather have one change per function.
checkpatch-clean, builds for sandbox (CONFIG_FIT_CIPHER=y) with no new
warnings at W=1, and no change in test/py results.
Pranav Rajendran (3):
lib: aes: reject a ciphertext length that is not a whole number of
blocks
image-fit: check the length of the data-size-unciphered property
lib: aes: reject an unciphered size larger than the ciphertext
boot/image-fit.c | 6 +++++-
lib/aes/aes-decrypt.c | 21 ++++++++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
--
2.50.1 (Apple Git-155)