Skip to content

Commit b392f76

Browse files
avagingvisor-bot
authored andcommitted
systrap: don't panic if the main stub process can't be created
There are a number of reasons when this can happen. Let's just return a normal error. PiperOrigin-RevId: 767675817
1 parent cf33046 commit b392f76

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/sentry/platform/systrap/systrap.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ func New(opts platform.Options) (*Systrap, error) {
268268
return nil, err
269269
}
270270

271+
var stubErr error
271272
stubInitialized.Do(func() {
272273
// Don't use sentry and stub fast paths if here is just one cpu.
273274
neverEnableFastPath = min(runtime.NumCPU(), runtime.GOMAXPROCS(0)) == 1
@@ -279,8 +280,8 @@ func New(opts platform.Options) (*Systrap, error) {
279280
// done before initializing any other processes.
280281
source, err := newSubprocess(createStub, mf, false)
281282
if err != nil {
282-
// Should never happen.
283-
panic("unable to initialize systrap source: " + err.Error())
283+
stubErr = fmt.Errorf("initialize systrap: %w", err)
284+
return
284285
}
285286
// The source subprocess is never released explicitly by a MM.
286287
source.DecRef(nil)
@@ -291,6 +292,10 @@ func New(opts platform.Options) (*Systrap, error) {
291292

292293
initSeccompNotify()
293294
})
295+
if stubErr != nil {
296+
mf.Destroy()
297+
return nil, stubErr
298+
}
294299

295300
latencyMonitoring.Do(func() {
296301
go controlFastPath()

0 commit comments

Comments
 (0)