Skip to content

syscall: unable to use the full length for abstract socket starting with null #70893

Closed
@albertsundjaja

Description

@albertsundjaja

Go version

go version go1.23.3 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/albert/.cache/go-build'
GOENV='/home/albert/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/albert/go/pkg/mod'
GONOPROXY='bitbucket.org/vivcourt/*'
GONOSUMDB='bitbucket.org/vivcourt/*'
GOOS='linux'
GOPATH='/home/albert/go'
GOPRIVATE='bitbucket.org/vivcourt/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/albert/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/albert/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/albert/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/albert/glue/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3031541326=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/Lro4QrH5-BK

What did you see happen?

padded addr1 (@begins-with-at) with length: 108
padded addr2 (begins-with-null) with length: 108
panic: listen unix begins-with-null: bind: invalid argument

goroutine 1 [running]:
main.main()
/tmp/sandbox3694864181/prog.go:27 +0x294

What did you expect to see?

both address (beginning with @ and null or 0) should be useable to specify abstract unix domain socket with length of 108 (full path length)

the issue seems to be this line of code that checks for @ for abstract domain socket but not for 0
https://github.com/golang/go/blob/master/src/syscall/syscall_linux.go#L557

considering how the next part of the code checks for 0 and sl > 3 https://github.com/golang/go/blob/master/src/syscall/syscall_linux.go#L569
I would expect that specifying 0 to indicate it's a domain socket to be a valid way of doing so

let me know if this is something that should be fixed, I would be more than happy to create a PR. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions