Blame SOURCES/0737-udev-check-age-against-both-timeouts-to-prevent-inte.patch

17b0f1
From 2b0874a8a0ff4bced5da0c25a4b3f3fbd2595e23 Mon Sep 17 00:00:00 2001
17b0f1
From: Michal Sekletar <msekleta@redhat.com>
17b0f1
Date: Wed, 1 May 2019 15:58:44 +0200
17b0f1
Subject: [PATCH] udev: check age against both timeouts to prevent integer
17b0f1
 wraparound
17b0f1
17b0f1
If we get back to while loop after timeout_warn (roughly 60s)
17b0f1
expired for the first time, but before age of the event is larger than
17b0f1
second timeout (roughly 120s) we would try to recompute timeout_warn
17b0f1
again. Previously the following code,
17b0f1
17b0f1
if (timeout_warn_usec > 0)
17b0f1
        timeout_warn = ((timeout_warn_usec - age_usec) / USEC_PER_MSEC) + MSEC_PER_SEC;
17b0f1
17b0f1
would cause an integer wraparound because (timeout_warn_usec - age_usec)
17b0f1
is negative however both timeout_warn_usec and age_usec are
17b0f1
unsigned.
17b0f1
17b0f1
This can happen if we get SIGTERM from the main daemon while waiting in
17b0f1
the second poll(), i.e. after timeout_warn already expired, because on
17b0f1
SIGTERM we just take a note of that happening in event->sigterm and
17b0f1
continue.
17b0f1
17b0f1
Related: #1697909
17b0f1
---
17b0f1
 src/udev/udev-event.c | 2 +-
17b0f1
 1 file changed, 1 insertion(+), 1 deletion(-)
17b0f1
17b0f1
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
17b0f1
index 07b82d093e..5550ec93de 100644
17b0f1
--- a/src/udev/udev-event.c
17b0f1
+++ b/src/udev/udev-event.c
17b0f1
@@ -559,7 +559,7 @@ static int spawn_wait(struct udev_event *event,
17b0f1
                         usec_t age_usec;
17b0f1
 
17b0f1
                         age_usec = now(CLOCK_MONOTONIC) - event->birth_usec;
17b0f1
-                        if (age_usec >= timeout_usec)
17b0f1
+                        if (age_usec >= timeout_usec || age_usec >= timeout_warn_usec)
17b0f1
                                 timeout = 1000;
17b0f1
                         else {
17b0f1
                                 if (timeout_warn_usec > 0)