From 81c0a93adf3ab9b08012be4868f200ec3e5a759a Mon Sep 17 00:00:00 2001 From: Renbo Date: Mon, 30 Jan 2023 16:56:34 +0800 Subject: [PATCH 1/4] update to util-linux-2.32.1-39.el8_7 Signed-off-by: Renbo --- 0076-libblkid-fix-Atari-prober-logic.patch | 47 +++ 0077-libblkid-make-Atari-more-robust.patch | 129 ++++++ ...bblkid-allow-a-lot-of-mac-partitions.patch | 53 +++ ...id-limit-amount-of-parsed-partitions.patch | 85 ++++ ...e-sure-block-size-is-large-enough-fu.patch | 29 ++ ...t-read-from-HW-when-use-sys-snapshot.patch | 40 ++ ...gins-improve-prefixes-interpretation.patch | 84 ++++ 0083-tests-update-atari-blkid-tests.patch | 149 +++++++ 0084-tests-update-atari-partx-tests.patch | 55 +++ ...t-continuous-clock-handling-for-time.patch | 375 ++++++++++++++++++ ...-clock-value-from-LIBUUID_CLOCK_FILE.patch | 35 ++ 1001-hwclock-make-glibc-2.31-compatible.patch | 161 -------- ...eoverse-N2-to-ARM-identifiers-tables.patch | 24 -- ...-cpu-frequency-from-cpuinfo-on-arm64.patch | 24 -- dist | 1 + util-linux.spec | 73 ++-- uuidd-tmpfiles.conf | 1 + 17 files changed, 1122 insertions(+), 243 deletions(-) create mode 100644 0076-libblkid-fix-Atari-prober-logic.patch create mode 100644 0077-libblkid-make-Atari-more-robust.patch create mode 100644 0078-libblkid-allow-a-lot-of-mac-partitions.patch create mode 100644 0079-libblkid-limit-amount-of-parsed-partitions.patch create mode 100644 0080-libblkid-mac-make-sure-block-size-is-large-enough-fu.patch create mode 100644 0081-lscpu-don-t-read-from-HW-when-use-sys-snapshot.patch create mode 100644 0082-lslogins-improve-prefixes-interpretation.patch create mode 100644 0083-tests-update-atari-blkid-tests.patch create mode 100644 0084-tests-update-atari-partx-tests.patch create mode 100644 0085-libuuid-Implement-continuous-clock-handling-for-time.patch create mode 100644 0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch delete mode 100644 1001-hwclock-make-glibc-2.31-compatible.patch delete mode 100644 1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch delete mode 100644 1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch create mode 100644 dist create mode 100644 uuidd-tmpfiles.conf diff --git a/0076-libblkid-fix-Atari-prober-logic.patch b/0076-libblkid-fix-Atari-prober-logic.patch new file mode 100644 index 0000000..98a492c --- /dev/null +++ b/0076-libblkid-fix-Atari-prober-logic.patch @@ -0,0 +1,47 @@ +From 214eaa70d8431161de03ea7903f814c102e87919 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 9 Oct 2020 13:06:08 +0200 +Subject: libblkid: fix Atari prober logic + +Addresses: https://github.com/karelzak/util-linux/issues/1159 +Addresses: https://github.com/karelzak/util-linux/issues/1116 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Upstream: http://github.com/util-linux/util-linux/commit/282ceadc3a72fc07dd0388b8880fd751490bb87f +Signed-off-by: Karel Zak +--- + libblkid/src/partitions/atari.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c +index 1224a577c..b469ef5a1 100644 +--- a/libblkid/src/partitions/atari.c ++++ b/libblkid/src/partitions/atari.c +@@ -199,11 +199,10 @@ static int probe_atari_pt(blkid_probe pr, + + hdsize = blkid_probe_get_size(pr) / 512; + +- /* Look for validly looking primary partition */ +- for (i = 0; ; i++) { +- if (i >= ARRAY_SIZE(rs->part)) +- goto nothing; +- ++ /* ++ * At least one valid partition required ++ */ ++ for (i = 0; i < 4; i++) { + if (IS_PARTDEF_VALID(rs->part[i], hdsize)) { + blkid_probe_set_magic(pr, + offsetof(struct atari_rootsector, part[i]), +@@ -213,6 +212,9 @@ static int probe_atari_pt(blkid_probe pr, + } + } + ++ if (i == 4) ++ goto nothing; ++ + if (blkid_partitions_need_typeonly(pr)) + /* caller does not ask for details about partitions */ + return BLKID_PROBE_OK; +-- +2.36.1 + diff --git a/0077-libblkid-make-Atari-more-robust.patch b/0077-libblkid-make-Atari-more-robust.patch new file mode 100644 index 0000000..9f19c48 --- /dev/null +++ b/0077-libblkid-make-Atari-more-robust.patch @@ -0,0 +1,129 @@ +From e7f0f5d3a80324e1430e979b0a170ded77b380e2 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 13 Oct 2020 16:19:20 +0200 +Subject: libblkid: make Atari more robust + +* ignore large disks +* check in-table stored device size +* check bad sectors list +* check partition dimensions against in-table device size + +Addresses: https://github.com/karelzak/util-linux/issues/1159 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Upstream: http://github.com/util-linux/util-linux/commit/282ceadc3a72fc07dd0388b8880fd751490bb87f +Signed-off-by: Karel Zak +--- + libblkid/src/partitions/atari.c | 66 ++++++++++++++++++++++++--------- + 1 file changed, 48 insertions(+), 18 deletions(-) + +diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c +index b469ef5a1..c3f77117a 100644 +--- a/libblkid/src/partitions/atari.c ++++ b/libblkid/src/partitions/atari.c +@@ -74,16 +74,27 @@ static int linux_isalnum(unsigned char c) { + + #define IS_ACTIVE(partdef) ((partdef).flags & 1) + +-#define IS_PARTDEF_VALID(partdef, hdsize) \ +- ( \ +- (partdef).flags & 1 && \ +- isalnum((partdef).id[0]) && \ +- isalnum((partdef).id[1]) && \ +- isalnum((partdef).id[2]) && \ +- be32_to_cpu((partdef).start) <= (hdsize) && \ +- be32_to_cpu((partdef).start) + \ +- be32_to_cpu((partdef).size) <= (hdsize) \ +- ) ++static int is_valid_dimension(uint32_t start, uint32_t size, uint32_t maxoff) ++{ ++ uint64_t end = start + size; ++ ++ return end >= start ++ && 0 < start && start <= maxoff ++ && 0 < size && size <= maxoff ++ && 0 < end && end <= maxoff; ++} ++ ++static int is_valid_partition(struct atari_part_def *part, uint32_t maxoff) ++{ ++ uint32_t start = be32_to_cpu(part->start), ++ size = be32_to_cpu(part->size); ++ ++ return (part->flags & 1) ++ && isalnum(part->id[0]) ++ && isalnum(part->id[1]) ++ && isalnum(part->id[2]) ++ && is_valid_dimension(start, size, maxoff); ++} + + static int is_id_common(char *id) + { +@@ -184,12 +195,20 @@ static int probe_atari_pt(blkid_probe pr, + unsigned i; + int has_xgm = 0; + int rc = 0; +- off_t hdsize; ++ uint32_t rssize; /* size in sectors from root sector */ ++ uint64_t size; /* size in sectors from system */ + + /* Atari partition is not defined for other sector sizes */ + if (blkid_probe_get_sectorsize(pr) != 512) + goto nothing; + ++ size = blkid_probe_get_size(pr) / 512; ++ ++ /* Atari is not well defined to support large disks */ ++ if (size > INT32_MAX) ++ goto nothing; ++ ++ /* read root sector */ + rs = (struct atari_rootsector *) blkid_probe_get_sector(pr, 0); + if (!rs) { + if (errno) +@@ -197,17 +216,29 @@ static int probe_atari_pt(blkid_probe pr, + goto nothing; + } + +- hdsize = blkid_probe_get_size(pr) / 512; ++ rssize = be32_to_cpu(rs->hd_size); ++ ++ /* check number of sectors stored in the root sector */ ++ if (rssize < 2 || rssize > size) ++ goto nothing; ++ ++ /* check list of bad blocks */ ++ if ((rs->bsl_start || rs->bsl_len) ++ && !is_valid_dimension(be32_to_cpu(rs->bsl_start), ++ be32_to_cpu(rs->bsl_len), ++ rssize)) ++ goto nothing; + + /* + * At least one valid partition required + */ + for (i = 0; i < 4; i++) { +- if (IS_PARTDEF_VALID(rs->part[i], hdsize)) { +- blkid_probe_set_magic(pr, +- offsetof(struct atari_rootsector, part[i]), +- sizeof(rs->part[i].flags) + sizeof(rs->part[i].id), +- (unsigned char *) &rs->part[i]); ++ if (is_valid_partition(&rs->part[i], rssize)) { ++ if (blkid_probe_set_magic(pr, ++ offsetof(struct atari_rootsector, part[i]), ++ sizeof(rs->part[i].flags) + sizeof(rs->part[i].id), ++ (unsigned char *) &rs->part[i])) ++ goto err; + break; + } + } +@@ -234,7 +265,6 @@ static int probe_atari_pt(blkid_probe pr, + blkid_partlist_increment_partno(ls); + continue; + } +- + if (!memcmp(p->id, "XGM", 3)) { + has_xgm = 1; + rc = parse_extended(pr, ls, tab, p); +-- +2.36.1 + diff --git a/0078-libblkid-allow-a-lot-of-mac-partitions.patch b/0078-libblkid-allow-a-lot-of-mac-partitions.patch new file mode 100644 index 0000000..9cf4dc9 --- /dev/null +++ b/0078-libblkid-allow-a-lot-of-mac-partitions.patch @@ -0,0 +1,53 @@ +From 2348779e225dd581c32c00108e017f5c1924e706 Mon Sep 17 00:00:00 2001 +From: Samanta Navarro +Date: Sun, 8 Nov 2020 11:45:18 +0000 +Subject: libblkid: allow a lot of mac partitions + +If the map count is set to INT_MAX then the for loop does not stop +because its check is never false. + +I have not found a correct upper limit. The other partition logics have +a maximum amount (exception is atari.c). + +The loop itself wouldn't be endless. If the iteration reaches block 0 +then the signature will be wrong. This means that map count = INT_MAX +case would fail even if such a setup would be correct on disk. + +Upstream: http://github.com/util-linux/util-linux/commit/8f22adaaf30e9fd3bf83da0213b4a6525c9305cd +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Signed-off-by: Samanta Navarro +--- + libblkid/src/partitions/mac.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c +index 4713d6042..2be91a620 100644 +--- a/libblkid/src/partitions/mac.c ++++ b/libblkid/src/partitions/mac.c +@@ -123,12 +123,12 @@ static int probe_mac_pt(blkid_probe pr, + ssf = block_size / 512; + nblks = be32_to_cpu(p->map_count); + +- for (i = 1; i <= nblks; ++i) { ++ for (i = 0; i < nblks; ++i) { + blkid_partition par; + uint32_t start; + uint32_t size; + +- p = (struct mac_partition *) get_mac_block(pr, block_size, i); ++ p = (struct mac_partition *) get_mac_block(pr, block_size, i + 1); + if (!p) { + if (errno) + return -errno; +@@ -141,7 +141,7 @@ static int probe_mac_pt(blkid_probe pr, + DBG(LOWPROBE, ul_debug( + "mac: inconsistent map_count in partition map, " + "entry[0]: %d, entry[%d]: %d", +- nblks, i - 1, ++ nblks, i, + be32_to_cpu(p->map_count))); + } + +-- +2.36.1 + diff --git a/0079-libblkid-limit-amount-of-parsed-partitions.patch b/0079-libblkid-limit-amount-of-parsed-partitions.patch new file mode 100644 index 0000000..e202558 --- /dev/null +++ b/0079-libblkid-limit-amount-of-parsed-partitions.patch @@ -0,0 +1,85 @@ +From 24f5385f4a54b90f4b7674e23f30567591962bcb Mon Sep 17 00:00:00 2001 +From: Samanta Navarro +Date: Tue, 10 Nov 2020 11:48:04 +0100 +Subject: libblkid: limit amount of parsed partitions + +The linux kernel does not support more than 256 partitions +(DISK_MAX_PARTS). The atari and mac block devices have no such limits. + +Use dos logical partition limit for atari as well (100). +Use the kernel limit for mac (256). + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Upstream: http://github.com/util-linux/util-linux/commit/c70b4f2a5b99876d230b8f4f413c3bb3ee6647f1 +Signed-off-by: Karel Zak +Signed-off-by: Samanta Navarro +--- + libblkid/src/partitions/atari.c | 6 +++++- + libblkid/src/partitions/mac.c | 15 +++++++++++---- + 2 files changed, 16 insertions(+), 5 deletions(-) + +diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c +index c3f77117a..fdd5498b5 100644 +--- a/libblkid/src/partitions/atari.c ++++ b/libblkid/src/partitions/atari.c +@@ -141,12 +141,16 @@ static int parse_extended(blkid_probe pr, blkid_partlist ls, + blkid_parttable tab, struct atari_part_def *part) + { + uint32_t x0start, xstart; +- unsigned i = 0; ++ unsigned ct = 0, i = 0; + int rc; + + x0start = xstart = be32_to_cpu(part->start); + while (1) { + struct atari_rootsector *xrs; ++ ++ if (++ct > 100) ++ break; ++ + xrs = (struct atari_rootsector *) blkid_probe_get_sector(pr, xstart); + if (!xrs) { + if (errno) +diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c +index 2be91a620..092d31d32 100644 +--- a/libblkid/src/partitions/mac.c ++++ b/libblkid/src/partitions/mac.c +@@ -79,7 +79,7 @@ static int probe_mac_pt(blkid_probe pr, + blkid_partlist ls; + uint16_t block_size; + uint16_t ssf; /* sector size fragment */ +- uint32_t nblks, i; ++ uint32_t nblks, nprts, i; + + + /* The driver descriptor record is always located at physical block 0, +@@ -122,8 +122,15 @@ static int probe_mac_pt(blkid_probe pr, + + ssf = block_size / 512; + nblks = be32_to_cpu(p->map_count); +- +- for (i = 0; i < nblks; ++i) { ++ if (nblks > 256) { ++ nprts = 256; ++ DBG(LOWPROBE, ul_debug( ++ "mac: map_count too large, entry[0]: %u, " ++ "enforcing limit of %u", nblks, nprts)); ++ } else ++ nprts = nblks; ++ ++ for (i = 0; i < nprts; ++i) { + blkid_partition par; + uint32_t start; + uint32_t size; +@@ -140,7 +147,7 @@ static int probe_mac_pt(blkid_probe pr, + if (be32_to_cpu(p->map_count) != nblks) { + DBG(LOWPROBE, ul_debug( + "mac: inconsistent map_count in partition map, " +- "entry[0]: %d, entry[%d]: %d", ++ "entry[0]: %u, entry[%u]: %u", + nblks, i, + be32_to_cpu(p->map_count))); + } +-- +2.36.1 + diff --git a/0080-libblkid-mac-make-sure-block-size-is-large-enough-fu.patch b/0080-libblkid-mac-make-sure-block-size-is-large-enough-fu.patch new file mode 100644 index 0000000..2eafd83 --- /dev/null +++ b/0080-libblkid-mac-make-sure-block-size-is-large-enough-fu.patch @@ -0,0 +1,29 @@ +From 7180c1ad36a1f419e20e90ddfad0b2f77d8c018f Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Jun 2022 16:02:54 +0200 +Subject: libblkid: (mac) make sure block size is large enough [fuzzing] + +Upstream: http://github.com/util-linux/util-linux/commit/4e12fbca62be10b09503cecc7507757874043474 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Reported-by: Thibault Guittet +Signed-off-by: Karel Zak +--- + libblkid/src/partitions/mac.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c +index 092d31d32..75a558b0a 100644 +--- a/libblkid/src/partitions/mac.c ++++ b/libblkid/src/partitions/mac.c +@@ -93,6 +93,8 @@ static int probe_mac_pt(blkid_probe pr, + } + + block_size = be16_to_cpu(md->block_size); ++ if (block_size < sizeof(struct mac_partition)) ++ goto nothing; + + /* The partition map always begins at physical block 1, + * the second block on the disk. +-- +2.36.1 + diff --git a/0081-lscpu-don-t-read-from-HW-when-use-sys-snapshot.patch b/0081-lscpu-don-t-read-from-HW-when-use-sys-snapshot.patch new file mode 100644 index 0000000..0f12cee --- /dev/null +++ b/0081-lscpu-don-t-read-from-HW-when-use-sys-snapshot.patch @@ -0,0 +1,40 @@ +From c223ad8f05d2d20a80e21dbb4b6240f11909f92c Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 14 Jul 2022 13:10:16 +0200 +Subject: lscpu: don;t read from HW when use /sys snapshot + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2069187 +Signed-off-by: Karel Zak +--- + sys-utils/lscpu.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c +index 70a797dd6..01f8fba35 100644 +--- a/sys-utils/lscpu.c ++++ b/sys-utils/lscpu.c +@@ -1850,7 +1850,10 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod) + } + } else { + if (desc->is_cluster) { +- int sockets = get_number_of_physical_sockets_from_dmi(); ++ int sockets = 0; ++ ++ if (mod->system == SYSTEM_LIVE) ++ sockets = get_number_of_physical_sockets_from_dmi(); + + if (sockets > 0) + add_summary_n(tb, _("Socket(s):"), sockets); +@@ -2109,7 +2112,8 @@ int main(int argc, char *argv[]) + qsort(desc->ecaches, desc->necaches, + sizeof(struct cpu_cache), cachecmp); + +- desc->is_cluster = is_fallback_to_cluster(desc); ++ if (mod->system == SYSTEM_LIVE) ++ desc->is_cluster = is_fallback_to_cluster(desc); + + read_nodes(desc); + read_hypervisor(desc, mod); +-- +2.36.1 + diff --git a/0082-lslogins-improve-prefixes-interpretation.patch b/0082-lslogins-improve-prefixes-interpretation.patch new file mode 100644 index 0000000..e41d75c --- /dev/null +++ b/0082-lslogins-improve-prefixes-interpretation.patch @@ -0,0 +1,84 @@ +From 818cd2018ca66e804ea30066c44572ca128a24a7 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 7 Jun 2022 09:11:56 +0200 +Subject: lslogins: improve prefixes interpretation + +It seems that for example 'passwd --lock' uses two exclamation marks +in password field. It seems better to assume arbitrary number of '!' +and '*' prefixes. + +The patch also makes description of the PWD-EMPTY output field more +explicit. + +Upstream: http://github.com/util-linux/util-linux/commit/c51cba1e838ae7e36a843ec785543492bb8737cd +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2093166 +Signed-off-by: Karel Zak +--- + login-utils/lslogins.c | 31 +++++++++++++++++++++++++------ + 1 file changed, 25 insertions(+), 6 deletions(-) + +diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c +index 6f804aa35..b81afc6c7 100644 +--- a/login-utils/lslogins.c ++++ b/login-utils/lslogins.c +@@ -216,7 +216,7 @@ static const struct lslogins_coldesc coldescs[] = + { + [COL_USER] = { "USER", N_("user name"), N_("Username"), 0.1, SCOLS_FL_NOEXTREMES }, + [COL_UID] = { "UID", N_("user ID"), "UID", 1, SCOLS_FL_RIGHT}, +- [COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not required"), N_("Password not required"), 1, SCOLS_FL_RIGHT }, ++ [COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not defined"), N_("Password not required (empty)"), 1, SCOLS_FL_RIGHT }, + [COL_PWDDENY] = { "PWD-DENY", N_("login by password disabled"), N_("Login by password disabled"), 1, SCOLS_FL_RIGHT }, + [COL_PWDLOCK] = { "PWD-LOCK", N_("password defined, but locked"), N_("Password is locked"), 1, SCOLS_FL_RIGHT }, + [COL_NOLOGIN] = { "NOLOGIN", N_("log in disabled by nologin(8) or pam_nologin(8)"), N_("No login"), 1, SCOLS_FL_RIGHT }, +@@ -755,16 +755,24 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c + break; + case COL_PWDEMPTY: + if (shadow) { +- if (!*shadow->sp_pwdp) /* '\0' */ ++ const char *p = shadow->sp_pwdp; ++ ++ while (p && (*p == '!' || *p == '*')) ++ p++; ++ ++ if (!p || !*p) + user->pwd_empty = STATUS_TRUE; + } else + user->pwd_empty = STATUS_UNKNOWN; + break; + case COL_PWDDENY: + if (shadow) { +- if ((*shadow->sp_pwdp == '!' || +- *shadow->sp_pwdp == '*') && +- !valid_pwd(shadow->sp_pwdp + 1)) ++ const char *p = shadow->sp_pwdp; ++ ++ while (p && (*p == '!' || *p == '*')) ++ p++; ++ ++ if (p && *p && p != shadow->sp_pwdp && !valid_pwd(p)) + user->pwd_deny = STATUS_TRUE; + } else + user->pwd_deny = STATUS_UNKNOWN; +@@ -772,7 +780,18 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c + + case COL_PWDLOCK: + if (shadow) { +- if (*shadow->sp_pwdp == '!' && valid_pwd(shadow->sp_pwdp + 1)) ++ const char *p = shadow->sp_pwdp; ++ int i = 0; ++ ++ /* 'passwd --lock' uses two exclamation marks, ++ * shadow(5) describes the lock as "field which ++ * starts with an exclamation mark". Let's ++ * support more '!' ... ++ */ ++ while (p && *p == '!') ++ p++, i++; ++ ++ if (i != 0 && (!*p || valid_pwd(p))) + user->pwd_lock = STATUS_TRUE; + } else + user->pwd_lock = STATUS_UNKNOWN; +-- +2.36.1 + diff --git a/0083-tests-update-atari-blkid-tests.patch b/0083-tests-update-atari-blkid-tests.patch new file mode 100644 index 0000000..6bd93f0 --- /dev/null +++ b/0083-tests-update-atari-blkid-tests.patch @@ -0,0 +1,149 @@ +From 78be9c320883e77c2b5fdc676277a51efc98c723 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 13 Oct 2020 16:29:19 +0200 +Subject: tests: update atari blkid tests + +The old images of the atari label are truncated and in-table stored +sizes do not match with real images sizes -- libblkid checks it now. + +I have no idea how to generate ICD format, let's ignore it in tests +for now. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Upstream: http://github.com/util-linux/util-linux/commit/0d061b6e68bc74ce7d61524097b5d0f3becee437 +Signed-off-by: Karel Zak +--- + tests/expected/blkid/lowprobe-pt-atari-icd | 8 -------- + tests/expected/blkid/lowprobe-pt-atari-primary | 3 +++ + tests/expected/blkid/lowprobe-pt-atari-xgm | 10 +++------- + tests/ts/blkid/images-pt/atari-icd.img.xz | Bin 1920 -> 0 bytes + tests/ts/blkid/images-pt/atari-primary.img.xz | Bin 0 -> 932 bytes + tests/ts/blkid/images-pt/atari-xgm.img.xz | Bin 1920 -> 956 bytes + 6 files changed, 6 insertions(+), 15 deletions(-) + delete mode 100644 tests/expected/blkid/lowprobe-pt-atari-icd + create mode 100644 tests/expected/blkid/lowprobe-pt-atari-primary + delete mode 100644 tests/ts/blkid/images-pt/atari-icd.img.xz + create mode 100644 tests/ts/blkid/images-pt/atari-primary.img.xz + +diff --git a/tests/expected/blkid/lowprobe-pt-atari-icd b/tests/expected/blkid/lowprobe-pt-atari-icd +deleted file mode 100644 +index 29942b123..000000000 +--- a/tests/expected/blkid/lowprobe-pt-atari-icd ++++ /dev/null +@@ -1,8 +0,0 @@ +-size: 8388608, sector size: 512, PT: atari, offset: 0, id=(null) +---- +-#1: 65 4032 0x0 type='FAT' +-#2: 4097 904 0x0 type='FOO' +-#4: 12289 4096 0x0 type='BAR' +-#5: 5002 1999 0x0 type='GEM' +-#6: 7003 3238 0x0 type='RAW' +-#7: 10241 2048 0x0 type='RAW' +diff --git a/tests/expected/blkid/lowprobe-pt-atari-primary b/tests/expected/blkid/lowprobe-pt-atari-primary +new file mode 100644 +index 000000000..472821e47 +--- /dev/null ++++ b/tests/expected/blkid/lowprobe-pt-atari-primary +@@ -0,0 +1,3 @@ ++size: 5242880, sector size: 512, PT: atari, offset: 0, id=(null) ++--- ++#1: 2 10238 0x0 type='RAW' +diff --git a/tests/expected/blkid/lowprobe-pt-atari-xgm b/tests/expected/blkid/lowprobe-pt-atari-xgm +index 4b7756655..a7dae6995 100644 +--- a/tests/expected/blkid/lowprobe-pt-atari-xgm ++++ b/tests/expected/blkid/lowprobe-pt-atari-xgm +@@ -1,8 +1,4 @@ +-size: 8388608, sector size: 512, PT: atari, offset: 0, id=(null) ++size: 5242880, sector size: 512, PT: atari, offset: 0, id=(null) + --- +-#1: 65 4032 0x0 type='FAT' +-#2: 4097 904 0x0 type='FOO' +-#3: 5002 1999 0x0 type='GEM' +-#4: 7003 3238 0x0 type='RAW' +-#5: 10241 2048 0x0 type='RAW' +-#6: 12289 4096 0x0 type='BAR' ++#1: 2 9 0x0 type='RAW' ++#2: 14 10226 0x0 type='RAW' +diff --git a/tests/ts/blkid/images-pt/atari-icd.img.xz b/tests/ts/blkid/images-pt/atari-icd.img.xz +deleted file mode 100644 +index 00a2aba49a8f940c35b788fd693f966a31cd1aaf..0000000000000000000000000000000000000000 +GIT binary patch +literal 0 +HcmV?d00001 + +literal 1920 +zcmexsUKJ6=z`*kC+7>q^21Q0O1_p)_{ilon|NqLI8OvZIducK^Ecg5@jkusTr=nRy9*!Bn(bM`eR*oT<-}u76EuU~ +zr&{jenxVc;S-qm~ZIsPAhf|HgcYYYo_5QBSWhxk^uDJZlk@ka|=4h`oy~sXG;MryA +zIO|(4yiWFOUJ0<66IC1R`kF;$O2rLg_J2GWu-_F>bn|D|)EpJ!*v${KQj{VzR>(-u`|K~x`ZzH*T0p2&o +zI-4YzQ@78Q>MqMUn_j_J&?R}Ab%JX4g_GgC#kn_Er2N@;{G{oT!>g3%?{7LTl&~r1 +z*sPkJ_H4EL-ks8A5cG>Zb+_(`db`H=OHtd`KiM;({>U6}*_GC3*O{IFD%<~0_S{B} +zIAt^L!kb^-#2H7;7G8c(H`jXWaenqoR^eP0x0jjMz0;S=ntyt=$t<^43C^Wa`_>-0 +zn)7LCqnV7@rul}KIZjS|we9MTwfEKjD!a`sVqAVcbjH02iV_QaLoQ$Lm6>2)J5?)m +z+4ZM<_KLr<4xZ|{k^g93P-0R3!R;b!3l;9v+iG1rUa|31OFLJYVQ4>WuO;!puhEVbK`;3BdWnazD_hVWL>)9 +zUH-uWUw59169reTO_1GnZlk(HOk~^3w4jK6F9(a&E)Q>o&j0_BF`3~_aq#lL`_|PM +zO3mNiYnWFsZ@F^(8;#Sg7pKnXs?(bINxk&DxBzBB&bSbuc_Kc+u-9hd96{dU62 +zdy9&v9!&J;nWpuKafAQ2KRiy8H+G)6azfr>>9!ZUEsJ{hn{EH;vMu55vVwblapfAb +zxMqapUGF~CVIOb!`-J}sVcYGG8+IwL_`%kF^K1PzUTOPUszzJx7yZuII0hq?niBJy +ztHOi*X|1ZF(LqR~lKc93~ +zM{UwbNSDCeSh)377bwKEDG0HlkOiq$@C5SPZ)#xt%D~Ft{N&Fs28N&OuDBU3?>)l6 +bc!#f{p@D_bU0QSFk@Vk8zq^21Q0O1_p)_{ilon|NG21IhKJT|L>o5D`zuK%~gJC<+=Ii +zjxFDrre11~o8UX~^*sr`-ND)CA`-a`g{vlPsQ4ms_SS~eoI5Q;loOk08+!D2evoWh +za^cV`_b30BuKD=6`BwT2=4;0@BCk29bN`)lS>&4=``*}-hYFe|Np9+Tq~OEO|Ip}x +zJ4;5zolM)LTaTWs>#-B)sg`FET(veqcGtO$>Jl-LZ7YVQ4>WuO;!puhEVbK`;3BdWnazD_hVWL>)9UH-uWUw59169<{qE8fUY +zo&R5eQJdjSaq#lL`_|PMO3mNiYnWFsZ@F^(8;#Sg7pKnXs?(bINxk&DxBzBB&b +zSbuc_{}AvSO=2{V-+t2s#$OCG2V;Pp`LJObFuO6V(c5G(m3T!1071TaDPc176 +z%r3#|+u3QZtfaEW{3%z$%QU-cGO>PfMsWxu0c{gkG*2F%lPd=M1Y0KMdb1z~F#!dT +z0hR!nlZ*pGlY9kID9q|Q?7#p305pfRGwmY1>Hq(WLc?9R2t|ec6RBZT@27Sz` +zOOUBo_werj4>Y!M_jnW_X5LT!U5BJX(|7z_`gvmiFY#+&QGZnQ(jc275rI8N1mYN% +z7v%B{<<#dXY{%}<@y#~8tP9hXhdGhPLXas^?`1i>3YaIhBPV!{?OHspK+1tr-1sq_ +zOZO`ZH4#=PA*a;DhrzO(E3P%s2bvJ((;Hqp+UQEjk15npIGkF2Q$_0pB(dp;yn_5C +zKjIcSPFeWwJAX-pwI>0p^9vxJ5{vOrh0paF?UCzL@0Je2X%OGwl&9sLSXEoYL7KSi +z7kK;C!)?P%&jT1dJAlLZ%9j=5dAv$#2>cZVkYtBX;b +zKkd4%t<0bN;Bxyi9^Oz(*%pa{7z1UunHr0BY|UqQ4u5cp8OsHbC2P>hSGyMrvv_3u +zzQ@Tm#KWp1pTB~~5@51y#+rP&KL&li?#e9y5l&so-G1aJhbZ^bTDPy{ypVsyoJ$?4 +zJI$^(&-ERT{vFP-2wo#L3vt=>>|Qfkn-izOEp0os#}5b6I#&uf+o6-(AknAKCP^m+ +zEB^#2tYI)UL`(v`beQMaSJV*sS*EXE2$I<^GcOj!0Hii26j3aN*&gGTU5Zv+1i&@u +zjId2o5C}?3I%5GFBrU@lP*l(vtk2>ZTe5f +z$zE{PRc+w5GMeW^E4f@oa+%ryKCLFeKmd=m8Cq32;k}|hR%L!j^w4xxgPa6z%)Qy@ +zimjI||1RsAlMMk+M(8o4AFk??@Qc3})r~lth`4dR`1> +z^;L1tHfbGi`%8!rY(mS3KU@Hh&`z%=D3oy@J&z>elMn+h2}%2(tDpZ60W6XOI|uL2 +zV$Ccjl9Rv!HWZKL5CJQa1C*2A0vVHh0)H=n0rda{07K;b`Tzg` +l001+77wRp|PznG6*$#k!fCRGE)_JkSXZr#G00004Sz1dOv2XwY + +-- +2.36.1 + diff --git a/0084-tests-update-atari-partx-tests.patch b/0084-tests-update-atari-partx-tests.patch new file mode 100644 index 0000000..2d004cd --- /dev/null +++ b/0084-tests-update-atari-partx-tests.patch @@ -0,0 +1,55 @@ +From cf74ece6486dabfd4b84c90435348c04ff72ef54 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 13 Oct 2020 18:34:39 +0200 +Subject: tests: update atari partx tests + +Upstream: http://github.com/util-linux/util-linux/commit/017c0308c7d3b0d84bfc11e5863220bc32d640ba +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030 +Signed-off-by: Karel Zak +--- + tests/expected/partx/partx-image-atari-icd | 7 ------- + tests/expected/partx/partx-image-atari-primary | 2 ++ + tests/expected/partx/partx-image-atari-xgm | 10 +++------- + 3 files changed, 5 insertions(+), 14 deletions(-) + delete mode 100644 tests/expected/partx/partx-image-atari-icd + create mode 100644 tests/expected/partx/partx-image-atari-primary + +diff --git a/tests/expected/partx/partx-image-atari-icd b/tests/expected/partx/partx-image-atari-icd +deleted file mode 100644 +index 8677dff03..000000000 +--- a/tests/expected/partx/partx-image-atari-icd ++++ /dev/null +@@ -1,7 +0,0 @@ +-NR START END SECTORS SIZE NAME UUID +- 1 65 4096 4032 2M +- 2 4097 5000 904 452K +- 4 12289 16384 4096 2M +- 5 5002 7000 1999 999.5K +- 6 7003 10240 3238 1.6M +- 7 10241 12288 2048 1M +diff --git a/tests/expected/partx/partx-image-atari-primary b/tests/expected/partx/partx-image-atari-primary +new file mode 100644 +index 000000000..044d319be +--- /dev/null ++++ b/tests/expected/partx/partx-image-atari-primary +@@ -0,0 +1,2 @@ ++NR START END SECTORS SIZE NAME UUID ++ 1 2 10239 10238 5M +diff --git a/tests/expected/partx/partx-image-atari-xgm b/tests/expected/partx/partx-image-atari-xgm +index 248d6a56a..557327c04 100644 +--- a/tests/expected/partx/partx-image-atari-xgm ++++ b/tests/expected/partx/partx-image-atari-xgm +@@ -1,7 +1,3 @@ +-NR START END SECTORS SIZE NAME UUID +- 1 65 4096 4032 2M +- 2 4097 5000 904 452K +- 3 5002 7000 1999 999.5K +- 4 7003 10240 3238 1.6M +- 5 10241 12288 2048 1M +- 6 12289 16384 4096 2M ++NR START END SECTORS SIZE NAME UUID ++ 1 2 10 9 4.5K ++ 2 14 10239 10226 5M +-- +2.36.1 + diff --git a/0085-libuuid-Implement-continuous-clock-handling-for-time.patch b/0085-libuuid-Implement-continuous-clock-handling-for-time.patch new file mode 100644 index 0000000..ef9798b --- /dev/null +++ b/0085-libuuid-Implement-continuous-clock-handling-for-time.patch @@ -0,0 +1,375 @@ +From ce49a152fd8a830b1c9c0a8b745ea71feff71697 Mon Sep 17 00:00:00 2001 +From: Michael Trapp +Date: Mon, 20 Jun 2022 17:10:36 +0200 +Subject: libuuid: Implement continuous clock handling for time based UUIDs + +In a uuidd setup, the daemon is a singleton and can maintain it's own +resources for time based UUID generation. This requires a dedicated +'clock sequence range' but does not need any further lock/update of +the LIBUUID_CLOCK_FILE from uuidd. The range of available clock values +is extended by a continuous handling of the clock updates - instead of +updating the value to the current timestamp, it is incremented by +the number of requested UUIDs. + +[kzak@redhat.com: - backport from upstream v2.39 to to RHEL-8] + +Upstream: http://github.com/util-linux/util-linux/commit/3cfba7d39b66eff4307218fefd8bb34bb1621f83 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141969 +Signed-off-by: Karel Zak +--- + libuuid/src/gen_uuid.c | 91 ++++++++++++++++++++++++++++++++++++++--- + libuuid/src/libuuid.sym | 1 + + libuuid/src/uuidd.h | 1 + + misc-utils/uuidd.8.in | 12 ++++++ + misc-utils/uuidd.c | 86 ++++++++++++++++++++++++++++++++++++-- + 5 files changed, 182 insertions(+), 9 deletions(-) + +diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c +index 27c135db5..f557053f7 100644 +--- a/libuuid/src/gen_uuid.c ++++ b/libuuid/src/gen_uuid.c +@@ -209,6 +209,8 @@ static int get_node_id(unsigned char *node_id) + + /* Assume that the gettimeofday() has microsecond granularity */ + #define MAX_ADJUSTMENT 10 ++/* Reserve a clock_seq value for the 'continuous clock' implementation */ ++#define CLOCK_SEQ_CONT 0 + + /* + * Get clock from global sequence clock counter. +@@ -275,8 +277,10 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low, + } + + if ((last.tv_sec == 0) && (last.tv_usec == 0)) { +- random_get_bytes(&clock_seq, sizeof(clock_seq)); +- clock_seq &= 0x3FFF; ++ do { ++ random_get_bytes(&clock_seq, sizeof(clock_seq)); ++ clock_seq &= 0x3FFF; ++ } while (clock_seq == CLOCK_SEQ_CONT); + gettimeofday(&last, NULL); + last.tv_sec--; + } +@@ -286,7 +290,9 @@ try_again: + if ((tv.tv_sec < last.tv_sec) || + ((tv.tv_sec == last.tv_sec) && + (tv.tv_usec < last.tv_usec))) { +- clock_seq = (clock_seq+1) & 0x3FFF; ++ do { ++ clock_seq = (clock_seq+1) & 0x3FFF; ++ } while (clock_seq == CLOCK_SEQ_CONT); + adjustment = 0; + last = tv; + } else if ((tv.tv_sec == last.tv_sec) && +@@ -331,6 +337,64 @@ try_again: + return ret; + } + ++/* ++ * Get current time in 100ns ticks. ++ */ ++static uint64_t get_clock_counter(void) ++{ ++ struct timeval tv; ++ uint64_t clock_reg; ++ ++ gettimeofday(&tv, NULL); ++ clock_reg = tv.tv_usec*10; ++ clock_reg += ((uint64_t) tv.tv_sec) * 10000000ULL; ++ ++ return clock_reg; ++} ++ ++/* ++ * Get continuous clock value. ++ * ++ * Return -1 if there is no further clock counter available, ++ * otherwise return 0. ++ * ++ * This implementation doesn't deliver clock counters based on ++ * the current time because last_clock_reg is only incremented ++ * by the number of requested UUIDs. ++ * max_clock_offset is used to limit the offset of last_clock_reg. ++ */ ++static int get_clock_cont(uint32_t *clock_high, ++ uint32_t *clock_low, ++ int num, ++ uint32_t max_clock_offset) ++{ ++ /* 100ns based time offset according to RFC 4122. 4.1.4. */ ++ const uint64_t reg_offset = (((uint64_t) 0x01B21DD2) << 32) + 0x13814000; ++ static uint64_t last_clock_reg = 0; ++ uint64_t clock_reg; ++ ++ if (last_clock_reg == 0) ++ last_clock_reg = get_clock_counter(); ++ ++ clock_reg = get_clock_counter(); ++ if (max_clock_offset) { ++ uint64_t clock_offset = max_clock_offset * 10000000ULL; ++ if (last_clock_reg < (clock_reg - clock_offset)) ++ last_clock_reg = clock_reg - clock_offset; ++ } ++ ++ clock_reg += MAX_ADJUSTMENT; ++ ++ if ((last_clock_reg + num) >= clock_reg) ++ return -1; ++ ++ *clock_high = (last_clock_reg + reg_offset) >> 32; ++ *clock_low = last_clock_reg + reg_offset; ++ last_clock_reg += num; ++ ++ return 0; ++} ++ + #if defined(HAVE_UUIDD) && defined(HAVE_SYS_UN_H) + + /* +@@ -403,7 +467,7 @@ static int get_uuid_via_daemon(int op __attribute__((__unused__)), + } + #endif + +-int __uuid_generate_time(uuid_t out, int *num) ++static int __uuid_generate_time_internal(uuid_t out, int *num, uint32_t cont_offset) + { + static unsigned char node_id[6]; + static int has_init = 0; +@@ -423,7 +487,14 @@ int __uuid_generate_time(uuid_t out, int *num) + } + has_init = 1; + } +- ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num); ++ if (cont_offset) { ++ ret = get_clock_cont(&clock_mid, &uu.time_low, *num, cont_offset); ++ uu.clock_seq = CLOCK_SEQ_CONT; ++ if (ret != 0) /* fallback to previous implpementation */ ++ ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num); ++ } else { ++ ret = get_clock(&clock_mid, &uu.time_low, &uu.clock_seq, num); ++ } + uu.clock_seq |= 0x8000; + uu.time_mid = (uint16_t) clock_mid; + uu.time_hi_and_version = ((clock_mid >> 16) & 0x0FFF) | 0x1000; +@@ -432,6 +503,16 @@ int __uuid_generate_time(uuid_t out, int *num) + return ret; + } + ++int __uuid_generate_time(uuid_t out, int *num) ++{ ++ return __uuid_generate_time_internal(out, num, 0); ++} ++ ++int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset) ++{ ++ return __uuid_generate_time_internal(out, num, cont_offset); ++} ++ + /* + * Generate time-based UUID and store it to @out + * +diff --git a/libuuid/src/libuuid.sym b/libuuid/src/libuuid.sym +index 9e3e80035..0a072b703 100644 +--- a/libuuid/src/libuuid.sym ++++ b/libuuid/src/libuuid.sym +@@ -51,6 +51,7 @@ global: + UUIDD_PRIVATE { + global: + __uuid_generate_time; ++ __uuid_generate_time_cont; + __uuid_generate_random; + local: + *; +diff --git a/libuuid/src/uuidd.h b/libuuid/src/uuidd.h +index e55c86f2f..14a01ade2 100644 +--- a/libuuid/src/uuidd.h ++++ b/libuuid/src/uuidd.h +@@ -50,5 +50,6 @@ + + extern int __uuid_generate_time(uuid_t out, int *num); + extern void __uuid_generate_random(uuid_t out, int *num); ++extern int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont); + + #endif /* _UUID_UUID_H */ +diff --git a/misc-utils/uuidd.8.in b/misc-utils/uuidd.8.in +index 0a5cf471b..28bcb48b5 100644 +--- a/misc-utils/uuidd.8.in ++++ b/misc-utils/uuidd.8.in +@@ -16,6 +16,18 @@ universally unique identifiers (UUIDs), especially time-based UUIDs, + in a secure and guaranteed-unique fashion, even in the face of large + numbers of threads running on different CPUs trying to grab UUIDs. + .SH OPTIONS ++ ++.TP ++.BR \-C , " \-\-cont\-clock " [\fInumber\fR] ++Activate continuous clock handling for time based UUIDs. uuidd could use all ++possible clock values, beginning with the daemon's start time. The optional ++argument can be used to set a value for the max_clock_offset. This gurantees, ++that a clock value of a UUID will always be within the range of the ++max_clock_offset. '-C' or '--cont-clock' enables the feature with a default ++max_clock_offset of 2 hours. '-C[hd]' or '--cont-clock=[hd]' enables ++the feature with a max_clock_offset of NUM seconds. In case of an appended h or ++d, the NUM value is read in hours or days. The minimum value is 60 seconds, the ++maximum value is 365 days. + .TP + .BR \-d , " \-\-debug " + Run uuidd in debugging mode. This prevents uuidd from running as a daemon. +diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c +index 8b83d91c0..e3c0abad7 100644 +--- a/misc-utils/uuidd.c ++++ b/misc-utils/uuidd.c +@@ -49,6 +49,8 @@ struct uuidd_cxt_t { + const char *cleanup_pidfile; + const char *cleanup_socket; + uint32_t timeout; ++ uint32_t cont_clock_offset; ++ + unsigned int debug: 1, + quiet: 1, + no_fork: 1, +@@ -73,6 +75,8 @@ static void __attribute__((__noreturn__)) usage(void) + fputs(_(" -P, --no-pid do not create pid file\n"), out); + fputs(_(" -F, --no-fork do not daemonize using double-fork\n"), out); + fputs(_(" -S, --socket-activation do not create listening socket\n"), out); ++ fputs(_(" -C, --cont-clock[=[hd]]\n"), out); ++ fputs(_(" activate continuous clock handling\n"), out); + fputs(_(" -d, --debug run in debugging mode\n"), out); + fputs(_(" -q, --quiet turn on quiet mode\n"), out); + fputs(USAGE_SEPARATOR, out); +@@ -401,6 +405,15 @@ static void server_loop(const char *socket_path, const char *pidfile_path, + pfd[POLLFD_SOCKET].fd = s; + pfd[POLLFD_SIGNAL].events = pfd[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP; + ++ num = 1; ++ if (uuidd_cxt->cont_clock_offset) { ++ /* trigger initialization */ ++ (void) __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset); ++ if (uuidd_cxt->debug) ++ fprintf(stderr, _("max_clock_offset = %u sec\n"), ++ uuidd_cxt->cont_clock_offset); ++ } ++ + while (1) { + ret = poll(pfd, ARRAY_SIZE(pfd), + uuidd_cxt->timeout ? +@@ -458,7 +471,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path, + break; + case UUIDD_OP_TIME_UUID: + num = 1; +- __uuid_generate_time(uu, &num); ++ __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset); + if (uuidd_cxt->debug) { + uuid_unparse(uu, str); + fprintf(stderr, _("Generated time UUID: %s\n"), str); +@@ -477,7 +490,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path, + reply_len = sizeof(uu); + break; + case UUIDD_OP_BULK_TIME_UUID: +- __uuid_generate_time(uu, &num); ++ __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset); + if (uuidd_cxt->debug) { + uuid_unparse(uu, str); + fprintf(stderr, P_("Generated time UUID %s " +@@ -530,6 +543,64 @@ static void __attribute__ ((__noreturn__)) unexpected_size(int size) + errx(EXIT_FAILURE, _("Unexpected reply length from server %d"), size); + } + ++/* Backport from v2.39 lib/strutils.c */ ++static int ul_strtos64(const char *str, int64_t *num, int base) ++{ ++ char *end = NULL; ++ ++ if (str == NULL || *str == '\0') ++ return -(errno = EINVAL); ++ ++ errno = 0; ++ *num = (int64_t) strtoimax(str, &end, base); ++ ++ if (errno != 0) ++ return -errno; ++ if (str == end || (end && *end)) ++ return -(errno = EINVAL); ++ return 0; ++} ++ ++/* Backport from v2.39 lib/strutils.c */ ++static int64_t str2num_or_err(const char *str, int base, const char *errmesg, ++ int64_t low, int64_t up) ++{ ++ int64_t num = 0; ++ int rc; ++ ++ rc = ul_strtos64(str, &num, base); ++ if (rc == 0 && ((low && num < low) || (up && num > up))) ++ rc = -(errno = ERANGE); ++ ++ if (rc) { ++ if (errno == ERANGE) ++ err(EXIT_FAILURE, "%s: '%s'", errmesg, str); ++ errx(EXIT_FAILURE, "%s: '%s'", errmesg, str); ++ } ++ return num; ++} ++ ++static uint32_t parse_cont_clock(char *arg) ++{ ++ uint32_t min_val = 60, ++ max_val = (3600 * 24 * 365), ++ factor = 1; ++ char *p = &arg[strlen(arg)-1]; ++ ++ if ('h' == *p) { ++ *p = '\0'; ++ factor = 3600; ++ min_val = 1; ++ } ++ if ('d' == *p) { ++ *p = '\0'; ++ factor = 24 * 3600; ++ min_val = 1; ++ } ++ return factor * str2num_or_err(optarg, 10, _("failed to parse --cont-clock/-C"), ++ min_val, max_val / factor); ++} ++ + int main(int argc, char **argv) + { + const char *socket_path = UUIDD_SOCKET_PATH; +@@ -543,7 +614,7 @@ int main(int argc, char **argv) + int no_pid = 0; + int s_flag = 0; + +- struct uuidd_cxt_t uuidd_cxt = { .timeout = 0 }; ++ struct uuidd_cxt_t uuidd_cxt = { .timeout = 0, .cont_clock_offset = 0 }; + + static const struct option longopts[] = { + {"pid", required_argument, NULL, 'p'}, +@@ -556,6 +627,7 @@ int main(int argc, char **argv) + {"no-pid", no_argument, NULL, 'P'}, + {"no-fork", no_argument, NULL, 'F'}, + {"socket-activation", no_argument, NULL, 'S'}, ++ {"cont-clock", optional_argument, NULL, 'C'}, + {"debug", no_argument, NULL, 'd'}, + {"quiet", no_argument, NULL, 'q'}, + {"version", no_argument, NULL, 'V'}, +@@ -576,10 +648,16 @@ int main(int argc, char **argv) + atexit(close_stdout); + + while ((c = +- getopt_long(argc, argv, "p:s:T:krtn:PFSdqVh", longopts, ++ getopt_long(argc, argv, "p:s:T:krtn:PFSC::dqVh", longopts, + NULL)) != -1) { + err_exclusive_options(c, longopts, excl, excl_st); + switch (c) { ++ case 'C': ++ if (optarg != NULL) ++ uuidd_cxt.cont_clock_offset = parse_cont_clock(optarg); ++ else ++ uuidd_cxt.cont_clock_offset = 7200; /* default 2h */ ++ break; + case 'd': + uuidd_cxt.debug = 1; + break; +-- +2.38.1 + diff --git a/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch b/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch new file mode 100644 index 0000000..401c52a --- /dev/null +++ b/0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch @@ -0,0 +1,35 @@ +From fffaa2c0856de8c42b17c52a641cbc5d00ec012b Mon Sep 17 00:00:00 2001 +From: Michael Trapp +Date: Tue, 2 Aug 2022 14:16:43 +0200 +Subject: libuuid: check clock value from LIBUUID_CLOCK_FILE + +The clock value from the LIBUUID_CLOCK_FILE must be checked in +case of an update of libuuid. If clock==CLOCK_SEQ_CONT it must +be set to a new value. + +Signed-off-by: Karel Zak +Upstream: http://github.com/util-linux/util-linux/commit/5d1424d85ac9e2a1369ee920038825c154ee5443 +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141969 +--- + libuuid/src/gen_uuid.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c +index f557053f7..8dc38559f 100644 +--- a/libuuid/src/gen_uuid.c ++++ b/libuuid/src/gen_uuid.c +@@ -274,6 +274,11 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low, + last.tv_usec = tv2; + adjustment = a; + } ++ // reset in case of reserved CLOCK_SEQ_CONT ++ if (clock_seq == CLOCK_SEQ_CONT) { ++ last.tv_sec = 0; ++ last.tv_usec = 0; ++ } + } + + if ((last.tv_sec == 0) && (last.tv_usec == 0)) { +-- +2.38.1 + diff --git a/1001-hwclock-make-glibc-2.31-compatible.patch b/1001-hwclock-make-glibc-2.31-compatible.patch deleted file mode 100644 index d4908a6..0000000 --- a/1001-hwclock-make-glibc-2.31-compatible.patch +++ /dev/null @@ -1,161 +0,0 @@ -From e42f9f05a96c9e0129722b15fc638d4133ac1ecb Mon Sep 17 00:00:00 2001 -From: J William Piggott -Date: Tue, 19 Apr 2022 23:22:11 -0400 -Subject: [PATCH] hwclock: make glibc 2.31 compatible -______________________________________________________ -GNU C Library NEWS -- history of user-visible changes. -Version 2.31 -Deprecated and removed features, and other changes affecting compatibility: - -* The settimeofday function can still be used to set a system-wide time - zone when the operating system supports it. This is because the Linux - kernel reused the API, on some architectures, to describe a system-wide - time-zone-like offset between the software clock maintained by the kernel, - and the "RTC" clock that keeps time when the system is shut down. - - However, to reduce the odds of this offset being set by accident, - settimeofday can no longer be used to set the time and the offset - simultaneously. If both of its two arguments are non-null, the call - will fail (setting errno to EINVAL). - - Callers attempting to set this offset should also be prepared for the call - to fail and set errno to ENOSYS; this already happens on the Hurd and on - some Linux architectures. The Linux kernel maintainers are discussing a - more principled replacement for the reused API. After a replacement - becomes available, we will change settimeofday to fail with ENOSYS on all - platforms when its 'tzp' argument is not a null pointer. - - settimeofday itself is obsolescent according to POSIX. Programs that set - the system time should use clock_settime and/or the adjtime family of - functions instead. We may cease to make settimeofday available to newly - linked binaries after there is a replacement for Linux's time-zone-like - offset API. -______________________________________________________ - -hwclock(8) had one settimeofday(2) call where both args were set for ---hctosys when the RTC was ticking UTC. This allowed setting the system -time, timezone, and locking the warp_clock function with a single call. -That operation now takes 3 calls of settimeofday(2). - -Although this common operation now takes three calls, the overall logic -for the set_system_clock() function was simplified. - -Co-Author: Karel Zak -Signed-off-by: J William Piggott ---- - sys-utils/hwclock.c | 70 ++++++++++++++++++++++----------------------- - 1 file changed, 35 insertions(+), 35 deletions(-) - -diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c -index b83e710..19e7410 100644 ---- a/sys-utils/hwclock.c -+++ b/sys-utils/hwclock.c -@@ -583,28 +583,28 @@ display_time(struct timeval hwctime) - * tz.tz_minuteswest argument and sets PCIL (see below). At boot settimeofday(2) - * has one-shot access to this function as shown in the table below. - * -- * +-------------------------------------------------------------------+ -- * | settimeofday(tv, tz) | -- * |-------------------------------------------------------------------| -- * | Arguments | System Time | PCIL | | warp_clock | -- * | tv | tz | set | warped | set | firsttime | locked | -- * |---------|---------|---------------|------|-----------|------------| -- * | pointer | NULL | yes | no | no | 1 | no | -- * | pointer | pointer | yes | no | no | 0 | yes | -- * | NULL | ptr2utc | no | no | no | 0 | yes | -- * | NULL | pointer | no | yes | yes | 0 | yes | -- * +-------------------------------------------------------------------+ -+ * +-------------------------------------------------------------------------+ -+ * | settimeofday(tv, tz) | -+ * |-------------------------------------------------------------------------| -+ * | Arguments | System Time | TZ | PCIL | | warp_clock | -+ * | tv | tz | set | warped | set | set | firsttime | locked | -+ * |---------|---------|---------------|-----|------|-----------|------------| -+ * | pointer | NULL | yes | no | no | no | 1 | no | -+ * | NULL | ptr2utc | no | no | yes | no | 0 | yes | -+ * | NULL | pointer | no | yes | yes | yes | 0 | yes | -+ * +-------------------------------------------------------------------------+ - * ptr2utc: tz.tz_minuteswest is zero (UTC). - * PCIL: persistent_clock_is_local, sets the "11 minute mode" timescale. - * firsttime: locks the warp_clock function (initialized to 1 at boot). -+ * Since glibc v2.31 settimeofday() will fail if both args are non NULL - * - * +---------------------------------------------------------------------------+ - * | op | RTC scale | settimeofday calls | - * |---------|-----------|-----------------------------------------------------| - * | systz | Local | 1) warps system time*, sets PCIL* and kernel tz | - * | systz | UTC | 1st) locks warp_clock* 2nd) sets kernel tz | -- * | hctosys | Local | 1st) sets PCIL* 2nd) sets system time and kernel tz | -- * | hctosys | UTC | 1) sets system time and kernel tz | -+ * | hctosys | Local | 1st) sets PCIL* & kernel tz 2nd) sets system time | -+ * | hctosys | UTC | 1st) locks warp* 2nd) sets tz 3rd) sets system time | - * +---------------------------------------------------------------------------+ - * * only on first call after boot - */ -@@ -615,41 +615,41 @@ set_system_clock(const struct hwclock_control *ctl, - struct tm broken; - int minuteswest; - int rc = 0; -- const struct timezone tz_utc = { 0 }; - - localtime_r(&newtime.tv_sec, &broken); - minuteswest = -get_gmtoff(&broken) / 60; - - if (ctl->verbose) { -- if (ctl->hctosys && !ctl->universal) -- printf(_("Calling settimeofday(NULL, %d) to set " -- "persistent_clock_is_local.\n"), minuteswest); -- if (ctl->systz && ctl->universal) -+ if (ctl->universal) { - puts(_("Calling settimeofday(NULL, 0) " -- "to lock the warp function.")); -+ "to lock the warp_clock function.")); -+ if (!( ctl->universal && !minuteswest )) -+ printf(_("Calling settimeofday(NULL, %d) " -+ "to set the kernel timezone.\n"), -+ minuteswest); -+ } else -+ printf(_("Calling settimeofday(NULL, %d) to warp " -+ "System time, set PCIL and the kernel tz.\n"), -+ minuteswest); -+ - if (ctl->hctosys) -- printf(_("Calling settimeofday(%ld.%06ld, %d)\n"), -- newtime.tv_sec, newtime.tv_usec, minuteswest); -- else { -- printf(_("Calling settimeofday(NULL, %d) "), minuteswest); -- if (ctl->universal) -- puts(_("to set the kernel timezone.")); -- else -- puts(_("to warp System time.")); -- } -+ printf(_("Calling settimeofday(%ld.%06ld, NULL) " -+ "to set the System time.\n"), -+ newtime.tv_sec, newtime.tv_usec); - } - - if (!ctl->testing) { -+ const struct timezone tz_utc = { 0 }; - const struct timezone tz = { minuteswest }; -- -- if (ctl->hctosys && !ctl->universal) /* set PCIL */ -- rc = settimeofday(NULL, &tz); -- if (ctl->systz && ctl->universal) /* lock warp_clock */ -+ /* If UTC RTC: lock warp_clock and PCIL */ -+ if (ctl->universal) - rc = settimeofday(NULL, &tz_utc); -- if (!rc && ctl->hctosys) -- rc = settimeofday(&newtime, &tz); -- else if (!rc) -+ /* Set kernel tz; if localtime RTC: warp_clock and set PCIL */ -+ if (!rc && !( ctl->universal && !minuteswest )) - rc = settimeofday(NULL, &tz); -+ /* Set the System Clock */ -+ if ((!rc || errno == ENOSYS) && ctl->hctosys) -+ rc = settimeofday(&newtime, NULL); - - if (rc) { - warn(_("settimeofday() failed")); --- -2.27.0 - diff --git a/1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch b/1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch deleted file mode 100644 index 9b6afb1..0000000 --- a/1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch +++ /dev/null @@ -1,24 +0,0 @@ -From dc11290085e49ec47be148447104f50ce3e7244b Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Tue, 27 Sep 2022 11:21:16 +0800 -Subject: [PATCH] add Neoverse-N2 to ARM identifiers tables - ---- - sys-utils/lscpu-arm.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c -index 2b178a7..697a4b2 100644 ---- a/sys-utils/lscpu-arm.c -+++ b/sys-utils/lscpu-arm.c -@@ -80,6 +80,7 @@ static const struct id_part arm_part[] = { - { 0xd21, "Cortex-M33" }, - { 0xd41, "Cortex-A78" }, - { 0xd42, "Cortex-A78AE" }, -+ { 0xd49, "Neoverse-N2" }, - { 0xd4a, "Neoverse-E1" }, - { 0xd4b, "Cortex-A78C" }, - { -1, "unknown" }, --- -2.31.1 - diff --git a/1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch b/1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch deleted file mode 100644 index 1893c87..0000000 --- a/1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 117b51eb538673be49bf0e619d2307a65963d1dd Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Tue, 27 Sep 2022 15:31:51 +0800 -Subject: [PATCH] fix lscpu to get cpu frequency from cpuinfo on arm64 - ---- - sys-utils/lscpu.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c -index 70a797d..a7014a0 100644 ---- a/sys-utils/lscpu.c -+++ b/sys-utils/lscpu.c -@@ -433,6 +433,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) - else if (lookup(buf, "stepping", &desc->stepping)) ; - else if (lookup(buf, "CPU variant", &desc->stepping)) ; /* aarch64 */ - else if (lookup(buf, "cpu MHz", &desc->mhz)) ; -+ else if (lookup(buf, "CPU MHz", &desc->mhz)) ; /* aarch64 */ - else if (lookup(buf, "cpu MHz dynamic", &desc->dynamic_mhz)) ; /* s390 */ - else if (lookup(buf, "cpu MHz static", &desc->static_mhz)) ; /* s390 */ - else if (lookup(buf, "flags", &desc->flags)) ; /* x86 */ --- -2.31.1 - diff --git a/dist b/dist new file mode 100644 index 0000000..535c690 --- /dev/null +++ b/dist @@ -0,0 +1 @@ +an8_7 diff --git a/util-linux.spec b/util-linux.spec index dcad610..cf4fbde 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,9 +1,8 @@ -%define anolis_release .0.3 ### Header Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 35%{anolis_release}%{?dist} +Release: 39%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -54,6 +53,7 @@ Source2: util-linux-remote.pamd Source3: util-linux-chsh-chfn.pamd Source4: util-linux-60-raw.rules Source5: adjtime +Source6: uuidd-tmpfiles.conf Source12: util-linux-su.pamd Source13: util-linux-su-l.pamd Source14: util-linux-runuser.pamd @@ -245,12 +245,27 @@ Patch74: 0074-Complete-Linux-PAM-compliance-for-forked-child-in-su.patch # 2058176 - losetup Retry LOOP_SET_STATUS64 on EAGAIN Patch75: 0075-lib-loopdev-retry-LOOP_SET_STATUS64-and-LOOP_SET_BLO.patch -# Begin: Anolis customized patches -# hwclock: make glibc 2.31 compatible -Patch1001: 1001-hwclock-make-glibc-2.31-compatible.patch -Patch1002: 1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch -Patch1003: 1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch -# End: Anolis customized patches +### RHEL-8.7 +### +# 2060030 - Please backport patches for atari partition detection to RHEL 8 +Patch76: 0076-libblkid-fix-Atari-prober-logic.patch +Patch77: 0077-libblkid-make-Atari-more-robust.patch +Patch78: 0078-libblkid-allow-a-lot-of-mac-partitions.patch +Patch79: 0079-libblkid-limit-amount-of-parsed-partitions.patch +Patch80: 0080-libblkid-mac-make-sure-block-size-is-large-enough-fu.patch +# 2069187 - Internal testsuite for lscpu failed on aarch64 +Patch81: 0081-lscpu-don-t-read-from-HW-when-use-sys-snapshot.patch +# 2093166 - lslogins reports incorrect "Password is locked" status +Patch82: 0082-lslogins-improve-prefixes-interpretation.patch +# 2060030 - Please backport patches for atari partition detection to RHEL 8 +Patch83: 0083-tests-update-atari-blkid-tests.patch +Patch84: 0084-tests-update-atari-partx-tests.patch + +### RHEL-8.7.Z +### +# 2141969 - Add --cont-clock feature for libuuid and uuidd +Patch85: 0085-libuuid-Implement-continuous-clock-handling-for-time.patch +Patch86: 0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch %description The util-linux package contains a large variety of low-level system @@ -486,9 +501,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_bindir} mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man{1,6,8,5} mkdir -p ${RPM_BUILD_ROOT}%{_sbindir} mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/{pam.d,security/console.apps} -mkdir -p ${RPM_BUILD_ROOT}/var/log -touch ${RPM_BUILD_ROOT}/var/log/lastlog -chmod 0664 ${RPM_BUILD_ROOT}/var/log/lastlog +mkdir -p ${RPM_BUILD_ROOT}%{_tmpfilesdir} # install util-linux make install DESTDIR=${RPM_BUILD_ROOT} @@ -507,6 +520,7 @@ echo '.so man8/raw.8' > $RPM_BUILD_ROOT%{_mandir}/man8/rawdevices.8 mv ${RPM_BUILD_ROOT}%{_sbindir}/raw ${RPM_BUILD_ROOT}%{_bindir}/raw # And a dirs uuidd needs that the makefiles don't create +install -m 644 %{SOURCE6} ${RPM_BUILD_ROOT}%{_tmpfilesdir}/uuidd.conf install -d ${RPM_BUILD_ROOT}/run/uuidd install -d ${RPM_BUILD_ROOT}/var/lib/libuuid @@ -594,22 +608,6 @@ find $RPM_BUILD_ROOT%{_mandir}/man8 -regextype posix-egrep \ -printf "%{_mandir}/man8/%f*\n" >> %{name}.files %post -# only for minimal buildroots without /var/log -[ -d /var/log ] || mkdir -p /var/log -touch /var/log/lastlog -chown root:utmp /var/log/lastlog -chmod 0664 /var/log/lastlog -# Fix the file context, do not use restorecon -if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then - SECXT=$( /usr/sbin/matchpathcon -n /var/log/lastlog 2> /dev/null ) - if [ -n "$SECXT" ]; then - # Selinux enabled, but without policy? It's true for buildroots - # without selinux stuff on host machine with enabled selinux. - # We don't want to use any RPM dependence on selinux policy for - # matchpathcon(2). SELinux policy should be optional. - /usr/bin/chcon "$SECXT" /var/log/lastlog >/dev/null 2>&1 || : - fi -fi if [ ! -L /etc/mtab ]; then ln -sf ../proc/self/mounts /etc/mtab || : fi @@ -687,7 +685,6 @@ fi %attr(755,root,root) %{_bindir}/login %attr(2755,root,tty) %{_bindir}/write -%ghost %attr(0664,root,utmp) %verify(not md5 size mtime) /var/log/lastlog %ghost %verify(not md5 size mtime) %config(noreplace,missingok) /etc/mtab %{_unitdir}/fstrim.* @@ -1030,6 +1027,7 @@ fi %dir %attr(2775, uuidd, uuidd) /var/lib/libuuid %dir %attr(2775, uuidd, uuidd) /run/uuidd %{compldir}/uuidd +%{_tmpfilesdir}/uuidd.conf %files -n libfdisk @@ -1116,14 +1114,21 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog -* Tue Sep 27 2022 Forrestly 2.32.1-35.0.3 -- [Patch] lscpu: fix lscpu to get cpu frequency from cpuinfo on arm64 +* Wed Nov 16 2022 Karel Zak 2.32.1-39 +- fix #2141969 - Add --cont-clock feature for libuuid and uuidd + +* Mon Aug 22 2022 Karel Zak 2.32.1-38 +- improve tmpfiles.d use in spec file (related to #2059241) -* Tue Sep 27 2022 Forrestly 2.32.1-35.0.2 -- [Patch] lscpu: add Neoverse-N2 to ARM identifiers tables +* Fri Jul 15 2022 Karel Zak 2.32.1-37 +- update atari partition tests (related to #2060030) -* Tue May 17 2022 Weitao Zhou 2.32.1-35.0.1 -- [Patch] hwclock: better compatibility for both glibc2.28 and glibc2.31 +* Thu Jul 14 2022 Karel Zak 2.32.1-36 +- fix #2060030 - Please backport patches for atari partition detection to RHEL 8 +- fix #2069187 - Internal testsuite for lscpu failed on aarch64 +- fix #2093166 - lslogins reports incorrect "Password is locked" status +- fix #2059241 - rpm -V / --verify reports bad user/group/mtime for /run/uuidd +- fix #2044592 - Move /var/log/lastlog ownership to systemd * Tue Mar 08 2022 Karel Zak 2.32.1-35 - fix #2058176 - losetup Retry LOOP_SET_STATUS64 on EAGAIN diff --git a/uuidd-tmpfiles.conf b/uuidd-tmpfiles.conf new file mode 100644 index 0000000..4158c7d --- /dev/null +++ b/uuidd-tmpfiles.conf @@ -0,0 +1 @@ +d /run/uuidd 2775 uuidd uuidd -- Gitee From 75128526d08fe208a63bfe0210671a4be1695372 Mon Sep 17 00:00:00 2001 From: songmingliang Date: Tue, 17 May 2022 22:36:54 +0800 Subject: [PATCH 2/4] hwclock: better compatibility for both glibc2.28 and glibc2.32 --- 1001-hwclock-make-glibc-2.31-compatible.patch | 161 ++++++++++++++++++ util-linux.spec | 10 +- 2 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 1001-hwclock-make-glibc-2.31-compatible.patch diff --git a/1001-hwclock-make-glibc-2.31-compatible.patch b/1001-hwclock-make-glibc-2.31-compatible.patch new file mode 100644 index 0000000..d4908a6 --- /dev/null +++ b/1001-hwclock-make-glibc-2.31-compatible.patch @@ -0,0 +1,161 @@ +From e42f9f05a96c9e0129722b15fc638d4133ac1ecb Mon Sep 17 00:00:00 2001 +From: J William Piggott +Date: Tue, 19 Apr 2022 23:22:11 -0400 +Subject: [PATCH] hwclock: make glibc 2.31 compatible +______________________________________________________ +GNU C Library NEWS -- history of user-visible changes. +Version 2.31 +Deprecated and removed features, and other changes affecting compatibility: + +* The settimeofday function can still be used to set a system-wide time + zone when the operating system supports it. This is because the Linux + kernel reused the API, on some architectures, to describe a system-wide + time-zone-like offset between the software clock maintained by the kernel, + and the "RTC" clock that keeps time when the system is shut down. + + However, to reduce the odds of this offset being set by accident, + settimeofday can no longer be used to set the time and the offset + simultaneously. If both of its two arguments are non-null, the call + will fail (setting errno to EINVAL). + + Callers attempting to set this offset should also be prepared for the call + to fail and set errno to ENOSYS; this already happens on the Hurd and on + some Linux architectures. The Linux kernel maintainers are discussing a + more principled replacement for the reused API. After a replacement + becomes available, we will change settimeofday to fail with ENOSYS on all + platforms when its 'tzp' argument is not a null pointer. + + settimeofday itself is obsolescent according to POSIX. Programs that set + the system time should use clock_settime and/or the adjtime family of + functions instead. We may cease to make settimeofday available to newly + linked binaries after there is a replacement for Linux's time-zone-like + offset API. +______________________________________________________ + +hwclock(8) had one settimeofday(2) call where both args were set for +--hctosys when the RTC was ticking UTC. This allowed setting the system +time, timezone, and locking the warp_clock function with a single call. +That operation now takes 3 calls of settimeofday(2). + +Although this common operation now takes three calls, the overall logic +for the set_system_clock() function was simplified. + +Co-Author: Karel Zak +Signed-off-by: J William Piggott +--- + sys-utils/hwclock.c | 70 ++++++++++++++++++++++----------------------- + 1 file changed, 35 insertions(+), 35 deletions(-) + +diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c +index b83e710..19e7410 100644 +--- a/sys-utils/hwclock.c ++++ b/sys-utils/hwclock.c +@@ -583,28 +583,28 @@ display_time(struct timeval hwctime) + * tz.tz_minuteswest argument and sets PCIL (see below). At boot settimeofday(2) + * has one-shot access to this function as shown in the table below. + * +- * +-------------------------------------------------------------------+ +- * | settimeofday(tv, tz) | +- * |-------------------------------------------------------------------| +- * | Arguments | System Time | PCIL | | warp_clock | +- * | tv | tz | set | warped | set | firsttime | locked | +- * |---------|---------|---------------|------|-----------|------------| +- * | pointer | NULL | yes | no | no | 1 | no | +- * | pointer | pointer | yes | no | no | 0 | yes | +- * | NULL | ptr2utc | no | no | no | 0 | yes | +- * | NULL | pointer | no | yes | yes | 0 | yes | +- * +-------------------------------------------------------------------+ ++ * +-------------------------------------------------------------------------+ ++ * | settimeofday(tv, tz) | ++ * |-------------------------------------------------------------------------| ++ * | Arguments | System Time | TZ | PCIL | | warp_clock | ++ * | tv | tz | set | warped | set | set | firsttime | locked | ++ * |---------|---------|---------------|-----|------|-----------|------------| ++ * | pointer | NULL | yes | no | no | no | 1 | no | ++ * | NULL | ptr2utc | no | no | yes | no | 0 | yes | ++ * | NULL | pointer | no | yes | yes | yes | 0 | yes | ++ * +-------------------------------------------------------------------------+ + * ptr2utc: tz.tz_minuteswest is zero (UTC). + * PCIL: persistent_clock_is_local, sets the "11 minute mode" timescale. + * firsttime: locks the warp_clock function (initialized to 1 at boot). ++ * Since glibc v2.31 settimeofday() will fail if both args are non NULL + * + * +---------------------------------------------------------------------------+ + * | op | RTC scale | settimeofday calls | + * |---------|-----------|-----------------------------------------------------| + * | systz | Local | 1) warps system time*, sets PCIL* and kernel tz | + * | systz | UTC | 1st) locks warp_clock* 2nd) sets kernel tz | +- * | hctosys | Local | 1st) sets PCIL* 2nd) sets system time and kernel tz | +- * | hctosys | UTC | 1) sets system time and kernel tz | ++ * | hctosys | Local | 1st) sets PCIL* & kernel tz 2nd) sets system time | ++ * | hctosys | UTC | 1st) locks warp* 2nd) sets tz 3rd) sets system time | + * +---------------------------------------------------------------------------+ + * * only on first call after boot + */ +@@ -615,41 +615,41 @@ set_system_clock(const struct hwclock_control *ctl, + struct tm broken; + int minuteswest; + int rc = 0; +- const struct timezone tz_utc = { 0 }; + + localtime_r(&newtime.tv_sec, &broken); + minuteswest = -get_gmtoff(&broken) / 60; + + if (ctl->verbose) { +- if (ctl->hctosys && !ctl->universal) +- printf(_("Calling settimeofday(NULL, %d) to set " +- "persistent_clock_is_local.\n"), minuteswest); +- if (ctl->systz && ctl->universal) ++ if (ctl->universal) { + puts(_("Calling settimeofday(NULL, 0) " +- "to lock the warp function.")); ++ "to lock the warp_clock function.")); ++ if (!( ctl->universal && !minuteswest )) ++ printf(_("Calling settimeofday(NULL, %d) " ++ "to set the kernel timezone.\n"), ++ minuteswest); ++ } else ++ printf(_("Calling settimeofday(NULL, %d) to warp " ++ "System time, set PCIL and the kernel tz.\n"), ++ minuteswest); ++ + if (ctl->hctosys) +- printf(_("Calling settimeofday(%ld.%06ld, %d)\n"), +- newtime.tv_sec, newtime.tv_usec, minuteswest); +- else { +- printf(_("Calling settimeofday(NULL, %d) "), minuteswest); +- if (ctl->universal) +- puts(_("to set the kernel timezone.")); +- else +- puts(_("to warp System time.")); +- } ++ printf(_("Calling settimeofday(%ld.%06ld, NULL) " ++ "to set the System time.\n"), ++ newtime.tv_sec, newtime.tv_usec); + } + + if (!ctl->testing) { ++ const struct timezone tz_utc = { 0 }; + const struct timezone tz = { minuteswest }; +- +- if (ctl->hctosys && !ctl->universal) /* set PCIL */ +- rc = settimeofday(NULL, &tz); +- if (ctl->systz && ctl->universal) /* lock warp_clock */ ++ /* If UTC RTC: lock warp_clock and PCIL */ ++ if (ctl->universal) + rc = settimeofday(NULL, &tz_utc); +- if (!rc && ctl->hctosys) +- rc = settimeofday(&newtime, &tz); +- else if (!rc) ++ /* Set kernel tz; if localtime RTC: warp_clock and set PCIL */ ++ if (!rc && !( ctl->universal && !minuteswest )) + rc = settimeofday(NULL, &tz); ++ /* Set the System Clock */ ++ if ((!rc || errno == ENOSYS) && ctl->hctosys) ++ rc = settimeofday(&newtime, NULL); + + if (rc) { + warn(_("settimeofday() failed")); +-- +2.27.0 + diff --git a/util-linux.spec b/util-linux.spec index cf4fbde..43cb64c 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,8 +1,9 @@ +%define anolis_release .0.1 ### Header Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 39%{?dist} +Release: 39%{anolis_release}%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -266,6 +267,10 @@ Patch84: 0084-tests-update-atari-partx-tests.patch # 2141969 - Add --cont-clock feature for libuuid and uuidd Patch85: 0085-libuuid-Implement-continuous-clock-handling-for-time.patch Patch86: 0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch +# Begin: Anolis customized patches +# hwclock: make glibc 2.31 compatible +Patch1001: 1001-hwclock-make-glibc-2.31-compatible.patch +# End: Anolis customized patches %description The util-linux package contains a large variety of low-level system @@ -1114,6 +1119,9 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Mon Jan 30 2023 Weitao Zhou 2.32.1-39.0.1 +- [Patch] hwclock: better compatibility for both glibc2.28 and glibc2.31 + * Wed Nov 16 2022 Karel Zak 2.32.1-39 - fix #2141969 - Add --cont-clock feature for libuuid and uuidd -- Gitee From 891497af202aa8a4a8ba8dcd46566d48dc0d38b0 Mon Sep 17 00:00:00 2001 From: forrest_ly Date: Tue, 27 Sep 2022 11:41:34 +0800 Subject: [PATCH 3/4] add Neoverse-N2 to ARM identifiers tables that lscpu can identify armv9 cpu --- ...eoverse-N2-to-ARM-identifiers-tables.patch | 24 +++++++++++++++++++ util-linux.spec | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch diff --git a/1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch b/1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch new file mode 100644 index 0000000..9b6afb1 --- /dev/null +++ b/1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch @@ -0,0 +1,24 @@ +From dc11290085e49ec47be148447104f50ce3e7244b Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Tue, 27 Sep 2022 11:21:16 +0800 +Subject: [PATCH] add Neoverse-N2 to ARM identifiers tables + +--- + sys-utils/lscpu-arm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sys-utils/lscpu-arm.c b/sys-utils/lscpu-arm.c +index 2b178a7..697a4b2 100644 +--- a/sys-utils/lscpu-arm.c ++++ b/sys-utils/lscpu-arm.c +@@ -80,6 +80,7 @@ static const struct id_part arm_part[] = { + { 0xd21, "Cortex-M33" }, + { 0xd41, "Cortex-A78" }, + { 0xd42, "Cortex-A78AE" }, ++ { 0xd49, "Neoverse-N2" }, + { 0xd4a, "Neoverse-E1" }, + { 0xd4b, "Cortex-A78C" }, + { -1, "unknown" }, +-- +2.31.1 + diff --git a/util-linux.spec b/util-linux.spec index 43cb64c..a92075a 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -270,6 +270,7 @@ Patch86: 0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch # Begin: Anolis customized patches # hwclock: make glibc 2.31 compatible Patch1001: 1001-hwclock-make-glibc-2.31-compatible.patch +patch1002: 1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch # End: Anolis customized patches %description @@ -1121,6 +1122,7 @@ fi %changelog * Mon Jan 30 2023 Weitao Zhou 2.32.1-39.0.1 - [Patch] hwclock: better compatibility for both glibc2.28 and glibc2.31 +- [Patch] lscpu: add Neoverse-N2 to ARM identifiers tables (flin@linux.alibaba.com) * Wed Nov 16 2022 Karel Zak 2.32.1-39 - fix #2141969 - Add --cont-clock feature for libuuid and uuidd -- Gitee From 8b21d25f0c435845eeabda6b141e58688c7ee3cc Mon Sep 17 00:00:00 2001 From: forrest_ly Date: Tue, 27 Sep 2022 15:36:50 +0800 Subject: [PATCH 4/4] 1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch --- ...-cpu-frequency-from-cpuinfo-on-arm64.patch | 24 +++++++++++++++++++ util-linux.spec | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch diff --git a/1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch b/1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch new file mode 100644 index 0000000..1893c87 --- /dev/null +++ b/1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch @@ -0,0 +1,24 @@ +From 117b51eb538673be49bf0e619d2307a65963d1dd Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Tue, 27 Sep 2022 15:31:51 +0800 +Subject: [PATCH] fix lscpu to get cpu frequency from cpuinfo on arm64 + +--- + sys-utils/lscpu.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c +index 70a797d..a7014a0 100644 +--- a/sys-utils/lscpu.c ++++ b/sys-utils/lscpu.c +@@ -433,6 +433,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) + else if (lookup(buf, "stepping", &desc->stepping)) ; + else if (lookup(buf, "CPU variant", &desc->stepping)) ; /* aarch64 */ + else if (lookup(buf, "cpu MHz", &desc->mhz)) ; ++ else if (lookup(buf, "CPU MHz", &desc->mhz)) ; /* aarch64 */ + else if (lookup(buf, "cpu MHz dynamic", &desc->dynamic_mhz)) ; /* s390 */ + else if (lookup(buf, "cpu MHz static", &desc->static_mhz)) ; /* s390 */ + else if (lookup(buf, "flags", &desc->flags)) ; /* x86 */ +-- +2.31.1 + diff --git a/util-linux.spec b/util-linux.spec index a92075a..4d8be66 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -270,7 +270,8 @@ Patch86: 0086-libuuid-check-clock-value-from-LIBUUID_CLOCK_FILE.patch # Begin: Anolis customized patches # hwclock: make glibc 2.31 compatible Patch1001: 1001-hwclock-make-glibc-2.31-compatible.patch -patch1002: 1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch +Patch1002: 1002-add-Neoverse-N2-to-ARM-identifiers-tables.patch +Patch1003: 1003-fix-lscpu-to-get-cpu-frequency-from-cpuinfo-on-arm64.patch # End: Anolis customized patches %description @@ -1123,6 +1124,7 @@ fi * Mon Jan 30 2023 Weitao Zhou 2.32.1-39.0.1 - [Patch] hwclock: better compatibility for both glibc2.28 and glibc2.31 - [Patch] lscpu: add Neoverse-N2 to ARM identifiers tables (flin@linux.alibaba.com) +- [Patch] lscpu: fix lscpu to get cpu frequency from cpuinfo on arm64 (flin@linux.alibaba.com) * Wed Nov 16 2022 Karel Zak 2.32.1-39 - fix #2141969 - Add --cont-clock feature for libuuid and uuidd -- Gitee