From 27ae2c64255f9527e4b7778ffcda430453f7dc44 Mon Sep 17 00:00:00 2001 From: roy Date: Fri, 20 Sep 2024 15:15:35 +0800 Subject: [PATCH] libfdisk: fix fdisk_reread_changes() for extended partitions. --- ...read_changes-for-extended-partitions.patch | 40 ++++++++++++++++++ util-linux.spec | 11 ++++- write-fix-potential-string-overflow.patch | 41 ------------------- 3 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 backport-libfdisk-fix-fdisk_reread_changes-for-extended-partitions.patch delete mode 100644 write-fix-potential-string-overflow.patch diff --git a/backport-libfdisk-fix-fdisk_reread_changes-for-extended-partitions.patch b/backport-libfdisk-fix-fdisk_reread_changes-for-extended-partitions.patch new file mode 100644 index 0000000..8ce8a63 --- /dev/null +++ b/backport-libfdisk-fix-fdisk_reread_changes-for-extended-partitions.patch @@ -0,0 +1,40 @@ +commit b0098c1ebd3bd068edaa38be67ac48b6c1218e98 +Author: Karel Zak +Date: Thu Aug 6 11:32:33 2020 +0200 + + libfdisk: fix fdisk_reread_changes() for extended partitions + + Linux kernel assumes only 1KiB extended partition to avoid overlapping + with nested logical partitions. We need to follow this rule for + BLKPG_ADD_PARTITION. + + Addresses: https://github.com/karelzak/util-linux/issues/1112 + Signed-off-by: Karel Zak + +diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c +index 363db30f4..327e03b42 100644 +--- a/libfdisk/src/context.c ++++ b/libfdisk/src/context.c +@@ -939,10 +939,21 @@ int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org) + } + } + for (i = 0; i < nadds; i++) { ++ uint64_t sz; ++ + pa = add[i]; ++ sz = pa->size * ssf; ++ + DBG(PART, ul_debugobj(pa, "#%zu calling BLKPG_ADD_PARTITION", pa->partno)); ++ ++ if (fdisk_is_label(cxt, DOS) && fdisk_partition_is_container(pa)) ++ /* Let's follow the Linux kernel and reduce ++ * DOS extended partition to 1 or 2 sectors. ++ */ ++ sz = min(sz, (uint64_t) 2); ++ + if (partx_add_partition(cxt->dev_fd, pa->partno + 1, +- pa->start * ssf, pa->size * ssf) != 0) { ++ pa->start * ssf, sz) != 0) { + fdisk_warn(cxt, _("Failed to add partition %zu to system"), pa->partno + 1); + err++; + } diff --git a/util-linux.spec b/util-linux.spec index 87278a3..611f0f9 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -2,7 +2,7 @@ Name: util-linux Version: 2.35.2 -Release: 18 +Release: 19 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 @@ -90,12 +90,14 @@ Patch6010: backport-CVE-2024-28085.patch Patch6011: backport-tests-fix-misc-setarch-run-in-a-docker-environment.patch Patch6012: backport-include-c.h-add-helpers-for-unaligned-structure-acce.patch Patch6013: backport-libblkid-drbd-reduce-false-positive.patch +Patch6014: backport-libfdisk-fix-fdisk_reread_changes-for-extended-partitions.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9001: modify-rescuemode-chinese-error.patch Patch9002: huawei-bios-model-name.patch Patch9003: backport-uuidd-fix-open-lock-state-issue.patch + %description The util-linux package contains a random collection of files that implements some low-level basic linux utilities. @@ -441,6 +443,13 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Fri Sep 20 2024 Yu Peng - 2.35.2-19 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:sync community patches + backport-libfdisk-fix-fdisk_reread_changes-for-extended-partitions.patch + * Mon Aug 5 2024 liyuzhe - 2.35.2-18 - Fixed incorrect macro usage in summary fields of devel and help subpackages diff --git a/write-fix-potential-string-overflow.patch b/write-fix-potential-string-overflow.patch deleted file mode 100644 index 1eb1201..0000000 --- a/write-fix-potential-string-overflow.patch +++ /dev/null @@ -1,41 +0,0 @@ -From cdf84bf65804873708b2b76551d64116123ac128 Mon Sep 17 00:00:00 2001 -From: Sami Kerola -Date: Sat, 8 Feb 2020 21:12:14 +0000 -Subject: [PATCH 038/389] write: fix potential string overflow -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Noticed when compiled with gcc verion 9.2.1 20200130. - -term-utils/write.c:182:7: warning: ‘strcmp’ argument 1 declared attribute - ‘nonstring’ [-Wstringop-overflow=] - 182 | if (strcmp(u->ut_line, ctl->src_tty_name) == 0) { - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In file included from /usr/include/utmpx.h:31, - from term-utils/write.c:60: -/usr/include/bits/utmpx.h:59:8: note: argument ‘ut_line’ declared here - 59 | char ut_line[__UT_LINESIZE] - | ^~~~~~~ - -Signed-off-by: Sami Kerola ---- - term-utils/write.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/term-utils/write.c b/term-utils/write.c -index 3436fbd..90eb18c 100644 ---- a/term-utils/write.c -+++ b/term-utils/write.c -@@ -179,7 +179,7 @@ static void search_utmp(struct write_control *ctl) - if (ctl->src_uid && !tty_writeable) - /* skip ttys with msgs off */ - continue; -- if (strcmp(u->ut_line, ctl->src_tty_name) == 0) { -+ if (memcmp(u->ut_line, ctl->src_tty_name, strlen(ctl->src_tty_name) + 1) == 0) { - user_is_me = 1; - /* don't write to yourself */ - continue; --- -1.8.3.1 - -- Gitee