From 266199f103a39ea53856fbd6001254524dd9e69c Mon Sep 17 00:00:00 2001 From: eabdullin Date: Wed, 27 Mar 2024 20:38:12 +0000 Subject: [PATCH] import CS util-linux-2.32.1-46.el8 --- ...scpu-avoid-EBUSY-on-cpuinfo_max_freq.patch | 108 ++++++++++++++++++ ...ize-socket-credentials-control-union.patch | 29 +++++ ...1-libblkid-hfs-fix-label-use-fuzzing.patch | 32 ++++++ ...d-bsd-fix-buffer-pointer-use-fuzzing.patch | 29 +++++ ...ix-size-and-offset-overflows-fuzzing.patch | 56 +++++++++ ...ch-today-day-and-this-year-correctly.patch | 89 +++++++++++++++ SPECS/util-linux.spec | 28 ++++- 7 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch create mode 100644 SOURCES/0100-logger-initialize-socket-credentials-control-union.patch create mode 100644 SOURCES/0101-libblkid-hfs-fix-label-use-fuzzing.patch create mode 100644 SOURCES/0102-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch create mode 100644 SOURCES/0103-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch create mode 100644 SOURCES/0104-timeutils-match-today-day-and-this-year-correctly.patch diff --git a/SOURCES/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch b/SOURCES/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch new file mode 100644 index 0000000..6827125 --- /dev/null +++ b/SOURCES/0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch @@ -0,0 +1,108 @@ +From e561e4740d8dd5419e5fb23ab186ae43fd572736 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 10 Jan 2024 12:08:17 +0100 +Subject: lscpu: avoid EBUSY on cpuinfo_max_freq + +Addresses: https://issues.redhat.com/browse/RHEL-13741 +--- + include/path.h | 4 ++++ + lib/path.c | 20 ++++++++++++++++++++ + sys-utils/lscpu.c | 18 ++++++++++++------ + 3 files changed, 36 insertions(+), 6 deletions(-) + +diff --git a/include/path.h b/include/path.h +index 4be01095c..965bdd047 100644 +--- a/include/path.h ++++ b/include/path.h +@@ -19,8 +19,12 @@ extern void path_read_str(char *result, size_t len, const char *path, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + extern int path_write_str(const char *str, const char *path, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); ++ ++extern int __path_read_s32(int *result, const char *path, ...) ++ __attribute__ ((__format__ (__printf__, 2, 3))); + extern int path_read_s32(const char *path, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); ++ + extern uint64_t path_read_u64(const char *path, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); + +diff --git a/lib/path.c b/lib/path.c +index e8cfa557a..7217c9089 100644 +--- a/lib/path.c ++++ b/lib/path.c +@@ -145,6 +145,26 @@ path_read_str(char *result, size_t len, const char *path, ...) + result[len - 1] = '\0'; + } + ++/* like path_read_s32() but do not print any error message */ ++int __path_read_s32(int *result, const char *path, ...) ++{ ++ FILE *f; ++ va_list ap; ++ int rc; ++ ++ va_start(ap, path); ++ f = path_vfopen("r" UL_CLOEXECSTR, 0, path, ap); ++ va_end(ap); ++ ++ if (!f) ++ return -1; ++ ++ rc = fscanf(f, "%d", result); ++ fclose(f); ++ ++ return rc == 1 ? 0 : -1; ++} ++ + int + path_read_s32(const char *path, ...) + { +diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c +index 01f8fba35..ed5543901 100644 +--- a/sys-utils/lscpu.c ++++ b/sys-utils/lscpu.c +@@ -1176,28 +1176,34 @@ static void + read_max_mhz(struct lscpu_desc *desc, int idx) + { + int num = real_cpu_num(desc, idx); ++ int mhz = 0; + + if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_max_freq", num)) + return; ++ if (__path_read_s32(&mhz, _PATH_SYS_CPU ++ "/cpu%d/cpufreq/cpuinfo_max_freq", num) != 0) ++ return; ++ + if (!desc->maxmhz) + desc->maxmhz = xcalloc(desc->ncpuspos, sizeof(char *)); +- xasprintf(&(desc->maxmhz[idx]), "%.4f", +- (float)path_read_s32(_PATH_SYS_CPU +- "/cpu%d/cpufreq/cpuinfo_max_freq", num) / 1000); ++ xasprintf(&(desc->maxmhz[idx]), "%.4f", (float) mhz / 1000); + } + + static void + read_min_mhz(struct lscpu_desc *desc, int idx) + { + int num = real_cpu_num(desc, idx); ++ int mhz = 0; + + if (!path_exist(_PATH_SYS_CPU "/cpu%d/cpufreq/cpuinfo_min_freq", num)) + return; ++ if (__path_read_s32(&mhz, _PATH_SYS_CPU ++ "/cpu%d/cpufreq/cpuinfo_min_freq", num) != 0) ++ return; ++ + if (!desc->minmhz) + desc->minmhz = xcalloc(desc->ncpuspos, sizeof(char *)); +- xasprintf(&(desc->minmhz[idx]), "%.4f", +- (float)path_read_s32(_PATH_SYS_CPU +- "/cpu%d/cpufreq/cpuinfo_min_freq", num) / 1000); ++ xasprintf(&(desc->minmhz[idx]), "%.4f", (float) mhz / 1000); + } + + static int +-- +2.43.0 + diff --git a/SOURCES/0100-logger-initialize-socket-credentials-control-union.patch b/SOURCES/0100-logger-initialize-socket-credentials-control-union.patch new file mode 100644 index 0000000..21adfd2 --- /dev/null +++ b/SOURCES/0100-logger-initialize-socket-credentials-control-union.patch @@ -0,0 +1,29 @@ +From ca39305530067a55fb151167ba2a085a167c780e Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 26 Jun 2023 11:56:23 +0200 +Subject: logger: initialize socket credentials control union + +Addresses: https://issues.redhat.com/browse/RHEL-18451 +Upstream: http://github.com/util-linux/util-linux/commit/3a4d70419c97f64f60c0eda4720e64d17b3b071 +Addresses: https://github.com/util-linux/util-linux/issues/2336 +Signed-off-by: Karel Zak +--- + misc-utils/logger.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc-utils/logger.c b/misc-utils/logger.c +index c20ef05f1..3f7b05a44 100644 +--- a/misc-utils/logger.c ++++ b/misc-utils/logger.c +@@ -457,7 +457,7 @@ static void write_output(struct logger_ctl *ctl, const char *const msg) + union { + struct cmsghdr cmh; + char control[CMSG_SPACE(sizeof(struct ucred))]; +- } cbuf; ++ } cbuf = { .control = { 0 } }; + #endif + + /* 4) add extra \n to make sure message is terminated */ +-- +2.43.0 + diff --git a/SOURCES/0101-libblkid-hfs-fix-label-use-fuzzing.patch b/SOURCES/0101-libblkid-hfs-fix-label-use-fuzzing.patch new file mode 100644 index 0000000..e735932 --- /dev/null +++ b/SOURCES/0101-libblkid-hfs-fix-label-use-fuzzing.patch @@ -0,0 +1,32 @@ +From f16b5e8bb95471a27b52e46f2357168dabba67d5 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Jun 2022 16:02:54 +0200 +Subject: libblkid: (hfs) fix label use [fuzzing] + +Addresses: https://issues.redhat.com/browse/RHEL-16070 +Upstream: http://github.com/util-linux/util-linux/commit/74e48269ee9a15e230e25d0e3d2e50f5b0ba2b04 +Reported-by: Thibault Guittet +Signed-off-by: Karel Zak +--- + libblkid/src/superblocks/hfs.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libblkid/src/superblocks/hfs.c b/libblkid/src/superblocks/hfs.c +index 185c42c92..4552c1e6a 100644 +--- a/libblkid/src/superblocks/hfs.c ++++ b/libblkid/src/superblocks/hfs.c +@@ -173,7 +173,10 @@ static int probe_hfs(blkid_probe pr, const struct blkid_idmag *mag) + + hfs_set_uuid(pr, hfs->finder_info.id, sizeof(hfs->finder_info.id)); + +- blkid_probe_set_label(pr, hfs->label, hfs->label_len); ++ size = hfs->label_len; ++ if ((size_t) size > sizeof(hfs->label)) ++ size = sizeof(hfs->label); ++ blkid_probe_set_label(pr, hfs->label, size); + return 0; + } + +-- +2.43.0 + diff --git a/SOURCES/0102-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch b/SOURCES/0102-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch new file mode 100644 index 0000000..5c00834 --- /dev/null +++ b/SOURCES/0102-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch @@ -0,0 +1,29 @@ +From ba63ed8d306b5d1fa5ced1b13fa59d575e345ebf Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Jun 2022 16:02:54 +0200 +Subject: libblkid: (bsd) fix buffer pointer use [fuzzing] + +Addresses: https://issues.redhat.com/browse/RHEL-16070 +Upstream: http://github.com/util-linux/util-linux/commit/0a0630133055c3b3daa3072a3fd9944a1a149401 +Reported-by: Thibault Guittet +Signed-off-by: Karel Zak +--- + libblkid/src/partitions/bsd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libblkid/src/partitions/bsd.c b/libblkid/src/partitions/bsd.c +index c74517334..7a0b23195 100644 +--- a/libblkid/src/partitions/bsd.c ++++ b/libblkid/src/partitions/bsd.c +@@ -50,7 +50,7 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag) + goto nothing; + } + +- l = (struct bsd_disklabel *) data + BLKID_MAG_LASTOFFSET(mag); ++ l = (struct bsd_disklabel *) (data + BLKID_MAG_LASTOFFSET(mag)); + + ls = blkid_probe_get_partlist(pr); + if (!ls) +-- +2.43.0 + diff --git a/SOURCES/0103-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch b/SOURCES/0103-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch new file mode 100644 index 0000000..f61c6b4 --- /dev/null +++ b/SOURCES/0103-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch @@ -0,0 +1,56 @@ +From fb4a413e67e0d4f24ad23ece37f206d198601741 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Jun 2022 16:02:54 +0200 +Subject: libblkid: (probe) fix size and offset overflows [fuzzing] + +Addresses: https://issues.redhat.com/browse/RHEL-16070 +Upstream: http://github.com/util-linux/util-linux/commit/106de261469e1001243d5b81ed895762fb34b2ba +Reported-by: Thibault Guittet +Signed-off-by: Karel Zak +--- + libblkid/src/probe.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c +index 49a62c47f..d36dce4c9 100644 +--- a/libblkid/src/probe.c ++++ b/libblkid/src/probe.c +@@ -613,6 +613,11 @@ static int hide_buffer(blkid_probe pr, uint64_t off, uint64_t len) + struct list_head *p; + int ct = 0; + ++ if (UINT64_MAX - len < off) { ++ DBG(BUFFER, ul_debug("\t hide-buffer overflow (ignore)")); ++ return -EINVAL; ++ } ++ + list_for_each(p, &pr->buffers) { + struct blkid_bufinfo *x = + list_entry(p, struct blkid_bufinfo, bufs); +@@ -648,14 +653,20 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len + DBG(BUFFER, ul_debug("\t>>>> off=%ju, real-off=%ju (probe <%ju..%ju>, len=%ju", + off, real_off, pr->off, pr->off + pr->size, len)); + */ +- + if (pr->size == 0) { + errno = EINVAL; + return NULL; + } + +- if (len == 0 || (!S_ISCHR(pr->mode) && pr->off + pr->size < real_off + len)) { +- DBG(BUFFER, ul_debug("\t ignore: request out of probing area")); ++ if (UINT64_MAX - len < off || UINT64_MAX - len < real_off) { ++ DBG(BUFFER, ul_debug("\t read-buffer overflow (ignore)")); ++ return NULL; ++ } ++ ++ if (len == 0 ++ || (!S_ISCHR(pr->mode) && (pr->size < off || pr->size < len)) ++ || (!S_ISCHR(pr->mode) && (pr->off + pr->size < real_off + len))) { ++ DBG(BUFFER, ul_debug("\t read-buffer out of probing area (ignore)")); + errno = 0; + return NULL; + } +-- +2.43.0 + diff --git a/SOURCES/0104-timeutils-match-today-day-and-this-year-correctly.patch b/SOURCES/0104-timeutils-match-today-day-and-this-year-correctly.patch new file mode 100644 index 0000000..d087979 --- /dev/null +++ b/SOURCES/0104-timeutils-match-today-day-and-this-year-correctly.patch @@ -0,0 +1,89 @@ +From db254673510a49c1ad2ac154f72687bc5ff3ece3 Mon Sep 17 00:00:00 2001 +From: Sami Kerola +Date: Sat, 5 Jan 2019 21:32:23 +0000 +Subject: timeutils: match today day and this year correctly + +Assumption all years since 1970 have been exactly 365 days long has it's +problems when leap years happen. Lets use struct tm fields that are +provided by localtime_r(), making year and day to be correctly compared even +when it's late new years eve somewhere else than UTC-0. + +Addresses: https://issues.redhat.com/browse/RHEL-6274 +Upstream: http://github.com/util-linux/util-linux/commit/d393c00c6cd57ef7f122f4e1730b3c410b6084cb +Signed-off-by: Sami Kerola +--- + include/timeutils.h | 3 --- + lib/timeutils.c | 27 +++++++++++++++------------ + 2 files changed, 15 insertions(+), 15 deletions(-) + +diff --git a/include/timeutils.h b/include/timeutils.h +index f1540a183..eec840085 100644 +--- a/include/timeutils.h ++++ b/include/timeutils.h +@@ -83,9 +83,6 @@ int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz); + + #define UL_SHORTTIME_THISYEAR_HHMM (1 << 1) + +-int time_is_today(const time_t *t, struct timeval *now); +-int time_is_thisyear(const time_t *t, struct timeval *now); +- + int strtime_short(const time_t *t, struct timeval *now, int flags, char *buf, size_t bufsz); + + #ifndef HAVE_TIMEGM +diff --git a/lib/timeutils.c b/lib/timeutils.c +index 9c286aebc..d403ced90 100644 +--- a/lib/timeutils.c ++++ b/lib/timeutils.c +@@ -503,34 +503,37 @@ int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz) + } + + /* relative time functions */ +-int time_is_today(const time_t *t, struct timeval *now) ++static inline int time_is_thisyear(struct tm const *const tm, ++ struct tm const *const tmnow) + { +- if (now->tv_sec == 0) +- gettimeofday(now, NULL); +- return *t / (3600 * 24) == now->tv_sec / (3600 * 24); ++ return tm->tm_year == tmnow->tm_year; + } + +-int time_is_thisyear(const time_t *t, struct timeval *now) ++static inline int time_is_today(struct tm const *const tm, ++ struct tm const *const tmnow) + { +- if (now->tv_sec == 0) +- gettimeofday(now, NULL); +- return *t / (3600 * 24 * 365) == now->tv_sec / (3600 * 24 * 365); ++ return (tm->tm_yday == tmnow->tm_yday && ++ time_is_thisyear(tm, tmnow)); + } + + int strtime_short(const time_t *t, struct timeval *now, int flags, char *buf, size_t bufsz) + { +- struct tm tm; ++ struct tm tm, tmnow; + int rc = 0; + +- localtime_r(t, &tm); ++ if (now->tv_sec == 0) ++ gettimeofday(now, NULL); ++ ++ localtime_r(t, &tm); ++ localtime_r(&now->tv_sec, &tmnow); + +- if (time_is_today(t, now)) { ++ if (time_is_today(&tm, &tmnow)) { + rc = snprintf(buf, bufsz, "%02d:%02d", tm.tm_hour, tm.tm_min); + if (rc < 0 || (size_t) rc > bufsz) + return -1; + rc = 1; + +- } else if (time_is_thisyear(t, now)) { ++ } else if (time_is_thisyear(&tm, &tmnow)) { + if (flags & UL_SHORTTIME_THISYEAR_HHMM) + rc = strftime(buf, bufsz, "%b%d/%H:%M", &tm); + else +-- +2.43.0 + diff --git a/SPECS/util-linux.spec b/SPECS/util-linux.spec index 27e7627..4c5164b 100644 --- a/SPECS/util-linux.spec +++ b/SPECS/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 43%{?dist} +Release: 46%{?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 @@ -292,6 +292,20 @@ Patch97: 0097-swapon-man-fix-priority-description.patch # 2227097 - wall(1) fails when trying to use seat0 Patch98: 0098-wall-do-not-error-for-ttys-that-do-not-exist.patch +### RHEL-8.10 +### +# RHEL-13741 - lscpu: avoid EBUSY on cpuinfo_max_freq +Patch99: 0099-lscpu-avoid-EBUSY-on-cpuinfo_max_freq.patch +# RHEL-18451 - logger: initialize socket credentials control union +Patch100: 0100-logger-initialize-socket-credentials-control-union.patch +# RHEL-16070 - util-linux: issues in libblkid +Patch101: 0101-libblkid-hfs-fix-label-use-fuzzing.patch +Patch102: 0102-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch +Patch103: 0103-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch +# RHEL-6274 - lslogins incorrect account expiration field +Patch104: 0104-timeutils-match-today-day-and-this-year-correctly.patch + + %description The util-linux package contains a large variety of low-level system @@ -1140,6 +1154,18 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Thu Feb 08 2024 Karel Zak 2.32.1-46 +- fix RHEL-13741 - lscpu: avoid EBUSY on cpuinfo_max_freq +- fix RHEL-18451 - logger: initialize socket credentials control union +- fix RHEL-16070 - util-linux: issues in libblkid +- fix RHEL-6274 - lslogins incorrect account expiration field + +* Tue Jan 30 2024 Karel Zak 2.32.1-45 +- increment release number + +* Wed Jan 10 2024 Karel Zak 2.32.1-44 +- fix RHEL-13741 - lscpu: avoid EBUSY on cpuinfo_max_freq + * Thu Aug 10 2023 Karel Zak 2.32.1-43 - fix #2117355 - Add additional documentation for fstab - fix #2184728 - libuuid - downport cache related patch