tresor: fix bad hash update during rekeying in vbd

The re-keying state machine in the VBD module would use block data of the wrong
block for the hash update of an inner node in a certain circumstance.

On re-keying, the VBD iterates for a given VBA over all snapshots, beginning
with the newest and re-keys the VBA in each of the snapshots. At each snapshot
it therefore loads the branch of the VBA top-down, and then updates the branch
bottom-up. However, if loading a certain level of the branch of a certain
snapshot runs into the same physical block as with the last snapshot on this
level, the algorithm turns around and updates the branch from this point
upwards instead of going further down the whole way to the leaf. This is
because everything below this point has already been re-keyed in the course of
a newer snapshot.

The case where this turning around is not right above the leaf (i.e., the first
shared physical block is a metadata block) that's were the bug was located. In
this situation, we have to re-encode the highest shared metadata block into a
buffer again before starting to update. The update code acts as if the
mentioned block was just written back (which is true when going down all the
way to the leaf before updating) and consequently is present in the encoded
buffer.

Ref #4971
This commit is contained in:
Martin Stein 2023-08-01 13:55:43 +02:00 committed by Christian Helmuth
parent f8332ce587
commit 417fb4e108

View File

@ -1299,6 +1299,7 @@ void Virtual_block_device::_execute_rekey_vba(Channel &chan,
break;
chan._log_rekeying_pba_alloc();
chan._t1_blks.items[chan._t1_blk_idx].encode_to_blk(chan._encoded_blk);
chan._state = Channel::WRITE_INNER_NODE_COMPLETED;
if (VERBOSE_REKEYING)