File handle-linux-kernel-stat-overflow.patch of Package open-vm-tools.9224
commit c7a186e204cdff46b5e02bcb5208ef8979eaf261
Author: Oliver Kurth <okurth@vmware.com>
Date: Mon Sep 17 16:41:18 2018 -0700
Handle Linux kernel /proc FS uint32 type stat overflow when calculating
tools rate stats.
On both 32-bit and 64-bit Linux, tools always parses Linux kernel /proc
FS stats as uint64 values. For rate stats, current - previous can handle
uint64 type stat overflow, but not uint32 type.
diff --git a/open-vm-tools/services/plugins/guestInfo/perfMonLinux.c b/open-vm-tools/services/plugins/guestInfo/perfMonLinux.c
index fa2344b0..eb74faa5 100644
--- a/open-vm-tools/services/plugins/guestInfo/perfMonLinux.c
+++ b/open-vm-tools/services/plugins/guestInfo/perfMonLinux.c
@@ -1094,7 +1094,18 @@ GuestInfoAppendRate(Bool emitNameSpace, // IN:
if (reportID == GuestStatID_Linux_DiskRequestQueueAvg) {
valueDelta = ((double)(currentStat->value)) / 10;
} else {
- valueDelta = currentStat->value - previousStat->value;
+ /*
+ * The /proc FS stat can be uint32 type in the kernel on both x86
+ * and x64 Linux, it is parsed and stored as uint64 in tools, so we
+ * also need to handle uint32 overflow here.
+ */
+ if (currentStat->value < previousStat->value &&
+ previousStat->value <= MAX_UINT32) {
+ valueDelta = (uint32)(currentStat->value) -
+ (uint32)(previousStat->value);
+ } else {
+ valueDelta = currentStat->value - previousStat->value;
+ }
}
valueDouble = valueDelta / timeDelta;