From 0249d9c8932674b8b00ec0d0a261f616794eee36 Mon Sep 17 00:00:00 2001 From: Divya Chellam Date: Thu, 12 Sep 2024 06:44:07 +0000 Subject: python3: Upgrade 3.12.5 -> 3.12.6 Includes security fixes for CVE-2024-7592, CVE-2024-8088, CVE-2024-6232 and other bug fixes. Removed below patches, as the fix is included in 3.12.6 upgrade: 1. CVE-2024-7592.patch Release Notes: https://www.python.org/downloads/release/python-3126/ (From OE-Core rev: aa492b1fd5973c37b8fa2cd17d28199eba46afcc) Signed-off-by: Divya Chellam Signed-off-by: Richard Purdie --- ...1-test_readline-skip-limited-history-test.patch | 19 +- .../python/python3/CVE-2024-7592.patch | 231 ---------- meta/recipes-devtools/python/python3_3.12.5.bb | 477 --------------------- meta/recipes-devtools/python/python3_3.12.6.bb | 476 ++++++++++++++++++++ 4 files changed, 484 insertions(+), 719 deletions(-) delete mode 100644 meta/recipes-devtools/python/python3/CVE-2024-7592.patch delete mode 100644 meta/recipes-devtools/python/python3_3.12.5.bb create mode 100644 meta/recipes-devtools/python/python3_3.12.6.bb (limited to 'meta') diff --git a/meta/recipes-devtools/python/python3/0001-test_readline-skip-limited-history-test.patch b/meta/recipes-devtools/python/python3/0001-test_readline-skip-limited-history-test.patch index 50a4609f7a..e8d297c721 100644 --- a/meta/recipes-devtools/python/python3/0001-test_readline-skip-limited-history-test.patch +++ b/meta/recipes-devtools/python/python3/0001-test_readline-skip-limited-history-test.patch @@ -16,11 +16,11 @@ Signed-off-by: Trevor Gamblin Lib/test/test_readline.py | 2 ++ 1 file changed, 2 insertions(+) -diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py -index 91fd7dd13f9..d81f9bf8eed 100644 ---- a/Lib/test/test_readline.py -+++ b/Lib/test/test_readline.py -@@ -132,6 +132,7 @@ def test_nonascii_history(self): +Index: Python-3.12.6/Lib/test/test_readline.py +=================================================================== +--- Python-3.12.6.orig/Lib/test/test_readline.py ++++ Python-3.12.6/Lib/test/test_readline.py +@@ -133,6 +133,7 @@ class TestHistoryManipulation (unittest. self.assertEqual(readline.get_history_item(1), "entrée 1") self.assertEqual(readline.get_history_item(2), "entrée 22") @@ -28,14 +28,11 @@ index 91fd7dd13f9..d81f9bf8eed 100644 def test_write_read_limited_history(self): previous_length = readline.get_history_length() self.addCleanup(readline.set_history_length, previous_length) -@@ -349,6 +350,7 @@ def test_history_size(self): - self.assertEqual(len(lines), history_size) - self.assertEqual(lines[-1].strip(), b"last input") +@@ -371,6 +372,7 @@ readline.write_history_file(history_file + self.assertIn(b"done", output) + + @unittest.skip("Skipping problematic test") def test_write_read_limited_history(self): previous_length = readline.get_history_length() self.addCleanup(readline.set_history_length, previous_length) --- -2.39.2 - diff --git a/meta/recipes-devtools/python/python3/CVE-2024-7592.patch b/meta/recipes-devtools/python/python3/CVE-2024-7592.patch deleted file mode 100644 index 7fd74abed3..0000000000 --- a/meta/recipes-devtools/python/python3/CVE-2024-7592.patch +++ /dev/null @@ -1,231 +0,0 @@ -From 04ac47b343b10f2182c4b3730d4be241b2397a4d Mon Sep 17 00:00:00 2001 -From: Serhiy Storchaka -Date: Fri, 16 Aug 2024 19:13:37 +0300 -Subject: [PATCH 1/4] gh-123067: Fix quadratic complexity in parsing cookies - with backslashes - -This fixes CVE-2024-7592. - -CVE: CVE-2024-7592 -Upstream-Status: Backport [https://github.com/python/cpython/pull/123075] -Signed-off-by: Khem Raj - ---- - Lib/http/cookies.py | 34 ++++------------- - Lib/test/test_http_cookies.py | 38 +++++++++++++++++++ - ...-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst | 1 + - 3 files changed, 47 insertions(+), 26 deletions(-) - create mode 100644 Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst - -diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py -index 351faf428a20cd..11a67e8a2e008b 100644 ---- a/Lib/http/cookies.py -+++ b/Lib/http/cookies.py -@@ -184,8 +184,12 @@ def _quote(str): - return '"' + str.translate(_Translator) + '"' - - --_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]") --_QuotePatt = re.compile(r"[\\].") -+_unquote_re = re.compile(r'\\(?:([0-3][0-7][0-7])|(["\\]))') -+def _unquote_replace(m): -+ if m[1]: -+ return chr(int(m[1], 8)) -+ else: -+ return m[2] - - def _unquote(str): - # If there aren't any doublequotes, -@@ -205,30 +209,8 @@ def _unquote(str): - # \012 --> \n - # \" --> " - # -- i = 0 -- n = len(str) -- res = [] -- while 0 <= i < n: -- o_match = _OctalPatt.search(str, i) -- q_match = _QuotePatt.search(str, i) -- if not o_match and not q_match: # Neither matched -- res.append(str[i:]) -- break -- # else: -- j = k = -1 -- if o_match: -- j = o_match.start(0) -- if q_match: -- k = q_match.start(0) -- if q_match and (not o_match or k < j): # QuotePatt matched -- res.append(str[i:k]) -- res.append(str[k+1]) -- i = k + 2 -- else: # OctalPatt matched -- res.append(str[i:j]) -- res.append(chr(int(str[j+1:j+4], 8))) -- i = j + 4 -- return _nulljoin(res) -+ -+ return _unquote_re.sub(_unquote_replace, str) - - # The _getdate() routine is used to set the expiration time in the cookie's HTTP - # header. By default, _getdate() returns the current time in the appropriate -diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py -index 925c8697f60de6..13b526d49b0856 100644 ---- a/Lib/test/test_http_cookies.py -+++ b/Lib/test/test_http_cookies.py -@@ -5,6 +5,7 @@ - import doctest - from http import cookies - import pickle -+from test import support - - - class CookieTests(unittest.TestCase): -@@ -58,6 +59,43 @@ def test_basic(self): - for k, v in sorted(case['dict'].items()): - self.assertEqual(C[k].value, v) - -+ def test_unquote(self): -+ cases = [ -+ (r'a="b=\""', 'b="'), -+ (r'a="b=\\"', 'b=\\'), -+ (r'a="b=\="', 'b=\\='), -+ (r'a="b=\n"', 'b=\\n'), -+ (r'a="b=\042"', 'b="'), -+ (r'a="b=\134"', 'b=\\'), -+ (r'a="b=\377"', 'b=\xff'), -+ (r'a="b=\400"', 'b=\\400'), -+ (r'a="b=\42"', 'b=\\42'), -+ (r'a="b=\\042"', 'b=\\042'), -+ (r'a="b=\\134"', 'b=\\134'), -+ (r'a="b=\\\""', 'b=\\"'), -+ (r'a="b=\\\042"', 'b=\\"'), -+ (r'a="b=\134\""', 'b=\\"'), -+ (r'a="b=\134\042"', 'b=\\"'), -+ ] -+ for encoded, decoded in cases: -+ with self.subTest(encoded): -+ C = cookies.SimpleCookie() -+ C.load(encoded) -+ self.assertEqual(C['a'].value, decoded) -+ -+ @support.requires_resource('cpu') -+ def test_unquote_large(self): -+ n = 10**6 -+ for encoded in r'\\', r'\134': -+ with self.subTest(encoded): -+ data = 'a="b=' + encoded*n + ';"' -+ C = cookies.SimpleCookie() -+ C.load(data) -+ value = C['a'].value -+ self.assertEqual(value[:3], 'b=\\') -+ self.assertEqual(value[-2:], '\\;') -+ self.assertEqual(len(value), n + 3) -+ - def test_load(self): - C = cookies.SimpleCookie() - C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme') -diff --git a/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst b/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst -new file mode 100644 -index 00000000000000..158b938a65a2d4 ---- /dev/null -+++ b/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst -@@ -0,0 +1 @@ -+Fix quadratic complexity in parsing cookies with backslashes. - -From ab87c992c2d4cd28560178048915bc9636d6566e Mon Sep 17 00:00:00 2001 -From: Serhiy Storchaka -Date: Fri, 16 Aug 2024 19:38:20 +0300 -Subject: [PATCH 2/4] Restore the current behavior for backslash-escaping. - ---- - Lib/http/cookies.py | 2 +- - Lib/test/test_http_cookies.py | 8 ++++---- - 2 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py -index 11a67e8a2e008b..464abeb0fb253a 100644 ---- a/Lib/http/cookies.py -+++ b/Lib/http/cookies.py -@@ -184,7 +184,7 @@ def _quote(str): - return '"' + str.translate(_Translator) + '"' - - --_unquote_re = re.compile(r'\\(?:([0-3][0-7][0-7])|(["\\]))') -+_unquote_re = re.compile(r'\\(?:([0-3][0-7][0-7])|(.))') - def _unquote_replace(m): - if m[1]: - return chr(int(m[1], 8)) -diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py -index 13b526d49b0856..8879902a6e2f41 100644 ---- a/Lib/test/test_http_cookies.py -+++ b/Lib/test/test_http_cookies.py -@@ -63,13 +63,13 @@ def test_unquote(self): - cases = [ - (r'a="b=\""', 'b="'), - (r'a="b=\\"', 'b=\\'), -- (r'a="b=\="', 'b=\\='), -- (r'a="b=\n"', 'b=\\n'), -+ (r'a="b=\="', 'b=='), -+ (r'a="b=\n"', 'b=n'), - (r'a="b=\042"', 'b="'), - (r'a="b=\134"', 'b=\\'), - (r'a="b=\377"', 'b=\xff'), -- (r'a="b=\400"', 'b=\\400'), -- (r'a="b=\42"', 'b=\\42'), -+ (r'a="b=\400"', 'b=400'), -+ (r'a="b=\42"', 'b=42'), - (r'a="b=\\042"', 'b=\\042'), - (r'a="b=\\134"', 'b=\\134'), - (r'a="b=\\\""', 'b=\\"'), - -From 1fe24921da4c6c547da82e11c9703f3588dc5fab Mon Sep 17 00:00:00 2001 -From: Serhiy Storchaka -Date: Sat, 17 Aug 2024 12:40:11 +0300 -Subject: [PATCH 3/4] Cache the sub() method, not the compiled pattern object. - ---- - Lib/http/cookies.py | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py -index 464abeb0fb253a..6b9ed24ad8ec78 100644 ---- a/Lib/http/cookies.py -+++ b/Lib/http/cookies.py -@@ -184,7 +184,8 @@ def _quote(str): - return '"' + str.translate(_Translator) + '"' - - --_unquote_re = re.compile(r'\\(?:([0-3][0-7][0-7])|(.))') -+_unquote_sub = re.compile(r'\\(?:([0-3][0-7][0-7])|(.))').sub -+ - def _unquote_replace(m): - if m[1]: - return chr(int(m[1], 8)) -@@ -209,8 +210,7 @@ def _unquote(str): - # \012 --> \n - # \" --> " - # -- -- return _unquote_re.sub(_unquote_replace, str) -+ return _unquote_sub(_unquote_replace, str) - - # The _getdate() routine is used to set the expiration time in the cookie's HTTP - # header. By default, _getdate() returns the current time in the appropriate - -From 8256ed2228137c87d4b20747db84a9cdf0fa1d34 Mon Sep 17 00:00:00 2001 -From: Serhiy Storchaka -Date: Sat, 17 Aug 2024 13:08:20 +0300 -Subject: [PATCH 4/4] Add a reference to the module in NEWS. - ---- - .../next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst b/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst -index 158b938a65a2d4..6a234561fe31a3 100644 ---- a/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst -+++ b/Misc/NEWS.d/next/Library/2024-08-16-19-13-21.gh-issue-123067.Nx9O4R.rst -@@ -1 +1 @@ --Fix quadratic complexity in parsing cookies with backslashes. -+Fix quadratic complexity in parsing ``"``-quoted cookie values with backslashes by :mod:`http.cookies`. diff --git a/meta/recipes-devtools/python/python3_3.12.5.bb b/meta/recipes-devtools/python/python3_3.12.5.bb deleted file mode 100644 index 29b02ef510..0000000000 --- a/meta/recipes-devtools/python/python3_3.12.5.bb +++ /dev/null @@ -1,477 +0,0 @@ -SUMMARY = "The Python Programming Language" -HOMEPAGE = "http://www.python.org" -DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively." -LICENSE = "PSF-2.0" -SECTION = "devel/python" - -LIC_FILES_CHKSUM = "file://LICENSE;md5=fcf6b249c2641540219a727f35d8d2c2" - -SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ - file://run-ptest \ - file://create_manifest3.py \ - file://get_module_deps3.py \ - file://python3-manifest.json \ - file://check_build_completeness.py \ - file://reformat_sysconfig.py \ - file://cgi_py.patch \ - file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \ - file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \ - file://crosspythonpath.patch \ - file://0001-test_locale.py-correct-the-test-output-format.patch \ - file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \ - file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \ - file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \ - file://makerace.patch \ - file://0001-sysconfig.py-use-platlibdir-also-for-purelib.patch \ - file://0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch \ - file://deterministic_imports.patch \ - file://0001-Avoid-shebang-overflow-on-python-config.py.patch \ - file://0001-Update-test_sysconfig-for-posix_user-purelib.patch \ - file://0001-skip-no_stdout_fileno-test-due-to-load-variability.patch \ - file://0001-test_storlines-skip-due-to-load-variability.patch \ - file://0001-test_shutdown-skip-problematic-test.patch \ - file://0001-gh-107811-tarfile-treat-overflow-in-UID-GID-as-failu.patch \ - file://0001-test_deadlock-skip-problematic-test.patch \ - file://0001-test_active_children-skip-problematic-test.patch \ - file://0001-test_readline-skip-limited-history-test.patch \ - file://CVE-2024-7592.patch \ - " - -SRC_URI:append:class-native = " \ - file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \ - " - -SRC_URI[sha256sum] = "fa8a2e12c5e620b09f53e65bcd87550d2e5a1e2e04bf8ba991dcc55113876397" - -# exclude pre-releases for both python 2.x and 3.x -UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P\d+(\.\d+)+).tar" - -CVE_PRODUCT = "python cpython" - -CVE_STATUS[CVE-2007-4559] = "disputed: Upstream consider this expected behaviour" -CVE_STATUS[CVE-2019-18348] = "not-applicable-config: This is not exploitable when glibc has CVE-2016-10739 fixed" -CVE_STATUS[CVE-2020-15523] = "not-applicable-platform: Issue only applies on Windows" -CVE_STATUS[CVE-2022-26488] = "not-applicable-platform: Issue only applies on Windows" -# The module will be removed in the future and flaws documented. -CVE_STATUS[CVE-2015-20107] = "upstream-wontfix: The mailcap module is insecure by design, so this can't be fixed in a meaningful way" -CVE_STATUS[CVE-2023-36632] = "disputed: Not an issue, in fact expected behaviour" - -PYTHON_MAJMIN = "3.12" - -S = "${WORKDIR}/Python-${PV}" - -BBCLASSEXTEND = "native nativesdk" - -inherit autotools pkgconfig qemu ptest multilib_header update-alternatives - -MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" - -ALTERNATIVE:${PN}-dev = "python3-config" -ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config" -ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}" - - -DEPENDS = "bzip2-replacement-native expat libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux-libuuid libtirpc libnsl2 autoconf-archive-native ncurses" -DEPENDS:append:class-target = " python3-native" -DEPENDS:append:class-nativesdk = " python3-native" - -EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib} --with-system-expat" -EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}" -EXTRA_OECONF:append:class-target = " --with-build-python=nativepython3" -EXTRA_OECONF:append:class-nativesdk = " --with-build-python=nativepython3" - -export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/" - -EXTRANATIVEPATH += "python3-native" - -# LTO will be enabled via packageconfig depending upong distro features -LTO:class-target = "" - -CACHED_CONFIGUREVARS = " \ - ac_cv_file__dev_ptmx=yes \ - ac_cv_file__dev_ptc=no \ - ac_cv_working_tzset=yes \ -" -# set thread stack size to 2MB on musl for interpreter and stdlib C extensions -# so it does not run into stack limits due to musl's small thread stack -# This is only needed to build interpreter and not the subsequent modules -# Thats why CFLAGS_NODIST is modified instead of CFLAGS -CACHED_CONFIGUREVARS:append:libc-musl = "\ - CFLAGS_NODIST='${CFLAGS} -DTHREAD_STACK_SIZE=0x200000' \ -" - -# PGO currently causes builds to not be reproducible so disable by default, see YOCTO #13407 -PACKAGECONFIG ??= "editline gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}" -PACKAGECONFIG[readline] = "--with-readline=readline,,readline,,,editline" -PACKAGECONFIG[editline] = "--with-readline=editline,,libedit,,,readline" -# Use profile guided optimisation by running PyBench inside qemu-user -PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native" -PACKAGECONFIG[tk] = ",,tk" -PACKAGECONFIG[tcl] = ",,tcl" -PACKAGECONFIG[gdbm] = ",,gdbm" -PACKAGECONFIG[lto] = "--with-lto,--without-lto" -PACKAGECONFIG[staticlibpython] = "--with-static-libpython,--without-static-libpython" - -do_configure:prepend () { - mkdir -p ${B}/Modules - cat > ${B}/Modules/Setup.local << EOF -*disabled* -${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)} -${@bb.utils.contains_any('PACKAGECONFIG', 'readline editline', '', 'readline', d)} -${@bb.utils.contains('PACKAGECONFIG', 'tk', '', '_tkinter', d)} -EOF -} - -CPPFLAGS += "-I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" - -# COMPILEALL_OPTS= ensures that .pyc are not compiled in parallel -# This was found to lock up builds, break reproducibility, and produce strange file ownership -# races. -# -# The upstream commit introducing the change was: -# https://github.com/python/cpython/commit/1a2dd82f56bd813aacc570e172cefe55a8a41504 -# -# The build lock up issue is reported here: -# https://bugs.python.org/issue45945 -# -# The repro failures are documented here: -# https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20211130-yr_o1a8d/packages/diff-html/ - -EXTRA_OEMAKE = '\ - STAGING_LIBDIR=${STAGING_LIBDIR} \ - STAGING_INCDIR=${STAGING_INCDIR} \ - LIB=${baselib} \ - COMPILEALL_OPTS= \ -' - -# Generate a Profile Guided Optimisation wrapper script that uses qemu-user for -# all cross builds. -write_pgo_wrapper:class-native = ":" -write_pgo_wrapper() { - if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then - cat >pgo-wrapper < ${B}/Modules/Setup.local << EOF +*disabled* +${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)} +${@bb.utils.contains_any('PACKAGECONFIG', 'readline editline', '', 'readline', d)} +${@bb.utils.contains('PACKAGECONFIG', 'tk', '', '_tkinter', d)} +EOF +} + +CPPFLAGS += "-I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" + +# COMPILEALL_OPTS= ensures that .pyc are not compiled in parallel +# This was found to lock up builds, break reproducibility, and produce strange file ownership +# races. +# +# The upstream commit introducing the change was: +# https://github.com/python/cpython/commit/1a2dd82f56bd813aacc570e172cefe55a8a41504 +# +# The build lock up issue is reported here: +# https://bugs.python.org/issue45945 +# +# The repro failures are documented here: +# https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20211130-yr_o1a8d/packages/diff-html/ + +EXTRA_OEMAKE = '\ + STAGING_LIBDIR=${STAGING_LIBDIR} \ + STAGING_INCDIR=${STAGING_INCDIR} \ + LIB=${baselib} \ + COMPILEALL_OPTS= \ +' + +# Generate a Profile Guided Optimisation wrapper script that uses qemu-user for +# all cross builds. +write_pgo_wrapper:class-native = ":" +write_pgo_wrapper() { + if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then + cat >pgo-wrapper <