Skip to content

Commit

Permalink
server: make a copy of exit messages when filtering fields
Browse files Browse the repository at this point in the history
We encountered another segfault similar to the one fixed in #1432. This time, it's related
to the pid field in exit events. Fix this by making a copy of the exit event before
filtering.

Signed-off-by: William Findlay <will@isovalent.com>
  • Loading branch information
willfindlay committed Nov 1, 2023
1 parent 962f0d7 commit 6d6b1dc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,12 @@ func (s *Server) GetEventsWG(request *tetragon.GetEventsRequest, server tetragon
// Filter the GetEventsResponse fields
filters := filters.FieldFiltersFromGetEventsRequest(request)
filterEvent := event
if len(filters) > 0 && filterEvent.GetProcessExec() != nil { // this is an exec event and we have fieldFilters
// We need a copy of the exec event as modifing the original message
if len(filters) > 0 && (filterEvent.GetProcessExec() != nil || filterEvent.GetProcessExit() != nil) { // this is an exec or exit event and we have fieldFilters
// We need a copy of the exec or exit event as modifing the original message
// can cause issues in the process cache (we keep a copy of that message there).
filterEvent = proto.Clone(event).(*tetragon.GetEventsResponse)
}
for _, filter := range filters {
// we need not to change res
// maybe only for exec events
filter.Filter(filterEvent)
}

Expand Down

0 comments on commit 6d6b1dc

Please sign in to comment.