summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2026-08-20 08:47:42 -0600
committerTom Rini <[email protected]>2026-08-20 12:15:24 -0600
commitacd4ac0ea62366368b99bd69a7698bbfe097c714 (patch)
tree153c411a18eb041dea3f61e0c16018f0f9211ff1
parent33472b3162ced734e1e6eadb55ed1afa7d46eb52 (diff)
parent35432ef6fe2c79ab72709966e64815a45eb55c76 (diff)
Merge tag 'u-boot-dfu-20260819' of https://git.u-boot-project.org/u-boot/custodians/u-boot-dfu
u-boot-dfu-20260819 Android: * Ensure boot image read is bound by partition size
-rw-r--r--boot/bootmeth_android.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index ec255b072af..0db08d4f861 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -384,6 +384,14 @@ static int read_slotted_partition(struct blk_desc *desc, const char *const name,
if (ret < 0)
return log_msg_ret("part", ret);
+ /*
+ * The image size comes from the (untrusted) boot image header, so bound
+ * the read by the partition size: a valid image cannot be larger than
+ * the partition holding it.
+ */
+ if (num_blks > partition.size)
+ return log_msg_ret("image larger than partition", -EFBIG);
+
n = blk_dread(desc, partition.start, num_blks, map_sysmem(addr, 0));
if (n < num_blks)
return log_msg_ret("part read", -EIO);