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