Blame SOURCES/0031-libmultipath-handle-clock_gettime-failures-in-tur-ch.patch

b7ef27
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b7ef27
From: Benjamin Marzinski <bmarzins@redhat.com>
b7ef27
Date: Thu, 16 May 2019 12:41:33 -0500
b7ef27
Subject: [PATCH] libmultipath: handle clock_gettime failures in tur checker
b7ef27
b7ef27
If clock_gettime() fails, and multipathd can't figure out when it should
b7ef27
time out, it should just default to assuming that it has already timed
b7ef27
out. Found by coverity.
b7ef27
b7ef27
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
b7ef27
---
b7ef27
 libmultipath/checkers/tur.c | 19 +++++++++++++++----
b7ef27
 1 file changed, 15 insertions(+), 4 deletions(-)
b7ef27
b7ef27
diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
b7ef27
index 6b08dbb..717353e 100644
b7ef27
--- a/libmultipath/checkers/tur.c
b7ef27
+++ b/libmultipath/checkers/tur.c
b7ef27
@@ -290,7 +290,12 @@ static void *tur_thread(void *ctx)
b7ef27
 
b7ef27
 static void tur_timeout(struct timespec *tsp)
b7ef27
 {
b7ef27
-	clock_gettime(CLOCK_MONOTONIC, tsp);
b7ef27
+	if (clock_gettime(CLOCK_MONOTONIC, tsp) != 0) {
b7ef27
+		/* can't get time. clear tsp to not wait */
b7ef27
+		tsp->tv_sec = 0;
b7ef27
+		tsp->tv_nsec = 0;
b7ef27
+		return;
b7ef27
+	}
b7ef27
 	tsp->tv_nsec += 1000 * 1000; /* 1 millisecond */
b7ef27
 	normalize_timespec(tsp);
b7ef27
 }
b7ef27
@@ -300,8 +305,12 @@ static void tur_set_async_timeout(struct checker *c)
b7ef27
 	struct tur_checker_context *ct = c->context;
b7ef27
 	struct timespec now;
b7ef27
 
b7ef27
-	clock_gettime(CLOCK_MONOTONIC, &now;;
b7ef27
-	ct->time = now.tv_sec + c->timeout;
b7ef27
+	if (clock_gettime(CLOCK_MONOTONIC, &now) != 0)
b7ef27
+		/* can't get time. clear time to always timeout on
b7ef27
+		 * next path check */
b7ef27
+		ct->time = 0;
b7ef27
+	else
b7ef27
+		ct->time = now.tv_sec + c->timeout;
b7ef27
 }
b7ef27
 
b7ef27
 static int tur_check_async_timeout(struct checker *c)
b7ef27
@@ -309,7 +318,9 @@ static int tur_check_async_timeout(struct checker *c)
b7ef27
 	struct tur_checker_context *ct = c->context;
b7ef27
 	struct timespec now;
b7ef27
 
b7ef27
-	clock_gettime(CLOCK_MONOTONIC, &now;;
b7ef27
+	if (clock_gettime(CLOCK_MONOTONIC, &now) != 0)
b7ef27
+		/* can't get time. assume we've timed out */
b7ef27
+		return 1;
b7ef27
 	return (now.tv_sec > ct->time);
b7ef27
 }
b7ef27
 
b7ef27
-- 
b7ef27
2.17.2
b7ef27