Add GOARCH as config key to seccomp filter options.

This ensures that we cannot accidentally load rules that were compiled for
one CPU architecture onto another architecture. With this change, if this
happens, we'll ignore the precompiled rules and generate them at container
startup instead.

(Prior to this change, this could have happened for example if the `runsc`
binary had been cross-compiled, with the rules generation binary compiled
for a different architecture than the `runsc` target architecture.)

PiperOrigin-RevId: 585835885
This commit is contained in:
Etienne Perot
2023-11-27 20:31:12 -08:00
committed by gVisor bot
parent 7cf14b7c8b
commit 32be99569d
+2
View File
@@ -19,6 +19,7 @@ package config
import (
"fmt"
"os"
"runtime"
"strings"
"golang.org/x/sys/unix"
@@ -55,6 +56,7 @@ func isInstrumentationEnabled() bool {
// at runtime (e.g. `ControllerFD`).
func (opt Options) ConfigKey() string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("GOARCH=%q ", runtime.GOARCH))
sb.WriteString(fmt.Sprintf("Platform=%q ", opt.Platform.ConfigKey()))
sb.WriteString(fmt.Sprintf("HostNetwork=%t ", opt.HostNetwork))
sb.WriteString(fmt.Sprintf("HostNetworkRawSockets=%t ", opt.HostNetworkRawSockets))