Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracee: fix panic when ctrl-c after the boot #3188

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/ebpf/events_enrich.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (t *Tracee) enrichContainerEvents(ctx gocontext.Context, in <-chan *trace.E
for { // enqueue events
select {
case event := <-in:
if event == nil {
continue // might happen during initialization (ctrl+c seg faults)
}

eventID := events.ID(event.EventID)
// send out irrelevant events (non container or already enriched), don't skip the cgroup lifecycle events
if (event.Container.ID == "" || event.Container.Name != "") && eventID != events.CgroupMkdir && eventID != events.CgroupRmdir {
Expand Down Expand Up @@ -130,6 +134,11 @@ func (t *Tracee) enrichContainerEvents(ctx gocontext.Context, in <-chan *trace.E
// de-queue event if queue is enriched
if _, ok := queues[cgroupId]; ok {
event := <-queues[cgroupId]

if event == nil {
continue // might happen during initialization (ctrl+c seg faults)
}

eventID := events.ID(event.EventID)
// check if not enriched, and only enrich regular non cgroup related events
if event.Container.Name == "" && eventID != events.CgroupMkdir && eventID != events.CgroupRmdir {
Expand Down
8 changes: 8 additions & 0 deletions pkg/ebpf/events_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ func (t *Tracee) processEvents(ctx context.Context, in <-chan *trace.Event) (
defer close(errc)

for event := range in { // For each received event...
if event == nil {
continue // might happen during initialization (ctrl+c seg faults)
}

// Go through event processors if needed
errs := t.processEvent(event)
if len(errs) > 0 {
Expand Down Expand Up @@ -541,6 +545,10 @@ func (t *Tracee) sinkEvents(ctx context.Context, in <-chan *trace.Event) <-chan
defer close(errc)

for event := range in {
if event == nil {
continue // might happen during initialization (ctrl+c seg faults)
}

// Only emit events requested by the user and matched by at least one policy.
id := events.ID(event.EventID)
event.MatchedPoliciesUser &= t.events[id].emit
Expand Down
4 changes: 4 additions & 0 deletions pkg/ebpf/signature_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (t *Tracee) engineEvents(ctx context.Context, in <-chan *trace.Event) (<-ch
for {
select {
case finding := <-engineOutput:
if finding.Event.Payload == nil {
continue // might happen during initialization (ctrl+c seg faults)
}

event, err := FindingToEvent(finding)
if err != nil {
t.handleError(err)
Expand Down