From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Joshua Watt <jpewhacker@gmail.com>, u-boot@lists.denx.de
Cc: Joshua Watt <JPEWhacker@gmail.com>,
Igor Opaniuk <igor.opaniuk@gmail.com>,
Sam Protsenko <semen.protsenko@linaro.org>,
Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v2] android_ab: Fixes: Fix backup offset calculation
Date: Thu, 29 Aug 2024 10:56:20 +0200 [thread overview]
Message-ID: <87r0a7r9l7.fsf@baylibre.com> (raw)
In-Reply-To: <20240828143924.3987331-1-JPEWhacker@gmail.com>
Hi Joshua,
Thank you for the patch.
On mer., août 28, 2024 at 08:37, Joshua Watt <jpewhacker@gmail.com> wrote:
> The backup offset is in bytes, but was incorrectly be interpreted as
> blocks, leading to it being written to the wrong location. Fix the
> calculation, clarify that ANDROID_AB_BACKUP_OFFSET is in bytes and must
> be a multiple of the block size, and add a runtime check to validate the
> offset.
>
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
As Igor suggested, I will add:
Fixes: 3430f24bc69d ("android_ab: Try backup booloader_message")
When applying.
> ---
> boot/android_ab.c | 9 +++++++--
> common/Kconfig | 3 ++-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/boot/android_ab.c b/boot/android_ab.c
> index 143f373aae..1196a189ed 100644
> --- a/boot/android_ab.c
> +++ b/boot/android_ab.c
> @@ -139,8 +139,13 @@ static int ab_control_store(struct blk_desc *dev_desc,
> {
> ulong abc_offset, abc_blocks, ret;
>
> - abc_offset = offset +
> - offsetof(struct bootloader_message_ab, slot_suffix) /
> + if (offset % part_info->blksz) {
> + log_err("ANDROID: offset not block aligned\n");
> + return -EINVAL;
> + }
> +
> + abc_offset = (offset +
> + offsetof(struct bootloader_message_ab, slot_suffix)) /
> part_info->blksz;
> abc_blocks = DIV_ROUND_UP(sizeof(struct bootloader_control),
> part_info->blksz);
> diff --git a/common/Kconfig b/common/Kconfig
> index 83c81edac2..e1b8557e0c 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -986,7 +986,8 @@ config ANDROID_AB_BACKUP_OFFSET
> help
> If non-zero, a backup bootloader message starting at this offset in
> the partition will tried in the event that the primary one (starting
> - at offset 0) fails its checksum.
> + at offset 0) fails its checksum. The offset is in bytes and must be
> + multiple of the block size.
>
> endmenu
>
> --
> 2.45.2
next prev parent reply other threads:[~2024-08-29 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 14:13 [PATCH] android_ab: Fix backup offset calculation Joshua Watt
2024-08-16 8:23 ` Mattijs Korpershoek
2024-08-28 0:38 ` Sam Protsenko
2024-08-28 14:37 ` [PATCH v2] android_ab: Fixes: " Joshua Watt
2024-08-29 8:56 ` Mattijs Korpershoek [this message]
2024-09-05 6:56 ` Mattijs Korpershoek
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=87r0a7r9l7.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=igor.opaniuk@gmail.com \
--cc=jpewhacker@gmail.com \
--cc=semen.protsenko@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.