storage
storage copied to clipboard
Reexec causes infinite loop, if built without CGO_ENABLED
Recently I opened this issue https://github.com/containers/buildah/issues/4370 in the buildah repo and found the culprit. While building, I didn't specify CGO_ENABLED=1
. This causes an infinite loop of forks, because this is never called: https://github.com/containers/storage/blob/89878da4a1548918d0f0a1f0ba535e68d7dd11f7/pkg/unshare/unshare_cgo.go#L6-L11 Is it possible to check for this while compiling and failing the build?
Steps to reproduce: main.go:
package main
import (
"github.com/containers/storage/pkg/unshare"
"github.com/containers/storage/pkg/reexec"
)
func main() {
reexec.Init()
unshare.MaybeReexecUsingUserNamespace(false)
}
Compile this with CGO_ENABLED=0 go build -o main main.go
=> Executing the binary leads to an infinite loop (and is akin to a fork bomb)