Blame SOURCES/bz1753517-link-mem-corruption.patch

cf5375
commit 93f3df56ce1008c362df679b2768edbf2e5a860a
cf5375
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
cf5375
Date:   Thu Sep 19 09:02:44 2019 +0200
cf5375
cf5375
    [links] fix memory corryption of link structure
cf5375
    
cf5375
    the index would overflow the buffer and overwrite data in the link
cf5375
    structure. Depending on what was written the cluster could fall
cf5375
    apart in many ways, from crashing, to hung.
cf5375
    
cf5375
    Fixes: https://github.com/kronosnet/kronosnet/issues/255
cf5375
    
cf5375
    thanks to the proxmox developers and community for reporting the issue
cf5375
    and for all the help reproducing / debugging the problem.
cf5375
    
cf5375
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
cf5375
cf5375
diff --git a/libknet/links.c b/libknet/links.c
cf5375
index 6abbd48..3d52511 100644
cf5375
--- a/libknet/links.c
cf5375
+++ b/libknet/links.c
cf5375
@@ -62,13 +62,13 @@ int _link_updown(knet_handle_t knet_h, knet_node_id_t host_id, uint8_t link_id,
cf5375
 	if (connected) {
cf5375
 		time(&link->status.stats.last_up_times[link->status.stats.last_up_time_index]);
cf5375
 		link->status.stats.up_count++;
cf5375
-		if (++link->status.stats.last_up_time_index > MAX_LINK_EVENTS) {
cf5375
+		if (++link->status.stats.last_up_time_index >= MAX_LINK_EVENTS) {
cf5375
 			link->status.stats.last_up_time_index = 0;
cf5375
 		}
cf5375
 	} else {
cf5375
 		time(&link->status.stats.last_down_times[link->status.stats.last_down_time_index]);
cf5375
 		link->status.stats.down_count++;
cf5375
-		if (++link->status.stats.last_down_time_index > MAX_LINK_EVENTS) {
cf5375
+		if (++link->status.stats.last_down_time_index >= MAX_LINK_EVENTS) {
cf5375
 			link->status.stats.last_down_time_index = 0;
cf5375
 		}
cf5375
 	}