Title: Autobind of empty unix socket on Linux broken since python 3.9 · Issue #94821 · python/cpython · GitHub
Open Graph Title: Autobind of empty unix socket on Linux broken since python 3.9 · Issue #94821 · python/cpython
X Title: Autobind of empty unix socket on Linux broken since python 3.9 · Issue #94821 · python/cpython
Description: Bug report When using empty address for unix socket on Linux, the socket is bound to a random address in the abstract namespace. from unix(7): Autobind feature If a bind(2) call specifies addrlen as sizeof(sa_family_t), or the SO_PASSCRE...
Open Graph Description: Bug report When using empty address for unix socket on Linux, the socket is bound to a random address in the abstract namespace. from unix(7): Autobind feature If a bind(2) call specifies addrlen a...
X Description: Bug report When using empty address for unix socket on Linux, the socket is bound to a random address in the abstract namespace. from unix(7): Autobind feature If a bind(2) call specifies addrlen a...
Opengraph URL: https://github.com/python/cpython/issues/94821
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Autobind of empty unix socket on Linux broken since python 3.9","articleBody":"**Bug report**\r\n\r\nWhen using empty address for unix socket on Linux, the socket is bound to a random\r\naddress in the abstract namespace.\r\n\r\nfrom unix(7):\r\n```\r\n Autobind feature\r\n If a bind(2) call specifies addrlen as sizeof(sa_family_t), or the\r\n SO_PASSCRED socket option was specified for a socket that was not ex‐\r\n plicitly bound to an address, then the socket is autobound to an ab‐\r\n stract address. The address consists of a null byte followed by 5\r\n bytes in the character set [0-9a-f]. Thus, there is a limit of 2^20\r\n autobind addresses. (From Linux 2.1.15, when the autobind feature was\r\n added, 8 bytes were used, and the limit was thus 2^32 autobind ad‐\r\n dresses. The change to 5 bytes came in Linux 2.3.15.)\r\n```\r\n\r\nSince python 3.9, when using empty socket address (\"\"), bind() is called with\r\nwith `path.len + offsetof(struct sockaddr_un, sun_path) + 1`, so the socket is\r\nbound to the specific address \"\\0\" instead of a random address (e.g. \"\\075499\").\r\nThis breaks code assuming that multiple sockets can be bound to a random address\r\nat the same time.\r\n\r\nIn python 3.8 (not including this change):\r\n\r\n```\r\n$ python3.8\r\nPython 3.8.13 (default, Jun 10 2022, 00:00:00) \r\n[GCC 12.1.1 20220507 (Red Hat 12.1.1-1)] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n\u003e\u003e\u003e import socket\r\n\u003e\u003e\u003e s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\r\n\u003e\u003e\u003e s.bind(\"\")\r\n\u003e\u003e\u003e s.getsockname()\r\nb'\\x0075499'\r\n```\r\n\r\nWith python 3.9 (including this change):\r\n```\r\n$ python3.9\r\nPython 3.9.13 (main, Jun 9 2022, 00:00:00) \r\n[GCC 12.1.1 20220507 (Red Hat 12.1.1-1)] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n\u003e\u003e\u003e import socket\r\n\u003e\u003e\u003e s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)\r\n\u003e\u003e\u003e s.bind(\"\")\r\n\u003e\u003e\u003e s.getsockname()\r\nb'\\x00'\r\n```\r\n\r\n**Your environment**\r\n\r\n- CPython versions tested on: python 3.9, python 3.10\r\n- Operating system and architecture: Fedora 36, Ubuntu latest (GitHub actions)\r\n\r\nThe breaking change is f6b3a07b7df60dc04d0260169ffef6e9796a2124, backported\r\nto python 3.9. I suspect that change was not needed since it did not include\r\nany test showing a real issue, but it is possible to fix handling of empty\r\nunix socket address without reverting this change. ","author":{"url":"https://github.com/nirs","@type":"Person","name":"nirs"},"datePublished":"2022-07-13T20:09:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/94821/cpython/issues/94821"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:30ccd5c1-569f-1c20-6b5a-c225a29f2dbd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88BE:1E4FEF:46CC01:5AC2A3:696AE210 |
| html-safe-nonce | b4aa9fccaeb0cc3d4399e19564e31083bea0339b9f067d326cb03ad073dc0f31 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEJFOjFFNEZFRjo0NkNDMDE6NUFDMkEzOjY5NkFFMjEwIiwidmlzaXRvcl9pZCI6IjI1NDAwNDM3NzY1ODcxMjkzNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a65a1cfb644bf0558e28f56595325a224c44ee1cc7fe49c8c26b5ee8b46dc791 |
| hovercard-subject-tag | issue:1303884778 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/94821/issue_layout |
| twitter:image | https://opengraph.githubassets.com/255ae778a761c3b4ead759f7b195cc00334a5afba7f9f5e5edbd2e8f12099b53/python/cpython/issues/94821 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/255ae778a761c3b4ead759f7b195cc00334a5afba7f9f5e5edbd2e8f12099b53/python/cpython/issues/94821 |
| og:image:alt | Bug report When using empty address for unix socket on Linux, the socket is bound to a random address in the abstract namespace. from unix(7): Autobind feature If a bind(2) call specifies addrlen a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nirs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3d84d50b3c75fa36755c3cf392edbc09e626f979 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width