From e735e0b700dc6626248593969bffcb2e51f28585 Mon Sep 17 00:00:00 2001 From: zhangyao Date: Fri, 8 Mar 2024 10:56:41 +0800 Subject: [PATCH] sync patches from upstream (cherry picked from commit da730ad190b4bf19beb1185704314dd98404ff3a) --- ...cpuset-exit-early-from-cpulist_parse.patch | 41 +++++++++++++ ...-libblkid-drbd-reduce-false-positive.patch | 50 ++++++++++++++++ ...bblkid-hfsplus-reduce-false-positive.patch | 57 +++++++++++++++++++ ...LERR-and-POLLHUP-on-stdin-is-receive.patch | 49 ++++++++++++++++ ...oc-cal-Werror-calloc-transposed-args.patch | 31 ++++++++++ util-linux.spec | 18 +++++- 6 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 backport-lib-cpuset-exit-early-from-cpulist_parse.patch create mode 100644 backport-libblkid-drbd-reduce-false-positive.patch create mode 100644 backport-libblkid-hfsplus-reduce-false-positive.patch create mode 100644 backport-more-exit-if-POLLERR-and-POLLHUP-on-stdin-is-receive.patch create mode 100644 backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch diff --git a/backport-lib-cpuset-exit-early-from-cpulist_parse.patch b/backport-lib-cpuset-exit-early-from-cpulist_parse.patch new file mode 100644 index 0000000..c796015 --- /dev/null +++ b/backport-lib-cpuset-exit-early-from-cpulist_parse.patch @@ -0,0 +1,41 @@ +From 566b1d348897a34016653d6de040688a2c0a136c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= +Date: Thu, 1 Feb 2024 20:09:41 +0100 +Subject: [PATCH] lib/cpuset: exit early from cpulist_parse +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If `a` exceeds `max`, any increment of `a` will also `exceed` max. +In this case the CPU_SET_S will never do anything all additional loops +are wasted. + +Fixes #2748 + +Signed-off-by: Thomas Weißschuh +--- + lib/cpuset.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/lib/cpuset.c b/lib/cpuset.c +index 643537f6d..533b8ab30 100644 +--- a/lib/cpuset.c ++++ b/lib/cpuset.c +@@ -326,8 +326,12 @@ int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize, int fail) + if (!(a <= b)) + return 1; + while (a <= b) { +- if (fail && (a >= max)) +- return 2; ++ if (a >= max) { ++ if (fail) ++ return 2; ++ else ++ break; ++ } + CPU_SET_S(a, setsize, set); + a += s; + } +-- +2.33.0 + diff --git a/backport-libblkid-drbd-reduce-false-positive.patch b/backport-libblkid-drbd-reduce-false-positive.patch new file mode 100644 index 0000000..aa70b8e --- /dev/null +++ b/backport-libblkid-drbd-reduce-false-positive.patch @@ -0,0 +1,50 @@ +From 1ab5d84d66f144ef0a9d1ac9502a59a842466504 Mon Sep 17 00:00:00 2001 +From: biubiuzy <294772273@qq.com> +Date: Wed, 17 Jan 2024 11:23:47 +0800 +Subject: [PATCH] libblkid: (drbd) reduce false-positive + +--- + libblkid/src/superblocks/drbd.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/libblkid/src/superblocks/drbd.c b/libblkid/src/superblocks/drbd.c +index 1723229..410e21d 100644 +--- a/libblkid/src/superblocks/drbd.c ++++ b/libblkid/src/superblocks/drbd.c +@@ -18,6 +18,13 @@ + + #include "superblocks.h" + ++/* ++ * drbd/drbd_int.h ++ */ ++#define BM_BLOCK_SHIFT 12 /* 4k per bit */ ++#define BM_BLOCK_SIZE (1<magic) != DRBD_MD_MAGIC_84_UNCLEAN) + return 1; + ++ if (be32_to_cpu(read_unaligned_member(md, bm_bytes_per_bit)) != BM_BLOCK_SIZE) ++ return 1; ++ + if (!is_zero_padded(member_ptr(md, padding_start), + member_ptr(md, padding_end))) + return 1; +@@ -201,6 +211,9 @@ static int probe_drbd_90(blkid_probe pr) + if (be32_to_cpu(md->magic) != DRBD_MD_MAGIC_09) + return 1; + ++ if (be32_to_cpu(read_unaligned_member(md, bm_bytes_per_bit)) != BM_BLOCK_SIZE) ++ return 1; ++ + if (!is_zero_padded(member_ptr(md, padding_start), + member_ptr(md, padding_end))) + return 1; +-- +2.33.0 + diff --git a/backport-libblkid-hfsplus-reduce-false-positive.patch b/backport-libblkid-hfsplus-reduce-false-positive.patch new file mode 100644 index 0000000..95ef51c --- /dev/null +++ b/backport-libblkid-hfsplus-reduce-false-positive.patch @@ -0,0 +1,57 @@ +From fcdf351d740218efc1e1f0fe2b0a692bdf8370d1 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 10 Jan 2024 09:35:35 +0100 +Subject: [PATCH] libblkid: (hfsplus) reduce false positive + +Fixes: https://github.com/util-linux/util-linux/issues/2692 +Signed-off-by: Karel Zak +--- + libblkid/src/superblocks/hfs.c | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git a/libblkid/src/superblocks/hfs.c b/libblkid/src/superblocks/hfs.c +index fceab95..d48de5f 100644 +--- a/libblkid/src/superblocks/hfs.c ++++ b/libblkid/src/superblocks/hfs.c +@@ -217,6 +217,10 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag) + return 1; + + alloc_block_size = be32_to_cpu(sbd->al_blk_size); ++ if (alloc_block_size < HFSPLUS_SECTOR_SIZE || ++ alloc_block_size % HFSPLUS_SECTOR_SIZE) ++ return 1; ++ + alloc_first_block = be16_to_cpu(sbd->al_bl_st); + embed_first_block = be16_to_cpu(sbd->embed_startblock); + off = (alloc_first_block * 512) + +@@ -238,16 +242,22 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag) + (memcmp(hfsplus->signature, "HX", 2) != 0)) + return 1; + +- hfs_set_uuid(pr, hfsplus->finder_info.id, sizeof(hfsplus->finder_info.id)); +- ++ /* Verify blocksize is initialized */ + blocksize = be32_to_cpu(hfsplus->blocksize); +- if (blocksize < HFSPLUS_SECTOR_SIZE) ++ if (blocksize < HFSPLUS_SECTOR_SIZE || !is_power_of_2(blocksize)) + return 1; + +- blkid_probe_set_block_size(pr, blocksize); +- ++ /* Save extends (hfsplus buffer may be later overwritten) */ + memcpy(extents, hfsplus->cat_file.extents, sizeof(extents)); ++ ++ /* Make sure start_block is properly initialized */ + cat_block = be32_to_cpu(extents[0].start_block); ++ if (off + ((uint64_t) cat_block * blocksize) > pr->size) ++ return 1; ++ ++ hfs_set_uuid(pr, hfsplus->finder_info.id, sizeof(hfsplus->finder_info.id)); ++ ++ blkid_probe_set_block_size(pr, blocksize); + + buf = blkid_probe_get_buffer(pr, + off + ((uint64_t) cat_block * blocksize), 0x2000); +-- +2.33.0 + diff --git a/backport-more-exit-if-POLLERR-and-POLLHUP-on-stdin-is-receive.patch b/backport-more-exit-if-POLLERR-and-POLLHUP-on-stdin-is-receive.patch new file mode 100644 index 0000000..945d00a --- /dev/null +++ b/backport-more-exit-if-POLLERR-and-POLLHUP-on-stdin-is-receive.patch @@ -0,0 +1,49 @@ +From 68e14d3d5f4116ad3aca0e392d008645ea90cf70 Mon Sep 17 00:00:00 2001 +From: Goldwyn Rodrigues +Date: Fri, 8 Dec 2023 09:04:39 -0600 +Subject: [PATCH] more: exit if POLLERR and POLLHUP on stdin is received + +more command continues to run in case stdin have closed the file and it +takes 100% of CPU. This is because revents on stdin send +POLLIN | POLLHUP | POLLERR once stdin is closed. more receives it even +though it is not requested in events. This is common Linux behaviour to +never mask out POLLHUP or POLLERR. The loop in more_key_command() runs +infinitely because more_poll() returns 0 and read_command() reads 0 +bytes. + +Check for POLLERR and POLLHUP, and exit more in case of an error. + +Steps to reproduce: +1. Setup /etc/systemd/logind.conf with KillUserProcesses=no +2. Add config "Defaults use_pty" in /etc/sudoers +3. Start an ssh session to the machine +4. # sudo su - +5. # more +6. kill the parent ssh process, say close the tab + +At this time "more" runs with 100% CPU utilization. + +Signed-off-by: Goldwyn Rodrigues +--- + text-utils/more.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/text-utils/more.c b/text-utils/more.c +index d4db3d5eb..a49acbc3e 100644 +--- a/text-utils/more.c ++++ b/text-utils/more.c +@@ -1392,6 +1392,11 @@ static int more_poll(struct more_control *ctl, int timeout) + abort(); + } + } ++ ++ /* Check for POLLERR and POLLHUP in stdin revents */ ++ if ((pfd[1].revents & POLLERR) && (pfd[1].revents & POLLHUP)) ++ more_exit(ctl); ++ + if (pfd[1].revents == 0) + return 1; + return 0; +-- +2.33.0 + diff --git a/backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch b/backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch new file mode 100644 index 0000000..2710595 --- /dev/null +++ b/backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch @@ -0,0 +1,31 @@ +From 07f0f0f5bd1e5e2268257ae1ff6d76a9b6c6ea8b Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 17 Jan 2024 12:37:08 +0100 +Subject: [PATCH] wall: fix calloc cal [-Werror=calloc-transposed-args] + +term-utils/wall.c:143:37: error: xcalloc sizes specified with sizeof in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] + 143 | buf->groups = xcalloc(sizeof(*buf->groups), buf->ngroups); + | ^ +term-utils/wall.c:143:37: note: earlier argument should specify number of elements, later size of each element + +Signed-off-by: Karel Zak +--- + term-utils/wall.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/term-utils/wall.c b/term-utils/wall.c +index a3fe7d29a..f894a32f8 100644 +--- a/term-utils/wall.c ++++ b/term-utils/wall.c +@@ -140,7 +140,7 @@ static struct group_workspace *init_group_workspace(const char *group) + + buf->requested_group = get_group_gid(group); + buf->ngroups = sysconf(_SC_NGROUPS_MAX) + 1; /* room for the primary gid */ +- buf->groups = xcalloc(sizeof(*buf->groups), buf->ngroups); ++ buf->groups = xcalloc(buf->ngroups, sizeof(*buf->groups)); + + return buf; + } +-- +2.33.0 + diff --git a/util-linux.spec b/util-linux.spec index 3204d0a..1c3136a 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -3,7 +3,7 @@ Name: util-linux Version: 2.37.2 -Release: 25 +Release: 26 Summary: A random collection of Linux utilities License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git @@ -135,6 +135,11 @@ Patch6113: backport-include-c.h-add-helpers-for-unaligned-structure-acce.pa Patch6114: backport-libblkid-probe-read-data-in-chunks.patch Patch6115: backport-libblkid-avoid-aligning-out-of-probing-area.patch Patch6116: backport-libblkid-drbd-validate-zero-padding.patch +Patch6117: backport-more-exit-if-POLLERR-and-POLLHUP-on-stdin-is-receive.patch +Patch6118: backport-libblkid-hfsplus-reduce-false-positive.patch +Patch6119: backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch +Patch6120: backport-libblkid-drbd-reduce-false-positive.patch +Patch6121: backport-lib-cpuset-exit-early-from-cpulist_parse.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9001: SKIPPED-no-root-permissions-test.patch @@ -506,6 +511,17 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Fri Mar 8 2024 zhangyao - 2.37.2-26 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:sync community patches + backport-more-exit-if-POLLERR-and-POLLHUP-on-stdin-is-receive.patch + backport-libblkid-hfsplus-reduce-false-positive.patch + backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch + backport-libblkid-drbd-reduce-false-positive.patch + backport-lib-cpuset-exit-early-from-cpulist_parse.patch + * Mon Feb 19 2024 zhangyao - 2.37.2-25 - Type:bugfix - CVE:NA