From 2c28e65ddf4a24ed926ebf19e0e9b901d11dd139 Mon Sep 17 00:00:00 2001 From: Renbo Date: Wed, 7 Jun 2023 11:15:53 +0800 Subject: [PATCH 1/3] update to python2-2.7.18-12.module+el8.8.0+17629+2cfc9d03 Signed-off-by: Renbo --- ...service-via-inefficient-idna-decoder.patch | 98 +++++++++++++++++++ 10000-python2-anolis-rebrand.patch | 63 ------------ python2.spec | 35 ++++--- 3 files changed, 117 insertions(+), 79 deletions(-) create mode 100644 00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch delete mode 100644 10000-python2-anolis-rebrand.patch diff --git a/00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch b/00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch new file mode 100644 index 0000000..0b6a602 --- /dev/null +++ b/00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch @@ -0,0 +1,98 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: "Miss Islington (bot)" + <31488909+miss-islington@users.noreply.github.com> +Date: Mon, 7 Nov 2022 19:22:14 -0800 +Subject: [PATCH] + 00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch + +00394 # +gh-98433: Fix quadratic time idna decoding. + +There was an unnecessary quadratic loop in idna decoding. This restores +the behavior to linear. + +Backported from python3. + +(cherry picked from commit a6f6c3a3d6f2b580f2d87885c9b8a9350ad7bf15) + +Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> +Co-authored-by: Gregory P. Smith +--- + Lib/encodings/idna.py | 32 +++++++++---------- + Lib/test/test_codecs.py | 6 ++++ + ...2-11-04-09-29-36.gh-issue-98433.l76c5G.rst | 6 ++++ + 3 files changed, 27 insertions(+), 17 deletions(-) + create mode 100644 Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst + +diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py +index ea90d67142f..2ce798cf47e 100644 +--- a/Lib/encodings/idna.py ++++ b/Lib/encodings/idna.py +@@ -39,23 +39,21 @@ def nameprep(label): + + # Check bidi + RandAL = map(stringprep.in_table_d1, label) +- for c in RandAL: +- if c: +- # There is a RandAL char in the string. Must perform further +- # tests: +- # 1) The characters in section 5.8 MUST be prohibited. +- # This is table C.8, which was already checked +- # 2) If a string contains any RandALCat character, the string +- # MUST NOT contain any LCat character. +- if filter(stringprep.in_table_d2, label): +- raise UnicodeError("Violation of BIDI requirement 2") +- +- # 3) If a string contains any RandALCat character, a +- # RandALCat character MUST be the first character of the +- # string, and a RandALCat character MUST be the last +- # character of the string. +- if not RandAL[0] or not RandAL[-1]: +- raise UnicodeError("Violation of BIDI requirement 3") ++ if any(RandAL): ++ # There is a RandAL char in the string. Must perform further ++ # tests: ++ # 1) The characters in section 5.8 MUST be prohibited. ++ # This is table C.8, which was already checked ++ # 2) If a string contains any RandALCat character, the string ++ # MUST NOT contain any LCat character. ++ if any(stringprep.in_table_d2(x) for x in label): ++ raise UnicodeError("Violation of BIDI requirement 2") ++ # 3) If a string contains any RandALCat character, a ++ # RandALCat character MUST be the first character of the ++ # string, and a RandALCat character MUST be the last ++ # character of the string. ++ if not RandAL[0] or not RandAL[-1]: ++ raise UnicodeError("Violation of BIDI requirement 3") + + return label + +diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py +index 0ec8bf5a4b4..76428e1794a 100644 +--- a/Lib/test/test_codecs.py ++++ b/Lib/test/test_codecs.py +@@ -1318,6 +1318,12 @@ class IDNACodecTest(unittest.TestCase): + self.assertEqual(u"pyth\xf6n.org".encode("idna"), "xn--pythn-mua.org") + self.assertEqual(u"pyth\xf6n.org.".encode("idna"), "xn--pythn-mua.org.") + ++ def test_builtin_decode_length_limit(self): ++ with self.assertRaisesRegexp(UnicodeError, "too long"): ++ (b"xn--016c"+b"a"*1100).decode("idna") ++ with self.assertRaisesRegexp(UnicodeError, "too long"): ++ (b"xn--016c"+b"a"*70).decode("idna") ++ + def test_stream(self): + import StringIO + r = codecs.getreader("idna")(StringIO.StringIO("abc")) +diff --git a/Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst b/Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst +new file mode 100644 +index 00000000000..5185fac2e29 +--- /dev/null ++++ b/Misc/NEWS.d/next/Security/2022-11-04-09-29-36.gh-issue-98433.l76c5G.rst +@@ -0,0 +1,6 @@ ++The IDNA codec decoder used on DNS hostnames by :mod:`socket` or :mod:`asyncio` ++related name resolution functions no longer involves a quadratic algorithm. ++This prevents a potential CPU denial of service if an out-of-spec excessive ++length hostname involving bidirectional characters were decoded. Some protocols ++such as :mod:`urllib` http ``3xx`` redirects potentially allow for an attacker ++to supply such a name. diff --git a/10000-python2-anolis-rebrand.patch b/10000-python2-anolis-rebrand.patch deleted file mode 100644 index 89a6d0a..0000000 --- a/10000-python2-anolis-rebrand.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 03b5ffe43421cab1ba3b7417483ab343181ca9bd Mon Sep 17 00:00:00 2001 -From: zhangbinchen -Date: Tue, 16 Mar 2021 11:30:43 +0800 -Subject: [PATCH] rebrand : rebrand txt use anolis - -Signed-off-by: zhangbinchen ---- - Doc/library/gettext.rst | 2 +- - Doc/library/platform.rst | 4 ++-- - Lib/platform.py | 2 +- - 3 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/Doc/library/gettext.rst b/Doc/library/gettext.rst -index 4b4883a..e3c20fd 100644 ---- a/Doc/library/gettext.rst -+++ b/Doc/library/gettext.rst -@@ -746,7 +746,7 @@ implementations, and valuable experience to the creation of this module: - - .. rubric:: Footnotes - --.. [#] The default locale directory is system dependent; for example, on RedHat Linux -+.. [#] The default locale directory is system dependent; for example, on Anolis OS - it is :file:`/usr/share/locale`, but on Solaris it is :file:`/usr/lib/locale`. - The :mod:`gettext` module does not try to support these system dependent - defaults; instead its default is :file:`sys.prefix/share/locale`. For this -diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst -index 3d0743b..7e35ac8 100644 ---- a/Doc/library/platform.rst -+++ b/Doc/library/platform.rst -@@ -242,7 +242,7 @@ Unix Platforms - -------------- - - --.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...)) -+.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake','anolis',...)) - - This is an old version of the functionality now provided by - :func:`linux_distribution`. For new code, please use the -@@ -254,7 +254,7 @@ Unix Platforms - - .. deprecated:: 2.6 - --.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1) -+.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake','anolis',...), full_distribution_name=1) - - Tries to determine the name of the Linux OS distribution name. - -diff --git a/Lib/platform.py b/Lib/platform.py -index e04d87f..e89fa52 100755 ---- a/Lib/platform.py -+++ b/Lib/platform.py -@@ -292,7 +292,7 @@ _release_version = re.compile(r'([^0-9]+)' - - _supported_dists = ( - 'SuSE', 'debian', 'fedora', 'redhat', 'centos', -- 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', -+ 'mandrake', 'anolis', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', - 'UnitedLinux', 'turbolinux') - - def _parse_release_file(firstline): --- -2.26.2 - diff --git a/python2.spec b/python2.spec index ed23f93..2bf4548 100644 --- a/python2.spec +++ b/python2.spec @@ -1,4 +1,3 @@ -%define anolis_release .0.1 # ====================================================== # Conditionals and other variables controlling the build # ====================================================== @@ -49,7 +48,7 @@ %global with_systemtap 1 # some arches don't have valgrind so we need to disable its support on them -%ifnarch s390 %{mips} riscv64 loongarch64 +%ifnarch s390 %{mips} riscv64 %global with_valgrind 1 %else %global with_valgrind 0 @@ -97,6 +96,7 @@ # the rest of the build %global regenerate_autotooling_patch 0 + # ================== # Top-level metadata # ================== @@ -104,7 +104,7 @@ Summary: An interpreted, interactive, object-oriented programming language Name: %{python} # Remember to also rebase python2-docs when changing this: Version: 2.7.18 -Release: 11%{anolis_release}%{?dist} +Release: 12%{?dist} License: Python Group: Development/Languages Requires: %{python}-libs%{?_isa} = %{version}-%{release} @@ -807,6 +807,15 @@ Patch378: 00378-support-expat-2-4-5.patch # Backported from python3. Patch382: 00382-cve-2015-20107.patch +# 00394 # +# gh-98433: Fix quadratic time idna decoding. +# +# There was an unnecessary quadratic loop in idna decoding. This restores +# the behavior to linear. +# +# Backported from python3. +Patch394: 00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decoder.patch + # (New patches go here ^^^) # # When adding new patches to "python2" and "python3" in Fedora, EL, etc., @@ -822,10 +831,6 @@ Patch382: 00382-cve-2015-20107.patch Patch5000: 05000-autotool-intermediates.patch -# Add by Anolis -Patch10000: 10000-python2-anolis-rebrand.patch -# End - # ====================================================== # Additional metadata, and subpackages # ====================================================== @@ -1144,6 +1149,7 @@ git apply %{PATCH351} %patch377 -p1 %patch378 -p1 %patch382 -p1 +%patch394 -p1 # This shouldn't be necesarry, but is right now (2.2a3) @@ -1155,9 +1161,6 @@ find -name "*~" |xargs rm -f %patch5000 -p0 -b .autotool-intermediates %endif -# Add by Anolis -%patch10000 -p1 -# End # ====================================================== # Configuring and building the code: @@ -1476,7 +1479,7 @@ install -d %{buildroot}/%{_prefix}/lib/python%{pybasever}/site-packages %global _pyconfig32_h pyconfig-32.h %global _pyconfig64_h pyconfig-64.h -%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} riscv64 loongarch64 +%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} riscv64 %global _pyconfig_h %{_pyconfig64_h} %else %global _pyconfig_h %{_pyconfig32_h} @@ -1545,7 +1548,7 @@ done # Install a tapset for this libpython into tapsetdir, fixing up the path to the # library: mkdir -p %{buildroot}%{tapsetdir} -%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} loongarch64 +%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} %global libpython_stp_optimized libpython%{pybasever}-64.stp %global libpython_stp_debug libpython%{pybasever}-debug-64.stp %else @@ -1639,7 +1642,7 @@ CheckPython() { %ifarch s390 s390x %{power64} %{arm} aarch64 %{mips} EXTRATESTOPTS="$EXTRATESTOPTS -x test_gdb" %endif -%ifarch %{mips64} loongarch64 +%ifarch %{mips64} EXTRATESTOPTS="$EXTRATESTOPTS -x test_ctypes" %endif @@ -2086,9 +2089,9 @@ fi # ====================================================== %changelog -* Tue Jan 31 2023 zhangbinchen - 2.7.18-11.0.1 -- Rebrand for Anolis OS(Binchen Zhang) -- Support loongarch64 platform(Liwei Ge) +* Wed Dec 21 2022 Charalampos Stratakis - 2.7.18-12 +- Security fix for CVE-2022-45061: CPU denial of service via inefficient IDNA decoder +Resolves: rhbz#2144072 * Fri Jun 17 2022 Charalampos Stratakis - 2.7.18-11 - Security fix for CVE-2015-20107 -- Gitee From f63af67193941d165b24daad8d83fe9330907a36 Mon Sep 17 00:00:00 2001 From: Zhao Hang Date: Fri, 17 Dec 2021 06:35:30 +0000 Subject: [PATCH 2/3] rebrand : rebrand for anolis --- 10000-python2-anolis-rebrand.patch | 63 ++++++++++++++++++++++++++++++ python2.spec | 14 ++++++- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 10000-python2-anolis-rebrand.patch diff --git a/10000-python2-anolis-rebrand.patch b/10000-python2-anolis-rebrand.patch new file mode 100644 index 0000000..89a6d0a --- /dev/null +++ b/10000-python2-anolis-rebrand.patch @@ -0,0 +1,63 @@ +From 03b5ffe43421cab1ba3b7417483ab343181ca9bd Mon Sep 17 00:00:00 2001 +From: zhangbinchen +Date: Tue, 16 Mar 2021 11:30:43 +0800 +Subject: [PATCH] rebrand : rebrand txt use anolis + +Signed-off-by: zhangbinchen +--- + Doc/library/gettext.rst | 2 +- + Doc/library/platform.rst | 4 ++-- + Lib/platform.py | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Doc/library/gettext.rst b/Doc/library/gettext.rst +index 4b4883a..e3c20fd 100644 +--- a/Doc/library/gettext.rst ++++ b/Doc/library/gettext.rst +@@ -746,7 +746,7 @@ implementations, and valuable experience to the creation of this module: + + .. rubric:: Footnotes + +-.. [#] The default locale directory is system dependent; for example, on RedHat Linux ++.. [#] The default locale directory is system dependent; for example, on Anolis OS + it is :file:`/usr/share/locale`, but on Solaris it is :file:`/usr/lib/locale`. + The :mod:`gettext` module does not try to support these system dependent + defaults; instead its default is :file:`sys.prefix/share/locale`. For this +diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst +index 3d0743b..7e35ac8 100644 +--- a/Doc/library/platform.rst ++++ b/Doc/library/platform.rst +@@ -242,7 +242,7 @@ Unix Platforms + -------------- + + +-.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...)) ++.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake','anolis',...)) + + This is an old version of the functionality now provided by + :func:`linux_distribution`. For new code, please use the +@@ -254,7 +254,7 @@ Unix Platforms + + .. deprecated:: 2.6 + +-.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1) ++.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake','anolis',...), full_distribution_name=1) + + Tries to determine the name of the Linux OS distribution name. + +diff --git a/Lib/platform.py b/Lib/platform.py +index e04d87f..e89fa52 100755 +--- a/Lib/platform.py ++++ b/Lib/platform.py +@@ -292,7 +292,7 @@ _release_version = re.compile(r'([^0-9]+)' + + _supported_dists = ( + 'SuSE', 'debian', 'fedora', 'redhat', 'centos', +- 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', ++ 'mandrake', 'anolis', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', + 'UnitedLinux', 'turbolinux') + + def _parse_release_file(firstline): +-- +2.26.2 + diff --git a/python2.spec b/python2.spec index 2bf4548..5d30ada 100644 --- a/python2.spec +++ b/python2.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 # ====================================================== # Conditionals and other variables controlling the build # ====================================================== @@ -96,7 +97,6 @@ # the rest of the build %global regenerate_autotooling_patch 0 - # ================== # Top-level metadata # ================== @@ -104,7 +104,7 @@ Summary: An interpreted, interactive, object-oriented programming language Name: %{python} # Remember to also rebase python2-docs when changing this: Version: 2.7.18 -Release: 12%{?dist} +Release: 12%{anolis_release}%{?dist} License: Python Group: Development/Languages Requires: %{python}-libs%{?_isa} = %{version}-%{release} @@ -831,6 +831,10 @@ Patch394: 00394-cve-2022-45061-cpu-denial-of-service-via-inefficient-idna-decode Patch5000: 05000-autotool-intermediates.patch +# Add by Anolis +Patch10000: 10000-python2-anolis-rebrand.patch +# End + # ====================================================== # Additional metadata, and subpackages # ====================================================== @@ -1161,6 +1165,9 @@ find -name "*~" |xargs rm -f %patch5000 -p0 -b .autotool-intermediates %endif +# Add by Anolis +%patch10000 -p1 +# End # ====================================================== # Configuring and building the code: @@ -2089,6 +2096,9 @@ fi # ====================================================== %changelog +* Wed Jun 07 2023 zhangbinchen - 2.7.18-12.0.1 +- Rebrand for Anolis OS + * Wed Dec 21 2022 Charalampos Stratakis - 2.7.18-12 - Security fix for CVE-2022-45061: CPU denial of service via inefficient IDNA decoder Resolves: rhbz#2144072 -- Gitee From e03e9b5937f57b7b3ac7702febb96293f1ae612f Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Thu, 4 Nov 2021 16:11:55 +0800 Subject: [PATCH 3/3] build: support loongarch64 Signed-off-by: Liwei Ge --- python2.spec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python2.spec b/python2.spec index 5d30ada..123e9e4 100644 --- a/python2.spec +++ b/python2.spec @@ -49,7 +49,7 @@ %global with_systemtap 1 # some arches don't have valgrind so we need to disable its support on them -%ifnarch s390 %{mips} riscv64 +%ifnarch s390 %{mips} riscv64 loongarch64 %global with_valgrind 1 %else %global with_valgrind 0 @@ -1486,7 +1486,7 @@ install -d %{buildroot}/%{_prefix}/lib/python%{pybasever}/site-packages %global _pyconfig32_h pyconfig-32.h %global _pyconfig64_h pyconfig-64.h -%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} riscv64 +%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} riscv64 loongarch64 %global _pyconfig_h %{_pyconfig64_h} %else %global _pyconfig_h %{_pyconfig32_h} @@ -1555,7 +1555,7 @@ done # Install a tapset for this libpython into tapsetdir, fixing up the path to the # library: mkdir -p %{buildroot}%{tapsetdir} -%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} +%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 aarch64 %{mips64} loongarch64 %global libpython_stp_optimized libpython%{pybasever}-64.stp %global libpython_stp_debug libpython%{pybasever}-debug-64.stp %else @@ -1649,7 +1649,7 @@ CheckPython() { %ifarch s390 s390x %{power64} %{arm} aarch64 %{mips} EXTRATESTOPTS="$EXTRATESTOPTS -x test_gdb" %endif -%ifarch %{mips64} +%ifarch %{mips64} loongarch64 EXTRATESTOPTS="$EXTRATESTOPTS -x test_ctypes" %endif @@ -2098,6 +2098,7 @@ fi %changelog * Wed Jun 07 2023 zhangbinchen - 2.7.18-12.0.1 - Rebrand for Anolis OS +- Support loongarch64 platform(Liwei Ge) * Wed Dec 21 2022 Charalampos Stratakis - 2.7.18-12 - Security fix for CVE-2022-45061: CPU denial of service via inefficient IDNA decoder -- Gitee