diff --git a/backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch b/backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch new file mode 100644 index 0000000000000000000000000000000000000000..b7af88ce39f69d29c0e45a2adb8fbf1f20e7940d --- /dev/null +++ b/backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch @@ -0,0 +1,39 @@ +From d7fa8ed63891b0058c5df8aa809e34de61008f51 Mon Sep 17 00:00:00 2001 +From: Milan Broz +Date: Sun, 9 Oct 2022 20:20:45 +0200 +Subject: [PATCH] libblkid: avoid buffer overflow in ocfs superblock parsing + +Label and mount values are checked only according to on-disk +values and not checked against the real structure size. +This can lead to reading of memory outside of superblock +struct and subsequent crash. + +Reproducer found with OSS-Fuzz (issue 52270) running over +cryptsetup project (blkid is used in header init). + +Signed-off-by: Milan Broz +--- + libblkid/src/superblocks/ocfs.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/libblkid/src/superblocks/ocfs.c b/libblkid/src/superblocks/ocfs.c +index 28df6ddfa4..e213d66b44 100644 +--- a/libblkid/src/superblocks/ocfs.c ++++ b/libblkid/src/superblocks/ocfs.c +@@ -129,10 +129,12 @@ static int probe_ocfs(blkid_probe pr, const struct blkid_idmag *mag) + blkid_probe_set_value(pr, "SEC_TYPE", + (unsigned char *) "ntocfs", sizeof("ntocfs")); + +- blkid_probe_set_label(pr, (unsigned char *) ovl.label, +- ocfslabellen(ovl)); +- blkid_probe_set_value(pr, "MOUNT", (unsigned char *) ovh.mount, +- ocfsmountlen(ovh)); ++ if (ocfslabellen(ovl) < sizeof(ovl.label)) ++ blkid_probe_set_label(pr, (unsigned char *) ovl.label, ++ ocfslabellen(ovl)); ++ if (ocfsmountlen(ovh) < sizeof(ovh.mount)) ++ blkid_probe_set_value(pr, "MOUNT", (unsigned char *) ovh.mount, ++ ocfsmountlen(ovh)); + blkid_probe_set_uuid(pr, ovl.vol_id); + blkid_probe_sprintf_version(pr, "%u.%u", maj, min); + return 0; diff --git a/backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch b/backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch new file mode 100644 index 0000000000000000000000000000000000000000..e6eb26dd131a630a2273fe9de8e4b5539c9ca3ba --- /dev/null +++ b/backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch @@ -0,0 +1,41 @@ +From 9eb31ca7f7971101846bd3668be5d7807200fa2f Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 19 Sep 2022 14:23:25 +0200 +Subject: [PATCH] lsblk: fix endless loop if device specified more than once + +Fixes: https://github.com/util-linux/util-linux/issues/1814 +Signed-off-by: Karel Zak +--- + misc-utils/lsblk-devtree.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/misc-utils/lsblk-devtree.c b/misc-utils/lsblk-devtree.c +index ce9d3e84f7..6f9dc54b3c 100644 +--- a/misc-utils/lsblk-devtree.c ++++ b/misc-utils/lsblk-devtree.c +@@ -282,8 +282,25 @@ void lsblk_unref_devtree(struct lsblk_devtree *tr) + } + } + ++static int has_root(struct lsblk_devtree *tr, struct lsblk_device *dev) ++{ ++ struct lsblk_iter itr; ++ struct lsblk_device *x = NULL; ++ ++ lsblk_reset_iter(&itr, LSBLK_ITER_FORWARD); ++ ++ while (lsblk_devtree_next_root(tr, &itr, &x) == 0) { ++ if (x == dev) ++ return 1; ++ } ++ return 0; ++} ++ + int lsblk_devtree_add_root(struct lsblk_devtree *tr, struct lsblk_device *dev) + { ++ if (has_root(tr, dev)) ++ return 0; ++ + if (!lsblk_devtree_has_device(tr, dev)) + lsblk_devtree_add_device(tr, dev); + diff --git a/util-linux.spec b/util-linux.spec index e9a5d09456a902fc261bc005d1b997f1410d5ea9..76335c12f1d72633a581854b42cc524717a75586 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -3,7 +3,7 @@ Name: util-linux Version: 2.37.2 -Release: 11 +Release: 12 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 @@ -51,6 +51,8 @@ Patch6029: backport-libblkid-mac-make-sure-block-size-is-large-enough-fuzzi Patch6030: backport-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch Patch6031: backport-libblkid-hfs-fix-label-use-fuzzing.patch Patch6032: backport-Maybe-there-is-a-little-mistake-in-do_taskset-functi.patch +Patch6033: backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch +Patch6034: backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9001: SKIPPED-no-root-permissions-test.patch @@ -422,6 +424,14 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Mon Nov 14 2022 zhangyao - 2.37.2-12 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Sync community patches + [add]backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch + backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch + * Tue Nov 8 2022 zhangyao - 2.37.2-11 - Type:bugfix - ID:NA