-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: double close pidfd if caller uses pidfd updated by os.StartProcess #68984
Comments
cc @kolyshkin |
I’d say this is a bug. If you manually set PidFD in SysProcAttr, then os.Process shouldn’t close it. That should be your responsibility. |
cc @golang/runtime |
Change https://go.dev/cl/607695 mentions this issue: |
@gopherbot Please backport to 1.23. This is a regression in os.StartProcess for programs already using pidfds. |
Backport issue(s) opened: #69119 (for 1.23). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/611415 mentions this issue: |
For #68984. Fixes #69119. Change-Id: I16d25777cb38a337cd4204a8147eaf866c3df9e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/607695 Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 239666c) Reviewed-on: https://go-review.googlesource.com/c/go/+/611415 Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Go version
go1.23.0
Output of
go env
in your module/workspace:What did you do?
I try to use os.StartProcess with ptrace to remove all the usage of linkname in containerd project containerd/containerd#10611.
For the os.StartProcess option. I set PidFD, use
os.NewFile
for it and close it.go/src/syscall/exec_linux.go
Lines 108 to 111 in 6885bad
But I run into
accept4: bad file descriptor
issue randomly, because theProcess
has finalizer to close the pidfd during GC.go/src/os/exec_posix.go
Lines 64 to 72 in 6885bad
go/src/os/exec.go
Lines 114 to 122 in 6885bad
There is POC code for reproducing it.
I think the document should mention that the
PidFD
should not be used or the GO runtime should dup it before using it.What did you see happen?
When you run the poc code by go1.23.0, you will see the error like.
What did you expect to see?
Should not use user's pidfd value directly.
The text was updated successfully, but these errors were encountered: