U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pranav Rajendran <pranavkasthuri@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: philippe.reynes@softathome.com, trini@konsulko.com,
	Pranav Rajendran <pranavkasthuri@gmail.com>
Subject: [PATCH v1 0/3] fit: cipher: bounds checks on the ciphered image path
Date: Sat, 15 Aug 2026 23:07:51 +0100	[thread overview]
Message-ID: <20260815220754.11724-1-pranavkasthuri@gmail.com> (raw)

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)


             reply	other threads:[~2026-08-15 22:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15 22:07 Pranav Rajendran [this message]
2026-08-15 22:07 ` [PATCH v1 1/3] lib: aes: reject a ciphertext length that is not a whole number of blocks Pranav Rajendran
2026-08-25 12:52   ` Simon Glass
2026-08-15 22:07 ` [PATCH v1 2/3] image-fit: check the length of the data-size-unciphered property Pranav Rajendran
2026-08-25 12:52   ` Simon Glass
2026-08-15 22:07 ` [PATCH v1 3/3] lib: aes: reject an unciphered size larger than the ciphertext Pranav Rajendran
2026-08-25 12:52   ` Simon Glass
2026-08-25 12:53 ` [v1,0/3] fit: cipher: bounds checks on the ciphered image path Simon Glass
2026-08-25 14:19 ` [PATCH v2 0/5] " Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 1/5] lib: aes: reject a ciphertext length that is not a whole number of blocks Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 2/5] image-fit: check the length of the data-size-unciphered property Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 3/5] lib: aes: reject an unciphered size larger than the ciphertext Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 4/5] include: u-boot: aes: make disabled cipher stubs static inline Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 5/5] test: boot: add regression tests for the FIT cipher bounds checks Pranav Rajendran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260815220754.11724-1-pranavkasthuri@gmail.com \
    --to=pranavkasthuri@gmail.com \
    --cc=philippe.reynes@softathome.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox