From 5af0f171f94a18ae0807679f45c757ebb146b35f Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 4 Jan 2024 12:52:25 +0100 Subject: [PATCH] udev: add upper bound of 5 hours to SYSTEMD_UDEV_EXTRA_TIMEOUT_SEC= Follow-up for b16c6076cb334c9da9602d4bafbf60381d6d630e CID#1533111 --- docs/ENVIRONMENT.md | 3 ++- src/udev/udev-manager.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index b9a96be82c..0113fd59fa 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -253,7 +253,8 @@ All tools: udev manager process waits for a worker process kills slow programs specified by IMPORT{program}=, PROGRAM=, or RUN=, and finalizes the processing event. If the worker process cannot finalize the event within the specified timespan, - the worker process is killed by the manager process. Defaults to 10 seconds. + the worker process is killed by the manager process. Defaults to 10 seconds, + maximum allowed is 5 hours. `udevadm` and `systemd-hwdb`: diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c index 5bf00bb262..31944c2247 100644 --- a/src/udev/udev-manager.c +++ b/src/udev/udev-manager.c @@ -335,6 +335,7 @@ static int on_event_timeout_warning(sd_event_source *s, uint64_t usec, void *use static usec_t extra_timeout_usec(void) { static usec_t saved = 10 * USEC_PER_SEC; static bool parsed = false; + usec_t timeout; const char *e; int r; @@ -347,10 +348,15 @@ static usec_t extra_timeout_usec(void) { if (!e) return saved; - r = parse_sec(e, &saved); + r = parse_sec(e, &timeout); if (r < 0) log_debug_errno(r, "Failed to parse $SYSTEMD_UDEV_EXTRA_TIMEOUT_SEC=%s, ignoring: %m", e); + if (timeout > 5 * USEC_PER_HOUR) /* Add an arbitrary upper bound */ + log_debug("Parsed $SYSTEMD_UDEV_EXTRA_TIMEOUT_SEC=%s is too large, ignoring.", e); + else + saved = timeout; + return saved; }