Skip to content

Commit

Permalink
fs_mgr: set partition.*.verified property even without state
Browse files Browse the repository at this point in the history
Set properties on verity_update_state even if verity state management
is not used.

Bug: 24865045
Change-Id: Ic68a9e1a230c959eeb2a769260ff7d8e100cb1e1
(cherry picked from 0eb0516)
  • Loading branch information
samitolvanen committed Oct 30, 2015
1 parent b57cd14 commit 25b230c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions fs_mgr/fs_mgr_verity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,9 @@ int fs_mgr_load_verity_state(int *mode)
continue;
}

if (current == VERITY_MODE_LOGGING) {
if (current != VERITY_MODE_DEFAULT) {
*mode = current;
break;
}
}

Expand All @@ -784,7 +785,6 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
{
alignas(dm_ioctl) char buffer[DM_BUF_SIZE];
bool use_state = true;
bool use_state_for_device = true;
char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)];
char *mount_point;
char propbuf[PROPERTY_VALUE_MAX];
Expand All @@ -801,12 +801,13 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
property_get("ro.boot.veritymode", propbuf, "");

if (*propbuf != '\0') {
if (fs_mgr_load_verity_state(&mode) == -1) {
return -1;
}
use_state = false; /* state is kept by the bootloader */
}

if (fs_mgr_load_verity_state(&mode) == -1) {
return -1;
}

fd = TEMP_FAILURE_RETRY(open("/dev/device-mapper", O_RDWR | O_CLOEXEC));

if (fd == -1) {
Expand All @@ -829,15 +830,6 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
continue;
}

use_state_for_device = use_state;

if (use_state) {
if (get_verity_state_offset(&fstab->recs[i], &offset) < 0 ||
read_verity_state(fstab->recs[i].verity_loc, offset, &mode) < 0) {
use_state_for_device = false;
}
}

mount_point = basename(fstab->recs[i].mount_point);
verity_ioctl_init(io, mount_point, 0);

Expand All @@ -849,7 +841,7 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)

status = &buffer[io->data_start + sizeof(struct dm_target_spec)];

if (use_state_for_device && *status == 'C') {
if (use_state && *status == 'C') {
if (write_verity_state(fstab->recs[i].verity_loc, offset,
VERITY_MODE_LOGGING) < 0) {
continue;
Expand Down

0 comments on commit 25b230c

Please sign in to comment.