-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Description
Go version
go version go1.25.0 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/ainsoph/devel/go/bin'
GOCACHE='/home/ainsoph/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ainsoph/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build179359909=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/ainsoph/devel/github.com/elastic/00.0.wip/go-bug/go.mod'
GOMODCACHE='/home/ainsoph/devel/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ainsoph/devel/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ainsoph/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.0'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I run a program with a seccomp policy which did not allow eventfd2
. The program crashed with:
runtime: eventfd failed with 18446744073709551615
fatal error: runtime: eventfd failed
the following is a minimal version of what I run, with all allowed syscall, just missing eventfd2
, which caused the panic:
package main
import (
"log/slog"
"os"
"github.com/elastic/go-seccomp-bpf"
)
func main() {
filter := seccomp.Filter{
NoNewPrivs: true,
Flag: seccomp.FilterFlagTSync,
Policy: policy,
}
if err := seccomp.LoadFilter(filter); err != nil {
slog.Warn("Syscall filter could not be installed", "error", err,
"seccomp_filter", filter)
return
}
path, err := os.Executable()
if err != nil {
panic(err)
}
os.Open(path)
}
var policy = seccomp.Policy{
DefaultAction: seccomp.ActionErrno,
Syscalls: []seccomp.SyscallGroup{
{
Action: seccomp.ActionAllow,
Names: []string{
"accept",
"accept4",
"access",
"arch_prctl",
"bind",
"brk",
"capget",
"chmod",
"chown",
"clock_gettime",
"clock_nanosleep",
"clone",
"clone3",
"close",
"connect",
"dup",
"dup2",
"dup3",
"epoll_create",
"epoll_create1",
"epoll_ctl",
"epoll_pwait",
"epoll_wait",
"execve",
"exit",
"exit_group",
"faccessat",
"faccessat2",
"fchdir",
"fchmod",
"fchmodat",
"fchown",
"fchownat",
"fcntl",
"fdatasync",
"flock",
"fstat",
"fstatfs",
"fsync",
"ftruncate",
"futex",
"getcwd",
"getdents",
"getdents64",
"geteuid",
"getgid",
"getpeername",
"getpid",
"getppid",
"getrandom",
"getrlimit",
"getrusage",
"getsockname",
"getsockopt",
"gettid",
"gettimeofday",
"getuid",
"inotify_add_watch",
"inotify_init1",
"inotify_rm_watch",
"ioctl",
"kill",
"listen",
"lseek",
"lstat",
"madvise",
"mincore",
"mkdirat",
"mmap",
"mprotect",
"munmap",
"nanosleep",
"newfstatat",
"open",
"openat",
"pipe",
"pipe2",
"poll",
"ppoll",
"prctl",
"pread64",
"pselect6",
"pwrite64",
"read",
"readlink",
"readlinkat",
"recvfrom",
"recvmmsg",
"recvmsg",
"rename",
"renameat",
"rseq",
"rt_sigaction",
"rt_sigprocmask",
"rt_sigreturn",
"sched_getaffinity",
"sched_yield",
"sendfile",
"sendmmsg",
"sendmsg",
"sendto",
"set_robust_list",
"setitimer",
"setrlimit",
"setsockopt",
"shutdown",
"sigaltstack",
"socket",
"splice",
"stat",
"statfs",
"sysinfo",
"tgkill",
"time",
"tkill",
"uname",
"unlink",
"unlinkat",
"wait4",
"waitid",
"write",
"writev",
},
},
},
}
What did you see happen?
run the program above
go run main.go
it panics with:
runtime: eventfd failed with 18446744073709551615
fatal error: runtime: eventfd failed
goroutine 1 gp=0xc000002380 m=0 mp=0x6047e0 [running]:
runtime.throw({0x512dbf?, 0x200000003?})
/usr/local/go/src/runtime/panic.go:1094 +0x48 fp=0xc000118c90 sp=0xc000118c60 pc=0x46fd08
runtime.netpollinit()
/usr/local/go/src/runtime/netpoll_epoll.go:31 +0x14e fp=0xc000118d00 sp=0xc000118c90 pc=0x4395ce
runtime.netpollGenericInit()
/usr/local/go/src/runtime/netpoll.go:224 +0x35 fp=0xc000118d18 sp=0xc000118d00 pc=0x438ed5
internal/poll.runtime_pollServerInit()
/usr/local/go/src/runtime/netpoll.go:215 +0xf fp=0xc000118d28 sp=0xc000118d18 pc=0x46f24f
sync.(*Once).doSlow(0x0?, 0xc000118db0?)
/usr/local/go/src/sync/once.go:78 +0xac fp=0xc000118d80 sp=0xc000118d28 pc=0x47ab2c
sync.(*Once).Do(...)
/usr/local/go/src/sync/once.go:69
internal/poll.(*pollDesc).init(0xc00007e200, 0xc00007e1e0)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:39 +0x3c fp=0xc000118da0 sp=0xc000118d80 pc=0x4a2a1c
internal/poll.(*FD).Init(0xc00007e1e0, {0x50df51?, 0xc000018270?}, 0x80?)
/usr/local/go/src/internal/poll/fd_unix.go:66 +0x45 fp=0xc000118dc0 sp=0xc000118da0 pc=0x4a2da5
os.newFile(0x3, {0xc000018270, 0x25}, 0x1, 0x0)
/usr/local/go/src/os/file_unix.go:218 +0x15d fp=0xc000118e00 sp=0xc000118dc0 pc=0x4a43bd
os.openFileNolog({0xc000018270, 0x25}, 0x0, 0x0)
/usr/local/go/src/os/file_unix.go:278 +0x17d fp=0xc000118e58 sp=0xc000118e00 pc=0x4a45dd
os.OpenFile({0xc000018270, 0x25}, 0x0, 0x0)
/usr/local/go/src/os/file.go:412 +0x3e fp=0xc000118e88 sp=0xc000118e58 pc=0x4a3e7e
os.Open(...)
/usr/local/go/src/os/file.go:390
main.main()
/home/ainsoph/devel/github.com/elastic/00.0.wip/go-bug/main.go:28 +0x178 fp=0xc000118f50 sp=0xc000118e88 pc=0x4dd578
runtime.main()
/usr/local/go/src/runtime/proc.go:285 +0x29d fp=0xc000118fe0 sp=0xc000118f50 pc=0x43ff5d
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1693 +0x1 fp=0xc000118fe8 sp=0xc000118fe0 pc=0x476601
goroutine 2 gp=0xc0000028c0 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:460 +0xce fp=0xc00006cfa8 sp=0xc00006cf88 pc=0x46fdee
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:466
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:373 +0xb3 fp=0xc00006cfe0 sp=0xc00006cfa8 pc=0x440293
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1693 +0x1 fp=0xc00006cfe8 sp=0xc00006cfe0 pc=0x476601
created by runtime.init.7 in goroutine 1
/usr/local/go/src/runtime/proc.go:361 +0x1a
goroutine 3 gp=0xc000002e00 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:460 +0xce fp=0xc00006d780 sp=0xc00006d760 pc=0x46fdee
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:466
runtime.bgsweep(0xc000026080)
/usr/local/go/src/runtime/mgcsweep.go:279 +0x94 fp=0xc00006d7c8 sp=0xc00006d780 pc=0x42b774
runtime.gcenable.gowrap1()
/usr/local/go/src/runtime/mgc.go:212 +0x25 fp=0xc00006d7e0 sp=0xc00006d7c8 pc=0x41f9c5
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1693 +0x1 fp=0xc00006d7e8 sp=0xc00006d7e0 pc=0x476601
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:212 +0x66
goroutine 4 gp=0xc000002fc0 m=nil [GC scavenge wait]:
runtime.gopark(0xc000026080?, 0x53dfc8?, 0x1?, 0x0?, 0xc000002fc0?)
/usr/local/go/src/runtime/proc.go:460 +0xce fp=0xc00006df78 sp=0xc00006df58 pc=0x46fdee
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:466
runtime.(*scavengerState).park(0x6038a0)
/usr/local/go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc00006dfa8 sp=0xc00006df78 pc=0x429249
runtime.bgscavenge(0xc000026080)
/usr/local/go/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc00006dfc8 sp=0xc00006dfa8 pc=0x4297dc
runtime.gcenable.gowrap2()
/usr/local/go/src/runtime/mgc.go:213 +0x25 fp=0xc00006dfe0 sp=0xc00006dfc8 pc=0x41f965
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1693 +0x1 fp=0xc00006dfe8 sp=0xc00006dfe0 pc=0x476601
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:213 +0xa5
goroutine 5 gp=0xc000003500 m=nil [GOMAXPROCS updater (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:460 +0xce fp=0xc00006e788 sp=0xc00006e768 pc=0x46fdee
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:466
runtime.updateMaxProcsGoroutine()
/usr/local/go/src/runtime/proc.go:6706 +0xe7 fp=0xc00006e7e0 sp=0xc00006e788 pc=0x44e087
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1693 +0x1 fp=0xc00006e7e8 sp=0xc00006e7e0 pc=0x476601
created by runtime.defaultGOMAXPROCSUpdateEnable in goroutine 1
/usr/local/go/src/runtime/proc.go:6694 +0x37
goroutine 6 gp=0xc0000036c0 m=nil [finalizer wait]:
runtime.gopark(0x44f055?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:460 +0xce fp=0xc00006c620 sp=0xc00006c600 pc=0x46fdee
runtime.runFinalizers()
/usr/local/go/src/runtime/mfinal.go:210 +0x107 fp=0xc00006c7e0 sp=0xc00006c620 pc=0x41e967
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1693 +0x1 fp=0xc00006c7e8 sp=0xc00006c7e0 pc=0x476601
created by runtime.createfing in goroutine 1
/usr/local/go/src/runtime/mfinal.go:172 +0x3d
exit status 2
What did you expect to see?
A panic like:
runtime: eventfd failed with 1
fatal error: runtime: eventfd failed
The printed value should be 1
, not 18446744073709551615
.
It seems to come from the fact errno
, a uintptr
is printed as -errno
:
https://go.googlesource.com/go/+/refs/heads/master/src/runtime/netpoll_epoll.go#30
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.