Skip to content

Commit

Permalink
Ignore kernel threads during clone events
Browse files Browse the repository at this point in the history
In Tetragon we do not report process_exec and process_exit events for
kernel threads. When searching for the parent of a kernel thread, we
failed to do so and we simply ignore that.

This patch optimizes that path as we abort early by checking the
task_struct's flags.

Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>
  • Loading branch information
tpapagian committed Nov 4, 2023
1 parent b29fc81 commit cc6f6c5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bpf/process/bpf_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ BPF_KPROBE(event_wake_up_new_task, struct task_struct *task)
{
struct execve_map_value *curr, *parent;
struct msg_clone_event msg;
u32 flags, tgid = 0;
u64 msg_size;
u32 tgid = 0;

if (!task)
return 0;

/* We do not care about kernel threads. */
flags = BPF_CORE_READ(task, flags);
if (flags & PF_KTHREAD)
return 0;

tgid = BPF_CORE_READ(task, tgid);

/* Do not try to create any msg or calling execve_map_get
Expand Down

0 comments on commit cc6f6c5

Please sign in to comment.