[pve-devel] [PATCH proxmox-backup-qemu v2 3/3] fix #2866: invalidate bitmap on crypt_mode change
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Jul 24 11:53:35 CEST 2020
signed and plain backups share chunks, so bitmap reusal is okay for
those combinations. switching from encrypted to not encrypted or
vice-versa could have pretty fatal consequences - either referencing
plain-text chunks in 'encrypted' backups, or referencing encrypted
chunks in 'unencrypted' backups without still having the corresponding
keys..
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/backup.rs | 5 ++++-
src/commands.rs | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/backup.rs b/src/backup.rs
index dab1da0..9e3d66a 100644
--- a/src/backup.rs
+++ b/src/backup.rs
@@ -203,7 +203,10 @@ impl BackupTask {
size: u64,
) -> bool {
match self.last_manifest() {
- Some(ref manifest) => check_last_incremental_csum(manifest.clone(), &device_name, size),
+ Some(ref manifest) => {
+ check_last_incremental_csum(manifest.clone(), &device_name, size)
+ && check_last_encryption_mode(manifest.clone(), &device_name, self.crypt_mode)
+ },
None => false,
}
}
diff --git a/src/commands.rs b/src/commands.rs
index e2584ab..c59ee1b 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -94,6 +94,29 @@ pub(crate) fn check_last_incremental_csum(
}
}
+pub(crate) fn check_last_encryption_mode(
+ manifest: Arc<BackupManifest>,
+ device_name: &str,
+ crypt_mode: CryptMode,
+) -> bool {
+ match manifest.lookup_file_info(&archive_name(device_name)) {
+ Ok(file) => {
+ match file.crypt_mode {
+ CryptMode::Encrypt => match crypt_mode {
+ CryptMode::Encrypt => true,
+ _ => false,
+ },
+ CryptMode::SignOnly | CryptMode::None => match crypt_mode {
+ CryptMode::Encrypt => false,
+ _ => true,
+ },
+ }
+ },
+ _ => false,
+ }
+}
+
+
pub(crate) async fn register_image(
client: Arc<BackupWriter>,
crypt_config: Option<Arc<CryptConfig>>,
--
2.20.1
More information about the pve-devel
mailing list