From 2d838b735851a1eee84a779b1d7edc7c43e5d2fe Mon Sep 17 00:00:00 2001 From: Michael Trapp Date: Tue, 10 Feb 2026 15:39:21 +0100 Subject: [PATCH] libuuid: reset initial cont-clock time on service start When uuidd starts with --cont-clock enabled and reads a stale timestamp from the state file, the continuous clock logic would apply a backwards offset (default 2 hours), causing generated UUIDs to have incorrect timestamps in the past. Fix this by resetting last_clock_reg to the current time when the saved timestamp is older than the current clock. This prevents the backwards offset from being applied at service start. [kzak@redhat.com: - fix comment, add commit message] Fixes: https://github.com/util-linux/util-linux/issues/4018 Signed-off-by: Karel Zak --- libuuid/src/gen_uuid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index 90b19c9a9..13d6ecbde 100644 --- a/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c @@ -419,6 +419,9 @@ static int get_clock_cont(uint32_t *clock_high, rewind(state_f); if (fscanf(state_f, "cont: %"SCNu64"\n", &last_clock_reg) != 1) goto error; + /* don't use old timestamps, reset to current time */ + if (last_clock_reg < clock_reg) + last_clock_reg = clock_reg; } else last_clock_reg = clock_reg; -- 2.47.3