Skip to content

Commit 94afa02

Browse files
author
Daniel Néri
committed
main/python3: patch CVE-2024-12254
Add patch to fix CVE-2024-12254: "Unbounded memory buffering in SelectorSocketTransport.writelines()". - https://mail.python.org/archives/list/[email protected]/thread/H4O3UBAOAQQXGT4RE3E4XQYR5XLROORB/ - python/cpython#127655 - python/cpython#127656
1 parent 068b58b commit 94afa02

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

main/python3/APKBUILD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pkgname=python3
44
# the python3-tkinter's pkgver needs to be synchronized with this.
55
pkgver=3.12.8
66
_basever="${pkgver%.*}"
7-
pkgrel=0
7+
pkgrel=1
88
pkgdesc="High-level scripting language"
99
url="https://www.python.org/"
1010
arch="all"
@@ -46,11 +46,14 @@ source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz
4646
musl-find_library.patch
4747
test_posix-nodev-disable.patch
4848
fix-run_fileexflags-test.patch
49+
CVE-2024-12254.patch
4950
"
5051
options="net" # Required for tests
5152
builddir="$srcdir/Python-$pkgver"
5253

5354
# secfixes:
55+
# 3.12.8-r1:
56+
# - CVE-2024-12254
5457
# 3.12.8-r0:
5558
# - CVE-2024-9287
5659
# 3.12.6-r0:
@@ -267,4 +270,5 @@ sha512sums="
267270
ab8eaa2858d5109049b1f9f553198d40e0ef8d78211ad6455f7b491af525bffb16738fed60fc84e960c4889568d25753b9e4a1494834fea48291b33f07000ec2 musl-find_library.patch
268271
606cf7b3df0c81c90571c6bc65e4f07e065867739fa0d36e9c8e1ad2d6bcd64d265f90c4a7881880fc7e0c85eed94d1f72655a5c70d92ca63e5cc4bd3be8f145 test_posix-nodev-disable.patch
269272
0e1155b1976be46d68fe50161b9644ac272d95c51f44ada51a0fd67a0154df89833752e97cfc85e977b384fca82b58907c30405a103f3a33a1483b9f76ce632f fix-run_fileexflags-test.patch
273+
594bca29856d481960c7caae45efcfe64dbc1f53b00d58c1aa560fdedb5d15794db9b66f7f3b6edc9a9b81d553a7299e61063b200e2f2fe52e0028bbc78a78fd CVE-2024-12254.patch
270274
"

main/python3/CVE-2024-12254.patch

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
https://github.com/python/cpython/issues/127655
2+
3+
From 5d355244e7c4f5d64216647ee0bf510dd8dc2bd6 Mon Sep 17 00:00:00 2001
4+
From: "J. Nick Koston" <[email protected]>
5+
Date: Thu, 5 Dec 2024 22:33:03 -0600
6+
Subject: [PATCH] gh-127655: Ensure `_SelectorSocketTransport.writelines`
7+
pauses the protocol if needed (GH-127656)
8+
9+
Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed.
10+
(cherry picked from commit e991ac8f2037d78140e417cc9a9486223eb3e786)
11+
12+
Co-authored-by: J. Nick Koston <[email protected]>
13+
Co-authored-by: Kumar Aditya <[email protected]>
14+
---
15+
Lib/asyncio/selector_events.py | 1 +
16+
Lib/test/test_asyncio/test_selector_events.py | 12 ++++++++++++
17+
.../2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst | 1 +
18+
3 files changed, 14 insertions(+)
19+
create mode 100644 Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst
20+
21+
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
22+
index 790711f834096b..dd79ad18df3b18 100644
23+
--- a/Lib/asyncio/selector_events.py
24+
+++ b/Lib/asyncio/selector_events.py
25+
@@ -1183,6 +1183,7 @@ def writelines(self, list_of_data):
26+
# If the entire buffer couldn't be written, register a write handler
27+
if self._buffer:
28+
self._loop._add_writer(self._sock_fd, self._write_ready)
29+
+ self._maybe_pause_protocol()
30+
31+
def can_write_eof(self):
32+
return True
33+
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
34+
index 47693ea4d3ce2e..736c19796ef3fc 100644
35+
--- a/Lib/test/test_asyncio/test_selector_events.py
36+
+++ b/Lib/test/test_asyncio/test_selector_events.py
37+
@@ -805,6 +805,18 @@ def test_writelines_send_partial(self):
38+
self.assertTrue(self.sock.send.called)
39+
self.assertTrue(self.loop.writers)
40+
41+
+ def test_writelines_pauses_protocol(self):
42+
+ data = memoryview(b'data')
43+
+ self.sock.send.return_value = 2
44+
+ self.sock.send.fileno.return_value = 7
45+
+
46+
+ transport = self.socket_transport()
47+
+ transport._high_water = 1
48+
+ transport.writelines([data])
49+
+ self.assertTrue(self.protocol.pause_writing.called)
50+
+ self.assertTrue(self.sock.send.called)
51+
+ self.assertTrue(self.loop.writers)
52+
+
53+
@unittest.skipUnless(selector_events._HAS_SENDMSG, 'no sendmsg')
54+
def test_write_sendmsg_full(self):
55+
data = memoryview(b'data')
56+
diff --git a/Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst b/Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst
57+
new file mode 100644
58+
index 00000000000000..76cfc58121d3bd
59+
--- /dev/null
60+
+++ b/Misc/NEWS.d/next/Security/2024-12-05-21-35-19.gh-issue-127655.xpPoOf.rst
61+
@@ -0,0 +1 @@
62+
+Fixed the :class:`!asyncio.selector_events._SelectorSocketTransport` transport not pausing writes for the protocol when the buffer reaches the high water mark when using :meth:`asyncio.WriteTransport.writelines`.

0 commit comments

Comments
 (0)