mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Display list of precompiled seccomp-bpf programs in debug logs.
See [this comment](https://github.com/freedomofpress/dangerzone/pull/590#issuecomment-2149642086) for context. PiperOrigin-RevId: 643463161
This commit is contained in:
committed by
gVisor bot
parent
2069e8643b
commit
11efa60e01
@@ -17,6 +17,8 @@
|
||||
package precompiled
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/seccomp/precompiledseccomp"
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
)
|
||||
@@ -39,6 +41,17 @@ func GetPrecompiled(programName string) (precompiledseccomp.Program, bool) {
|
||||
return program, ok
|
||||
}
|
||||
|
||||
// ListPrecompiled returns a list of all registered program names.
|
||||
func ListPrecompiled() []string {
|
||||
registerPrecompiledProgramsOnce.Do(registerPrograms)
|
||||
programNames := make([]string, 0, len(precompiledPrograms))
|
||||
for name := range precompiledPrograms {
|
||||
programNames = append(programNames, name)
|
||||
}
|
||||
sort.Strings(programNames)
|
||||
return programNames
|
||||
}
|
||||
|
||||
// registerPrograms registers available programs inside `precompiledPrograms`.
|
||||
func registerPrograms() {
|
||||
programs := make(map[string]precompiledseccomp.Program)
|
||||
|
||||
@@ -56,6 +56,13 @@ func Install(opt Options) error {
|
||||
seccompOpts.DefaultAction = linux.SECCOMP_RET_TRAP
|
||||
} else {
|
||||
log.Infof("No precompiled program found for config options %v, building seccomp program from scratch. This may slow down container startup.", key)
|
||||
if log.IsLogging(log.Debug) {
|
||||
precompiledKeys := ListPrecompiled()
|
||||
log.Debugf("Precompiled seccomp-bpf program configuration option variants (%d):", len(precompiledKeys))
|
||||
for k := range precompiledKeys {
|
||||
log.Debugf(" %v", k)
|
||||
}
|
||||
}
|
||||
}
|
||||
rules, denyRules := config.Rules(opt)
|
||||
return seccomp.Install(rules, denyRules, seccompOpts)
|
||||
|
||||
Reference in New Issue
Block a user