Skip to content

runtime, syscall: Linux syscall wrappers incorrectly treat -4095 as success #82228

Open

Description

@OfficialKatana

Go version

go1.28-devel_e58509ab7ed2 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/user/go/bin'
GOCACHE='/home/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3452989561=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/project/p4test'
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPACKAGESDRIVER=''
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.google.cn'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.28-devel_e58509ab7ed2'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

While reviewing the Linux syscall assembly implementations, I noticed that several syscall wrappers use unsigned less-than-or-equal comparisons to distinguish successful return values from errors.

On Linux, syscall return values in the range -4095 to -1 (inclusive) indicate errors.

However, the current implementations compare the return value against -4095 and branch to the success path when the value is less than or equal to that boundary.

For example, on linux/amd64:

CMPQ AX, $0xfffffffffffff001
JLS ok

Similar comparisons exist in the Linux syscall implementations for 386 and ARM.

What did you see happen?

All syscall return values in the range -4095 to -1, including the boundary value -4095, should be recognized as errors and handled through the appropriate error path.

What did you expect to see?

The unsigned less-than-or-equal comparison includes the boundary value -4095, causing it to be incorrectly classified as a successful syscall return value.

This may result in incorrect return values or missing error propagation when a syscall returns this boundary value.

The issue affects syscall implementations in the following packages on linux/386, linux/amd64, and linux/arm:

  • runtime

  • syscall

  • internal/runtime/syscall/linux

Activity

  1. gopherbot commented on Oct 15, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/848687 mentions this issue: runtime, syscall: fix Linux syscall error boundary handling

  2. added this to the Go1.28 milestone on Oct 20, 2026
  3. self-assigned this
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions