]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: reset initial cont-clock time on service start
authorMichael Trapp <michael.trapp@sap.com>
Tue, 10 Feb 2026 14:39:21 +0000 (15:39 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Feb 2026 13:18:07 +0000 (14:18 +0100)
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 <kzak@redhat.com>
libuuid/src/gen_uuid.c

index 90b19c9a96f3d8de4c623bdb2184b075bb00d4e7..13d6ecbde1246842e69102bd86b16a97da04c555 100644 (file)
@@ -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;