-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-44493: Add missing terminated NUL in sockaddr_un's length #26866
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
This PR is stale because it has been open for 30 days with no activity. |
9d52974
to
f6c4adc
Compare
Can anyone review this PR? |
d96470f
to
75a4ce9
Compare
Can anyone review this PR? |
I too am now facing this same issue. How can it be moved along? |
I can't believe this missed the 3.10 release. :( |
This comment was marked as abuse.
This comment was marked as abuse.
I'm temporarily locking this PR to prevent further abuse. The issue on BPO hasn't been triaged because it lacks any sort of description of the issue. You should provide an explanation why you consider the code to be wrong. A reproducer is greatly appreciated. The change set also needs a test case. PS: In case you wonder where the maintainers are, two are currently in the middle of a war zone and the others are worried for their lives. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think it is difficult to write any tests for this, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A regression test seems doable and potentially important if I understand this bug correctly:
It looks like the length would be short by one in Python before this change, meaning binding to a AF_UNIX socket potentially loses the last character of the path name intended to be bound?
That should be an observable behavior change.
It also suggests that fixing this will break code that has been working around this bug forever by adding an extra character when binding or connecting to a non-anonymous AF_UNIX socket?
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be poked with soft cushions! |
our bots have some known glitches :) this PR was good. |
GH-32140 is a backport of this pull request to the 3.10 branch. |
GH-32141 is a backport of this pull request to the 3.9 branch. |
…GH-26866) Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN (cherry picked from commit f6b3a07) Co-authored-by: ty <zonyitoo@users.noreply.github.com>
…GH-26866) Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN (cherry picked from commit f6b3a07) Co-authored-by: ty <zonyitoo@users.noreply.github.com>
regarding the conditional defines and sun_len population, if there is a problem being caused by not doing that, file a separate issue and it can be addressed via that. |
…H-26866) (GH-32140) Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN (cherry picked from commit f6b3a07) Co-authored-by: ty <zonyitoo@users.noreply.github.com> Automerge-Triggered-By: GH:gpshead
…ythonGH-26866) (pythonGH-32140) Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN (cherry picked from commit f6b3a07) Co-authored-by: ty <zonyitoo@users.noreply.github.com> Automerge-Triggered-By: GH:gpshead (cherry picked from commit 5944807) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
…H-26866) (GH-32140) (GH-32156) Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN (cherry picked from commit f6b3a07) Co-authored-by: ty <zonyitoo@users.noreply.github.com> Automerge-Triggered-By: GH:gpshead (cherry picked from commit 5944807) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
…ythonGH-26866) (pythonGH-32140) (pythonGH-32156) Add missing terminated NUL in sockaddr_un's length - Linux: https://man7.org/linux/man-pages/man7/unix.7.html - *BSD: SUN_LEN (cherry picked from commit f6b3a07) Co-authored-by: ty <zonyitoo@users.noreply.github.com> Automerge-Triggered-By: GH:gpshead (cherry picked from commit 5944807) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
…4826) When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (pythonGH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
…4826) When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (pythonGH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
…4826) When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (pythonGH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
) When binding a unix socket to an empty address on Linux, the socket is automatically bound to an available address in the abstract namespace. >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) >>> s.bind("") >>> s.getsockname() b'\x0075499' Since python 3.9, the socket is bound to the one address: >>> s.getsockname() b'\x00' And trying to bind multiple sockets will fail with: Traceback (most recent call last): File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind s2.bind("") OSError: [Errno 98] Address already in use Added 2 tests: - Auto binding empty address on Linux - Failing to bind an empty address on other platforms Fixes f6b3a07 (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (cherry picked from commit c22f134) Co-authored-by: Nir Soffer <nsoffer@redhat.com>
https://bugs.python.org/issue44493
Automerge-Triggered-By: GH:gpshead