Skip to content

Conversation

@mox692
Copy link
Member

@mox692 mox692 commented Aug 13, 2024

Motivation

Closes #6767.

Solution

If the beginning of the path is \0, we fallback to std's from_abstract_name.

@mox692 mox692 added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Aug 13, 2024
@mox692 mox692 force-pushed the mox692/handle_abstract_socket_name branch 2 times, most recently from afe849e to 062c36b Compare August 13, 2024 15:06
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could make sense to release as an 1.39.3. Thoughts?

@mox692
Copy link
Member Author

mox692 commented Aug 14, 2024

This could make sense to release as an 1.39.3.

yes, I agree.

@Darksonn
Copy link
Contributor

I just created a tokio-1.39.x branch. Can you move this PR over to that branch instead of master?

@mox692 mox692 changed the base branch from master to tokio-1.39.x August 15, 2024 12:49
@mox692 mox692 force-pushed the mox692/handle_abstract_socket_name branch from aa870b7 to 50fe61a Compare August 15, 2024 12:50
@mox692 mox692 requested a review from Darksonn August 15, 2024 13:05
@mox692 mox692 merged commit b2ea40b into tokio-rs:tokio-1.39.x Aug 16, 2024
kodiakhq bot pushed a commit to pdylanross/fatigue that referenced this pull request Aug 19, 2024
Bumps tokio from 1.39.2 to 1.39.3.

Release notes
Sourced from tokio's releases.

Tokio v1.39.3
1.39.3 (August 17th, 2024)
This release fixes a regression where the unix socket api stopped accepting the abstract socket namespace. (#6772)
#6772: tokio-rs/tokio#6772



Commits

3d439ab chore: prepare Tokio v1.39.3 (#6782)
b2ea40b net: add handling for abstract socket name (#6772)
See full diff in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot merge will merge this PR after your CI passes on it
@dependabot squash and merge will squash and merge this PR after your CI passes on it
@dependabot cancel merge will cancel a previously requested merge and block automerging
@dependabot reopen will reopen this PR if it is closed
@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
@mox692 mox692 deleted the mox692/handle_abstract_socket_name branch August 26, 2024 09:55
let addr = {
let os_str_bytes = path.as_ref().as_os_str().as_bytes();
if os_str_bytes.starts_with(b"\0") {
StdSocketAddr::from_abstract_name(os_str_bytes)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might a bug here.
The leading '\0' should not be passed to the StdSocketAddr::from_abstract_name() because this way there will be two leading NUL chars in the final name (i.e. \0\0...).

See https://github.com/rust-lang/rust/blob/1.89.0/library/std/src/os/unix/net/addr.rs#L273-L285

Here the addr is initialized with mem::zeroed() and later the passed name is copied to the ptr + 1:

crate::ptr::copy_nonoverlapping(
                name.as_ptr(),
                addr.sun_path.as_mut_ptr().add(1) as *mut u8,
                name.len(),
            );

So, there are two NULs - one from zeroed() and another from name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you open an issue or PR?

let addr = {
let os_str_bytes = path.as_ref().as_os_str().as_bytes();
if os_str_bytes.starts_with(b"\0") {
StdSocketAddr::from_abstract_name(os_str_bytes)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio Area: The main tokio crate M-net Module: tokio/net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnixStream::connect regression after mio v1 upgrade

3 participants