Skip to content

Commit

Permalink
[grpc/exec] Do not refinc on a nil parent
Browse files Browse the repository at this point in the history
When handling kthreads and we cannot find the parent, we print a
warning, but we also call refinc on a nil parent which results in a
panic in some cases.

This patch fixes that by avoiding the call of refinc in the case where
we cannot find a kthread's parent.

FIXES: #2614

Signed-off-by: Anastasios Papagiannis <[email protected]>
  • Loading branch information
tpapagian committed Jul 1, 2024
1 parent 0235ed5 commit 6dcc3aa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/grpc/exec/kthread_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (msg *MsgKThreadInitUnix) HandleMessage() *tetragon.GetEventsResponse {
parent, err := process.Get(proc.UnsafeGetProcess().ParentExecId)
if err != nil {
logger.GetLogger().Warnf("Failed to find parent for kernel thread %d", msg.Unix.Msg.Parent.Pid)
return nil
}
parent.RefInc()
return nil
Expand Down

0 comments on commit 6dcc3aa

Please sign in to comment.