Bug 2107689 - Autobind of empty unix socket on Linux broken since python 3.9
Summary: Autobind of empty unix socket on Linux broken since python 3.9
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: python3.9
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Charalampos Stratakis
QA Contact: Lukáš Zachar
URL:
Whiteboard:
: 2129075 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-15 16:16 UTC by Nir Soffer
Modified: 2023-08-07 08:57 UTC (History)
7 users (show)

Fixed In Version: python3.9-3.9.14-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2128249 (view as bug list)
Environment:
Last Closed: 2023-08-07 08:57:40 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-127892 0 None None None 2022-07-15 16:18:51 UTC

Description Nir Soffer 2022-07-15 16:16:55 UTC
Description of problem:

Since python 3.9, bind("") binds to b"\x00" instead of to a random address
in the abstract namespace (e.g. b"\x0012345")

In python 3.8:

    $ python3.8
    Python 3.8.13 (default, Jun 10 2022, 00:00:00) 
    [GCC 12.1.1 20220507 (Red Hat 12.1.1-1)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import socket
    >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    >>> s.bind("")
    >>> s.getsockname()
    b'\x0075499'

With python 3.9:

    $ python3
    Python 3.9.13 (main, Jun  9 2022, 00:00:00) 
    [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import socket
    >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    >>> s.bind("")
    >>> s.getsockname()
    b'\x00'

Trying to bind multiple socket to "" will fail with:

    OSError: [Errno 98] Address already in use


Version-Release number of selected component (if applicable):
python3-3.9.13-2.el9.x86_64

How reproducible:
100%

Upstream bug:
https://github.com/python/cpython/issues/94821

Fixed in:
https://github.com/python/cpython/pull/94826

Backport to 3.9:
https://github.com/python/cpython/pull/94875

Comment 3 Tomas Orsava 2022-08-10 12:07:53 UTC
This has been fixed in Python 3.9 on July 26th 2022, since it's not urgent we're waiting for a new release of Python 3.9 upstream (happens every ~2 months) and then we'll rebase. Most likely this will happen for RHEL 9.2.

Comment 4 Victor Stinner 2022-09-12 12:24:07 UTC
Python 3.9.14 released last week contains the fix: https://pythoninsider.blogspot.com/2022/09/python-releases-3107-3914-3814-and-3714.html

Comment 8 Charalampos Stratakis 2022-09-23 16:00:13 UTC
*** Bug 2129075 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.