public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Igor Opaniuk <igor.opaniuk@foundries.io>, u-boot@lists.denx.de
Cc: Igor Opaniuk <igor.opaniuk@gmail.com>, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v1 6/7] cmd: avb: rework do_avb_verify_part
Date: Fri, 09 Feb 2024 10:17:34 +0100	[thread overview]
Message-ID: <87zfwa2dzl.fsf@baylibre.com> (raw)
In-Reply-To: <20240206223153.3060433-7-igor.opaniuk@foundries.io>

Hi Igor,

Thank you for the patch.

On mar., févr. 06, 2024 at 23:31, Igor Opaniuk <igor.opaniuk@foundries.io> wrote:

> From: Igor Opaniuk <igor.opaniuk@gmail.com>
>
> Use existing str_avb_slot_error() function for obtaining
> verification fail reason details.
> Take into account device lock state for setting correct
> androidboot.verifiedbootstate kernel cmdline parameter.
>
> Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

Nitpick: the error handling migration could have been part of PATCH 5/7
but it's fine to keep as is.

> ---
>
>  cmd/avb.c | 50 +++++++++++++++++---------------------------------
>  1 file changed, 17 insertions(+), 33 deletions(-)
>
> diff --git a/cmd/avb.c b/cmd/avb.c
> index ae0012c0e79..e5fc202121f 100644
> --- a/cmd/avb.c
> +++ b/cmd/avb.c
> @@ -239,6 +239,7 @@ int do_avb_verify_part(struct cmd_tbl *cmdtp, int flag,
>  	const char * const requested_partitions[] = {"boot", NULL};
>  	AvbSlotVerifyResult slot_result;
>  	AvbSlotVerifyData *out_data;
> +	enum avb_boot_state boot_state;
>  	char *cmdline;
>  	char *extra_args;
>  	char *slot_suffix = "";
> @@ -273,18 +274,23 @@ int do_avb_verify_part(struct cmd_tbl *cmdtp, int flag,
>  				AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE,
>  				&out_data);
>  
> -	switch (slot_result) {
> -	case AVB_SLOT_VERIFY_RESULT_OK:
> -		/* Until we don't have support of changing unlock states, we
> -		 * assume that we are by default in locked state.
> -		 * So in this case we can boot only when verification is
> -		 * successful; we also supply in cmdline GREEN boot state
> -		 */
> +	/*
> +	 * LOCKED devices with custom root of trust setup is not supported (YELLOW)
> +	 */
> +	if (slot_result == AVB_SLOT_VERIFY_RESULT_OK) {
>  		printf("Verification passed successfully\n");
>  
> -		/* export additional bootargs to AVB_BOOTARGS env var */
> +		/*
> +		 * ORANGE state indicates that device may be freely modified.
> +		 * Device integrity is left to the user to verify out-of-band.
> +		 */
> +		if (unlocked)
> +			boot_state = AVB_ORANGE;
> +		else
> +			boot_state = AVB_GREEN;
>  
> -		extra_args = avb_set_state(avb_ops, AVB_GREEN);
> +		/* export boot state to AVB_BOOTARGS env var */
> +		extra_args = avb_set_state(avb_ops, boot_state);
>  		if (extra_args)
>  			cmdline = append_cmd_line(out_data->cmdline,
>  						  extra_args);
> @@ -294,30 +300,8 @@ int do_avb_verify_part(struct cmd_tbl *cmdtp, int flag,
>  		env_set(AVB_BOOTARGS, cmdline);
>  
>  		res = CMD_RET_SUCCESS;
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION:
> -		printf("Verification failed\n");
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_IO:
> -		printf("I/O error occurred during verification\n");
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_OOM:
> -		printf("OOM error occurred during verification\n");
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA:
> -		printf("Corrupted dm-verity metadata detected\n");
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_UNSUPPORTED_VERSION:
> -		printf("Unsupported version of avbtool was used\n");
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_ROLLBACK_INDEX:
> -		printf("Rollback index check failed\n");
> -		break;
> -	case AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED:
> -		printf("Public key was rejected\n");
> -		break;
> -	default:
> -		printf("Unknown error occurred\n");
> +	} else {
> +		printf("Verification failed, reason: %s\n", str_avb_slot_error(slot_result));
>  	}
>  
>  	if (out_data)
> -- 
> 2.34.1

  reply	other threads:[~2024-02-09  9:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 22:31 [PATCH v1 0/7] AVB: cosmetic adjustments/improvements Igor Opaniuk
2024-02-06 22:31 ` [PATCH v1 1/7] common: avb_verify: don't call mmc_switch_part for SD Igor Opaniuk
2024-02-08 13:35   ` Mattijs Korpershoek
2024-02-06 22:31 ` [PATCH v1 2/7] avb: move SPDX license itdentifiers to the first line Igor Opaniuk
2024-02-08 13:41   ` Mattijs Korpershoek
2024-02-06 22:31 ` [PATCH v1 3/7] common: avb_verify: rework error/debug prints Igor Opaniuk
2024-02-08 13:43   ` Mattijs Korpershoek
2024-02-06 22:31 ` [PATCH v1 4/7] cmd: avb: rework prints Igor Opaniuk
2024-02-08 14:00   ` Mattijs Korpershoek
2024-02-09  9:56     ` Igor Opaniuk
2024-02-06 22:31 ` [PATCH v1 5/7] common: avb_verify: add str_avb_io_error/str_avb_slot_error Igor Opaniuk
2024-02-08 14:03   ` Mattijs Korpershoek
2024-02-06 22:31 ` [PATCH v1 6/7] cmd: avb: rework do_avb_verify_part Igor Opaniuk
2024-02-09  9:17   ` Mattijs Korpershoek [this message]
2024-02-06 22:31 ` [PATCH v1 7/7] doc: android: avb: add slot_suffix param details Igor Opaniuk
2024-02-08 14:12   ` Mattijs Korpershoek
2024-02-09  9:50     ` Igor Opaniuk

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=87zfwa2dzl.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=igor.opaniuk@foundries.io \
    --cc=igor.opaniuk@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox