Unsandboxed GoStdlib actions include packages excluded from GoSDK.srcs
An ordinary gVisor //:release build on Linux ARM64 used cached standard library archives containing crypto/internal/sysrand/internal/seccomp. The Go analyzer rejected that package because it was absent from the declared SDK sources. Four of the six cached GoStdlib outputs contained the same eight extra packages. Forcing fresh sandboxed stdlib actions let the release and its guest smoke test pass. The cache records do not identify how the original producers ran. 1
On Linux AMD64, three fresh builds declared the same 5,931 SDK source paths. They used rules_go v0.63.0, Bazel 8.8.1 and Go 1.27.3, with race and cgo enabled. 2
Archive packages Listed packages
Sandboxed 370 370
Unsandboxed 378 384
Unsandboxed, declared sources only 370 370
Both builders recursively copy the physical SDK's src directory into a temporary GOROOT. That makes files excluded by the SDK rule, including net/internal/socktest, visible to go install and go list outside a filesystem sandbox. The archive tree and JSON list cover different sets of packages. Comparing each against its own sandboxed inventory gave an exact match after the change. 3
Would you accept passing GoSDK.srcs to both builders and copying those files into the same relative paths under GOROOT? The proposal applies the tested production change to current master at f9689452c. Its package-list test leaves net/internal/socktest physically present in the SDK while omitting it from the source arguments. With rules_go as the root module, the original directory copy reported that package and the proposed builder omitted it. Both export modes passed on the proposal. 4 5 6
Posted by Codex on behalf of @tamird.
Need to take a look at the PR, but this sounds reasonable. Please send.
Will send the PR, but it's linked above (it's citation 4): https://github.com/tamird/rules_go/commit/10f9a0f0d
Hi @tamird @fmeum, wanted to mention that this also seems related to #4310. In an unsandboxed environment with older kernel sources, GoStdlib can still pick up crypto/internal/sysrand/internal/seccomp from the physical SDK source tree despite it being excluded from GoSDK.srcs.
Yes, I reproduced #4310 with Go 1.26.7 and the Linux 3.16 x86-64 syscall-number header. With local execution, both the stdlib build and the package lister picked up the excluded package and failed on SYS_getrandom and SYS_seccomp. The sandboxed build passed.
With #4774, both execution modes passed. Each produced the same 350 archive names and the same 350 package-list entries as the sandboxed parent. The SDK still contains the package on disk. Passing the declared sources to the builders makes them honor the exclusion added in #4311.
Posted by Codex on behalf of @tamird.