diff --git a/backport-lsblk-fix-memory-leak.patch b/backport-lsblk-fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..99e3e7062a085cda5f43a45dc264766a5ee6f51a --- /dev/null +++ b/backport-lsblk-fix-memory-leak.patch @@ -0,0 +1,25 @@ +From b13f60104b646b45dc9bf43408e6fdec03382ad9 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 19 Sep 2025 10:57:17 +0800 +Subject: [PATCH] lsblk: fix memory leak [coverity scan] + +Signed-off-by: Karel Zak +--- + misc-utils/lsblk.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c +index 80941e0..eac581c 100644 +--- a/misc-utils/lsblk.c ++++ b/misc-utils/lsblk.c +@@ -434,6 +434,7 @@ static char *get_type(struct lsblk_device *dev) + + ul_path_read_string(dev->sysfs, &md_level, "md/level"); + res = (md_level && *md_level) ? md_level : xstrdup("md"); ++ free(md_level); + + } else { + const char *type = NULL; +-- +2.43.0 + diff --git a/backport-lsblk-fix-possible-use-after-free.patch b/backport-lsblk-fix-possible-use-after-free.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3aed2ad4e4aff80275a61f02a6cfcfe30c8288d --- /dev/null +++ b/backport-lsblk-fix-possible-use-after-free.patch @@ -0,0 +1,33 @@ +From 02955d9434396df4019132351d8264b74811dc3f Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 19 Sep 2025 10:58:54 +0800 +Subject: [PATCH] lsblk: fix possible use-after-free + +Signed-off-by: Karel Zak +--- + misc-utils/lsblk.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c +index eac581c..ae8fc6d 100644 +--- a/misc-utils/lsblk.c ++++ b/misc-utils/lsblk.c +@@ -433,9 +433,12 @@ static char *get_type(struct lsblk_device *dev) + char *md_level = NULL; + + ul_path_read_string(dev->sysfs, &md_level, "md/level"); +- res = (md_level && *md_level) ? md_level : xstrdup("md"); +- free(md_level); +- ++ if (md_level && *md_level) ++ res = md_level; ++ else { ++ free(md_level); /* may be unused empty string */ ++ res = xstrdup("md"); ++ } + } else { + const char *type = NULL; + int x = 0; +-- +2.43.0 + diff --git a/util-linux.spec b/util-linux.spec index 7cc87d86a7c311af9082119ea329ff99467e02b1..a4b1890c7f257f54d40edaf9f0332579ef04358a 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -3,7 +3,7 @@ Name: util-linux Version: 2.37.2 -Release: 45 +Release: 46 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 @@ -173,6 +173,8 @@ Patch6161: backport-cfdisk-fix-memory-leak-and-possible-NULL-dereference.pa Patch6162: backport-swapoff-clean-up-tag-resolution.patch Patch6163: backport-libblkid-befs-fix-underflow.patch Patch6164: backport-lsblk-use-md-as-fallback-TYPE-when-md-level-empty.patch +Patch6165: backport-lsblk-fix-memory-leak.patch +Patch6166: backport-lsblk-fix-possible-use-after-free.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9001: SKIPPED-no-root-permissions-test.patch @@ -552,6 +554,13 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Fri Sep 19 2025 cenhuilin - 2.37.2-46 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:lsblk: fix memory leak [coverity scan] + lsblk: fix possible use-after-free + * Tue Sep 02 2025 cenhuilin - 2.37.2-45 - Type:bugfix - CVE:NA