mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
dissect: Process verity sig partitions if a root hash is specified
If a root hash is specified, we should be checking that it matches the root hash in the verity signature partition, so let's not skip processing of the verity signature partitions if a root hash is specified.
This commit is contained in:
parent
3c5f7ec4ca
commit
3dd73ea77e
@ -603,13 +603,10 @@ int dissect_image(
|
||||
|
||||
m->has_verity_sig = true;
|
||||
|
||||
/* If root hash is specified explicitly, then ignore any embedded signature */
|
||||
if (!verity)
|
||||
continue;
|
||||
if (verity->designator >= 0 && verity->designator != PARTITION_ROOT)
|
||||
continue;
|
||||
if (verity->root_hash)
|
||||
continue;
|
||||
|
||||
assert_se((architecture = gpt_partition_type_uuid_to_arch(type_id)) >= 0);
|
||||
designator = PARTITION_VERITY_SIG_OF(PARTITION_ROOT_OF_ARCH(architecture));
|
||||
@ -667,13 +664,10 @@ int dissect_image(
|
||||
|
||||
m->has_verity_sig = true;
|
||||
|
||||
/* If usr hash is specified explicitly, then ignore any embedded signature */
|
||||
if (!verity)
|
||||
continue;
|
||||
if (verity->designator >= 0 && verity->designator != PARTITION_USR)
|
||||
continue;
|
||||
if (verity->root_hash)
|
||||
continue;
|
||||
|
||||
assert_se((architecture = gpt_partition_type_uuid_to_arch(type_id)) >= 0);
|
||||
designator = PARTITION_VERITY_SIG_OF(PARTITION_USR_OF_ARCH(architecture));
|
||||
@ -1074,6 +1068,9 @@ int dissect_image(
|
||||
if (verity->designator >= 0 && !m->partitions[verity->designator].found)
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
bool have_verity_sig_partition =
|
||||
m->partitions[verity->designator == PARTITION_USR ? PARTITION_USR_VERITY_SIG : PARTITION_ROOT_VERITY_SIG].found;
|
||||
|
||||
if (verity->root_hash) {
|
||||
/* If we have an explicit root hash and found the partitions for it, then we are ready to use
|
||||
* Verity, set things up for it */
|
||||
@ -1097,9 +1094,9 @@ int dissect_image(
|
||||
}
|
||||
|
||||
if (m->verity_ready)
|
||||
m->verity_sig_ready = verity->root_hash_sig;
|
||||
m->verity_sig_ready = verity->root_hash_sig || have_verity_sig_partition;
|
||||
|
||||
} else if (m->partitions[verity->designator == PARTITION_USR ? PARTITION_USR_VERITY_SIG : PARTITION_ROOT_VERITY_SIG].found) {
|
||||
} else if (have_verity_sig_partition) {
|
||||
|
||||
/* If we found an embedded signature partition, we are ready, too. */
|
||||
|
||||
|
@ -214,8 +214,11 @@ losetup -d "${loop}"
|
||||
ROOT_UUID="$(systemd-id128 -u show "$(head -c 32 "${image}.roothash")" -u | tail -n 1 | cut -b 6-)"
|
||||
VERITY_UUID="$(systemd-id128 -u show "$(tail -c 32 "${image}.roothash")" -u | tail -n 1 | cut -b 6-)"
|
||||
|
||||
systemd-dissect --json=short --root-hash "${roothash}" "${image}.gpt" | grep -q '{"rw":"ro","designator":"root","partition_uuid":"'"$ROOT_UUID"'","partition_label":"Root Partition","fstype":"squashfs","architecture":"'"$architecture"'","verity":"yes",'
|
||||
systemd-dissect --json=short --root-hash "${roothash}" "${image}.gpt" | grep -q '{"rw":"ro","designator":"root","partition_uuid":"'"$ROOT_UUID"'","partition_label":"Root Partition","fstype":"squashfs","architecture":"'"$architecture"'","verity":"signed",'
|
||||
systemd-dissect --json=short --root-hash "${roothash}" "${image}.gpt" | grep -q '{"rw":"ro","designator":"root-verity","partition_uuid":"'"$VERITY_UUID"'","partition_label":"Verity Partition","fstype":"DM_verity_hash","architecture":"'"$architecture"'","verity":null,'
|
||||
if [ "${HAVE_OPENSSL}" -eq 1 ]; then
|
||||
systemd-dissect --json=short --root-hash "${roothash}" "${image}.gpt" | grep -q -E '{"rw":"ro","designator":"root-verity-sig","partition_uuid":"'".*"'","partition_label":"Signature Partition","fstype":"verity_hash_signature","architecture":"'"$architecture"'","verity":null,'
|
||||
fi
|
||||
systemd-dissect --root-hash "${roothash}" "${image}.gpt" | grep -q -F "MARKER=1"
|
||||
systemd-dissect --root-hash "${roothash}" "${image}.gpt" | grep -q -F -f <(sed 's/"//g' "$os_release")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user