golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.95k stars 17.66k forks source link

syscall: incorrect length of abstract Unix domain socket paths beginning with null character #63579

Closed 1f604 closed 2 months ago

1f604 commented 1 year ago

What version of Go are you using (go version)?

$ go version
go version go1.21.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/x/.cache/go-build'
GOENV='/home/x/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/x/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/x/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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-build3291950043=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/QzrhBGKYhJc

What did you expect to see?

Num       RefCount Protocol Flags    Type St Inode Path
0000000000000000: 00000001 00000000 00010000 0001 01        1 @begins-with-null-1
0000000000000000: 00000001 00000000 00010000 0001 01        2 @begins-with-at-1
0000000000000000: 00000001 00000000 00010000 0001 01        3 @begins-with-null-2
0000000000000000: 00000001 00000000 00010000 0001 01        4 @begins-with-at-2

What did you see instead?

Num       RefCount Protocol Flags    Type St Inode Path
0000000000000000: 00000001 00000000 00010000 0001 01        1 @begins-with-null-1\x0
0000000000000000: 00000001 00000000 00010000 0001 01        2 @begins-with-at-1
0000000000000000: 00000001 00000000 00010000 0001 01        3 @begins-with-null-2\x0
0000000000000000: 00000001 00000000 00010000 0001 01        4 @begins-with-at-2

In the syscall file there is code that special-cases handling of unix socket names beginning with @ by removing the trailing NUL character but it does not do the same for unix socket names starting with the NUL character.

It seems obvious to me that this is just a simple oversight and the fix is very simple. Lemme just make a PR...

gopherbot commented 1 year ago

Change https://go.dev/cl/535776 mentions this issue: syscall: stop counting trailing NUL for abstract addresses starting with NUL

gopherbot commented 1 year ago

Change https://go.dev/cl/535955 mentions this issue: syscall: stop counting trailing NUL for abstract addresses starting with NUL

cagedmantis commented 1 year ago

cc @golang/runtime

ianlancetaylor commented 2 months ago

I believe this is fixed by the above CLs.