diff --git a/backport-lib-strutils-fix-parse_size-for-large-numbers.patch b/backport-lib-strutils-fix-parse_size-for-large-numbers.patch new file mode 100644 index 0000000000000000000000000000000000000000..66c71c89f937cc502a510a5ddf58238135c9c9d9 --- /dev/null +++ b/backport-lib-strutils-fix-parse_size-for-large-numbers.patch @@ -0,0 +1,52 @@ +From 191836bec292547393e8dd5e8d5148e8dbfa210b Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 18 May 2020 13:34:55 +0200 +Subject: [PATCH] lib/strutils: fix parse_size() for large numbers + +For example + ./test_strutils --size '1.0000000000000000000000000000018000000000000000010M' + ./test_strutils --size '1.18446744073709551615M' + +ends with infinite loop due to frac_div variable overflow. + +Addresses: https://github.com/karelzak/util-linux/issues/1023 +Signed-off-by: Karel Zak +--- + lib/strutils.c | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/lib/strutils.c b/lib/strutils.c +index 609ef0860..ce8799dd1 100644 +--- a/lib/strutils.c ++++ b/lib/strutils.c +@@ -173,13 +173,23 @@ check_suffix: + + /* maximal divisor for last digit (e.g. for 0.05 is + * frac_div=100, for 0.054 is frac_div=1000, etc.) ++ * ++ * Reduce frac if too large. + */ +- while (frac_div < frac) +- frac_div *= 10; ++ while (frac_div < frac) { ++ if (frac_div <= UINTMAX_MAX/10) ++ frac_div *= 10; ++ else ++ frac /= 10; ++ } + + /* 'frac' is without zeros (5 means 0.5 as well as 0.05) */ +- for (i = 0; i < frac_zeros; i++) +- frac_div *= 10; ++ for (i = 0; i < frac_zeros; i++) { ++ if (frac_div <= UINTMAX_MAX/10) ++ frac_div *= 10; ++ else ++ frac /= 10; ++ } + + /* + * Go backwardly from last digit and add to result what the +-- +2.23.0 + diff --git a/util-linux.spec b/util-linux.spec index 76d2048900fa5f03a4a310a7aadb3694f265f100..a916af536491b2b20ff406c0fcd071a48c544c69 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -2,7 +2,7 @@ Name: util-linux Version: 2.35.2 -Release: 8 +Release: 9 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 @@ -58,6 +58,7 @@ Patch19: backpaort-fix-rounding-in-size_to_human_string.patch Patch20: backpaort-fix-uint64_t-overflow.patch Patch21: backpaort-update-fdisk-outputs-due-to-sizes-rounding-change.patch Patch6000: backport-CVE-2021-37600.patch +Patch6001: backport-lib-strutils-fix-parse_size-for-large-numbers.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch @@ -407,6 +408,12 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Wed Dec 8 2021 yangmingtai - 2.35.2-9 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix parse_size for large numbers + * Tue Aug 10 2021 shixuantong - 2.35.2-8 - Type:CVE - ID:CVE-2021-37600