public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] rrd: fix integer underflow
@ 2020-10-01  9:40 Stefan Reiter
  2020-10-01 12:31 ` [pbs-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Reiter @ 2020-10-01  9:40 UTC (permalink / raw)
  To: pbs-devel

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@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-01 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  9:40 [pbs-devel] [PATCH proxmox-backup] rrd: fix integer underflow Stefan Reiter
2020-10-01 12:31 ` [pbs-devel] applied: " Dietmar Maurer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal