/* we should use avb_part_data->data as boot image */
/* boot image is already read by avb */
hdr = (struct andr_img_hdr *)avb_loadpart->data;
+ if (android_image_check_header(hdr)) {
+ printf("boota: bad boot image magic\n");
+ goto fail;
+ }
if (avb_result == AVB_AB_FLOW_RESULT_OK)
printf(" verify OK, boot '%s%s'\n",
avb_loadpart->partition_name, avb_out_data->ab_suffix);
}
#endif
image_size = avb_loadpart->data_size;
+ memcpy((void *)(ulong)(hdr->kernel_addr - hdr->page_size), (void *)hdr, image_size);
} else if (lock_status == FASTBOOT_LOCK) { /* && verify fail */
/* if in lock state, verify enforce fail */
printf(" verify FAIL, state: LOCK\n");
if (!is_recovery_mode)
boot_args[2] = NULL;
#endif
- /* we should free the avb_out_data but should not free the bootimage */
if (avb_out_data != NULL)
- avb_slot_verify_data_free_fast(avb_out_data);
+ avb_slot_verify_data_free(avb_out_data);
#ifdef CONFIG_IMX_TRUSTY_OS
/* put ql-tipc to release resource for Linux */
#include "avb_util.h"
#include "avb_vbmeta_image.h"
#include "avb_version.h"
-#include <common.h>
-#include "android_image.h"
/* Maximum allow length (in bytes) of a partition name, including
* ab_suffix.
return false;
}
-static struct andr_img_hdr boothdr __aligned(ARCH_DMA_MINALIGN);
-
static AvbSlotVerifyResult load_and_verify_hash_partition(
AvbOps* ops,
const char* const* requested_partitions,
}
}
- /* If we are going to load bootimage, load it to
- * hdr->kernel_addr - hdr->page_size address directly,
- * so we don't need to copy it again!*/
- if (strstr(part_name, "boot") != NULL) {
- struct andr_img_hdr *hdr = &boothdr;
- /* read boot header first so we can get the address */
- if (ops->read_from_partition(ops, part_name,
- 0, sizeof(boothdr), hdr, &part_num_read) != AVB_IO_RESULT_OK &&
- part_num_read != sizeof(boothdr)) {
- printf("Error! read bootimage head error\n");
- ret = AVB_SLOT_VERIFY_RESULT_ERROR_IO;
- goto out;
- }
- /* check bootimg header to make sure we have a vaild bootimage */
- if (android_image_check_header(hdr)) {
- printf("Error! bad boot image magic\n");
- /* bad boot image magic is critical so we will return
- * AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA here,
- * it will make this slot be marked as unbootable.*/
- ret = AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_METADATA;
- goto out;
- }
-
- image_buf = (uint8_t*)(unsigned long)(hdr->kernel_addr - hdr->page_size);
- } else {
- image_buf = avb_malloc(hash_desc.image_size);
- if (image_buf == NULL) {
+ image_buf = avb_malloc(image_size);
+ if (image_buf == NULL) {
ret = AVB_SLOT_VERIFY_RESULT_ERROR_OOM;
goto out;
- }
}
io_ret = ops->read_from_partition(
AvbAlgorithmType algorithm_type,
AvbHashtreeErrorMode hashtree_error_mode) {
AvbSlotVerifyResult ret;
- const char* verity_mode = "enforcing";
+ const char* verity_mode = NULL;
bool is_device_unlocked;
AvbIOResult io_ret;
if (toplevel_vbmeta->flags & AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED) {
verity_mode = "disabled";
} else {
- const char* dm_verity_mode = "restart_on_corruption";
+ const char* dm_verity_mode = NULL;
char* new_ret;
switch (hashtree_error_mode) {
fail:
if (slot_data != NULL) {
- /* the address of bootimage isn't alloced by malloc,
- * we should not free it. */
- avb_slot_verify_data_free_fast(slot_data);
+ avb_slot_verify_data_free(slot_data);
}
return ret;
}
-void avb_slot_verify_data_free_fast(AvbSlotVerifyData* data) {
- if (data->ab_suffix != NULL) {
- avb_free(data->ab_suffix);
- }
- if (data->cmdline != NULL) {
- avb_free(data->cmdline);
- }
- if (data->vbmeta_images != NULL) {
- size_t n;
- for (n = 0; n < data->num_vbmeta_images; n++) {
- AvbVBMetaData* vbmeta_image = &data->vbmeta_images[n];
- if (vbmeta_image->partition_name != NULL) {
- avb_free(vbmeta_image->partition_name);
- }
- if (vbmeta_image->vbmeta_data != NULL) {
- avb_free(vbmeta_image->vbmeta_data);
- }
- }
- avb_free(data->vbmeta_images);
- }
- if (data->loaded_partitions != NULL) {
- size_t n;
- for (n = 0; n < data->num_loaded_partitions; n++) {
- AvbPartitionData* loaded_partition = &data->loaded_partitions[n];
- if (loaded_partition->partition_name != NULL) {
- /* the address of bootimage isn't alloced by malloc, we don't
- * need to free it. */
- if (strstr(loaded_partition->partition_name, "boot") != NULL)
- continue;
- else
- avb_free(loaded_partition->partition_name);
- }
- if (loaded_partition->data != NULL) {
- avb_free(loaded_partition->data);
- }
- }
- avb_free(data->loaded_partitions);
- }
- avb_free(data);
-}
-
void avb_slot_verify_data_free(AvbSlotVerifyData* data) {
if (data->ab_suffix != NULL) {
avb_free(data->ab_suffix);