Skip to content

Commit 14c22da

Browse files
EtiennePerotgvisor-bot
authored andcommitted
Serialize writes to slice of precompiled seccomp programs.
I'm not sure if this is necessary but the lack of synchronization here makes me nervous. PiperOrigin-RevId: 788781248
1 parent 997ce5d commit 14c22da

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

runsc/boot/filter/config/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ go_library(
3838
"//pkg/sentry/platform/platforms",
3939
"//pkg/sentry/socket/hostinet",
4040
"//pkg/sentry/socket/plugin",
41+
"//pkg/sync",
4142
"//pkg/tcpip/link/fdbased",
4243
"@org_golang_x_sync//errgroup:go_default_library",
4344
"@org_golang_x_sys//unix:go_default_library",

runsc/boot/filter/config/config_precompiled.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"gvisor.dev/gvisor/pkg/seccomp/precompiledseccomp"
2424
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy/nvconf"
2525
"gvisor.dev/gvisor/pkg/sentry/platform"
26+
"gvisor.dev/gvisor/pkg/sync"
2627

2728
// Import platforms that we need to precompile filters for.
2829
_ "gvisor.dev/gvisor/pkg/sentry/platform/platforms"
@@ -136,6 +137,7 @@ func PrecompiledPrograms() ([]precompiledseccomp.Program, error) {
136137
return nil, err
137138
}
138139
programs := make([]precompiledseccomp.Program, len(opts))
140+
var programsMu sync.Mutex
139141
var errGroup errgroup.Group
140142
for i, opt := range opts {
141143
i, opt := i, opt
@@ -165,6 +167,8 @@ func PrecompiledPrograms() ([]precompiledseccomp.Program, error) {
165167
if err != nil {
166168
return fmt.Errorf("cannot precompile seccomp program for options %v: %w", opt.ConfigKey(), err)
167169
}
170+
programsMu.Lock()
171+
defer programsMu.Unlock()
168172
programs[i] = program
169173
return nil
170174
})

0 commit comments

Comments
 (0)