From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EE9301FF135 for ; Sun, 19 Apr 2026 23:08:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3AFEC1787F; Sun, 19 Apr 2026 23:08:24 +0200 (CEST) From: Thomas Lamprecht To: c.ebner@proxmox.com Subject: Re: [PATCH proxmox-backup v3 25/30] sync: pull: extend encountered chunk by optional decrypted digest Date: Sun, 19 Apr 2026 22:41:57 +0200 Message-ID: <20260419210610.3915597-8-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260414125923.892345-26-c.ebner@proxmox.com> References: <20260419210610.3915597-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776632780794 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.002 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: PAAOOECFROAW3MWCSMASNIFF63QFVUT4 X-Message-ID-Hash: PAAOOECFROAW3MWCSMASNIFF63QFVUT4 X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pbs-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Am 14.04.26 um 14:59 schrieb Christian Ebner: > diff --git a/src/server/pull.rs b/src/server/pull.rs > > + fn mark_reusable(&mut self, digest: &[u8; 32], decrypted_digest: Option<[u8; 32]>) { > match self.chunk_set.entry(*digest) { > Entry::Occupied(mut occupied) => { > - let (reusable, _touched) = occupied.get_mut(); > - *reusable = true; > + let chunk_info = occupied.get_mut(); > + chunk_info.reusable = true; > } > Entry::Vacant(vacant) => { > - vacant.insert((true, false)); > + vacant.insert(EncounteredChunkInfo { > + reusable: true, > + touched: false, > + decrypted_digest, > + }); > } > } > } > [...] > + fn mark_touched(&mut self, digest: &[u8; 32], decrypted_digest: Option<[u8; 32]>) { > match self.chunk_set.entry(*digest) { > Entry::Occupied(mut occupied) => { > - let (_reusable, touched) = occupied.get_mut(); > - *touched = true; > + let chunk_info = occupied.get_mut(); > + chunk_info.touched = true; > } > Entry::Vacant(vacant) => { > - vacant.insert((false, true)); > + vacant.insert(EncounteredChunkInfo { > + reusable: false, > + touched: true, > + decrypted_digest, > + }); > } > } > } Both functions silently drop the passed `decrypted_digest` in the Occupied arm - only the Vacant branch uses it. So the first caller to touch a given digest wins, and every subsequent call with a different (or present-vs-absent) decrypted_digest is discarded. Today all callers in the series pass None except the decrypt path in patch 27, so there's no observed misbehavior, but this is somewhat of a latent footgun: any future code path that calls `mark_reusable(digest, Some(d1))` *before* the decrypt code reaches `mark_reusable(digest, Some(d2))` (or even just `None`) will silently lose the mapping. Either: - Document the "first insert wins for decrypted_digest" semantics explicitly (doc comment + debug_assert on mismatch), or - Also update the field in the Occupied arm (probably only when the stored value is currently None, to preserve a decrypted_digest once it's been learned). Minor: the parameter name `decrypted_digest` reads naturally in the mark functions, but check_reusable returns it with just the cryptic `(touched, Some(&[u8; 32]))` tuple - maybe give it a name via a small struct return or at least a doc comment line on what the second element means.