[pbs-devel] [PATCH proxmox-backup] rrd: fix integer underflow
Stefan Reiter
s.reiter at proxmox.com
Thu Oct 1 11:40:44 CEST 2020
Causes a panic if last_update is smaller than RRD_DATA_ENTRIES*reso,
which (I believe) can happen when inserting the first value for a DB.
Clamp the value to 0 in that case.
Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
Added a new datastore and got this message in syslog:
thread 'tokio-runtime-worker' panicked at 'attempt to subtract with overflow', src/rrd/rrd.rs:63:21
followed by a lot of:
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/rrd/cache.rs:75:15
and a broken Dashboard.
Not sure if this is a good fix, maybe something else in the logic is broken?
src/rrd/rrd.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rrd/rrd.rs b/src/rrd/rrd.rs
index 8f542b52..86d6b50b 100644
--- a/src/rrd/rrd.rs
+++ b/src/rrd/rrd.rs
@@ -60,7 +60,7 @@ impl RRA {
let min_time = epoch - (RRD_DATA_ENTRIES as u64)*reso;
let min_time = (min_time/reso + 1)*reso;
- let mut t = last_update - (RRD_DATA_ENTRIES as u64)*reso;
+ let mut t = last_update.saturating_sub((RRD_DATA_ENTRIES as u64)*reso);
let mut index = ((t/reso) % (RRD_DATA_ENTRIES as u64)) as usize;
for _ in 0..RRD_DATA_ENTRIES {
t += reso; index = (index + 1) % RRD_DATA_ENTRIES;
--
2.20.1
More information about the pbs-devel
mailing list