Skip to content

Commit

Permalink
Add ctty to fork (#195)
Browse files Browse the repository at this point in the history
Add ctty to fork

Since we don't track actual TTY changes, at least make sure a new process gets
the correct TTY, previously we were tracking it only on exec which is fine for
probably most cases.
  • Loading branch information
haesbaert committed Jun 4, 2024
1 parent 61bdb7f commit 817e105
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions GPL/Events/EbpfEventProto.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ struct ebpf_process_fork_event {
struct ebpf_pid_info parent_pids;
struct ebpf_pid_info child_pids;
struct ebpf_cred_info creds;
struct ebpf_tty_dev ctty;
char comm[TASK_COMM_LEN];

// Variable length fields: pids_ss_cgroup_path
Expand Down
2 changes: 2 additions & 0 deletions GPL/Events/Process/Probe.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "Helpers.h"
#include "PathResolver.h"
#include "State.h"
#include "Varlen.h"

/* tty_write */
Expand Down Expand Up @@ -56,6 +57,7 @@ int BPF_PROG(sched_process_fork, const struct task_struct *parent, const struct
ebpf_pid_info__fill(&event->parent_pids, parent);
ebpf_pid_info__fill(&event->child_pids, child);
ebpf_cred_info__fill(&event->creds, parent);
ebpf_ctty__fill(&event->ctty, child);
ebpf_comm__fill(event->comm, sizeof(event->comm), child);

// Variable length fields
Expand Down
3 changes: 3 additions & 0 deletions non-GPL/Events/EventsTrace/EventsTrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ static void out_process_fork(struct ebpf_process_fork_event *evt)
out_cred_info("creds", &evt->creds);
out_comma();

out_tty_dev("ctty", &evt->ctty);
out_comma();

out_string("comm", evt->comm);

struct ebpf_varlen_field *field;
Expand Down
1 change: 1 addition & 0 deletions testing/testrunner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type ProcessForkEvent struct {
ParentPids PidInfo `json:"parent_pids"`
ChildPids PidInfo `json:"child_pids"`
Creds CredInfo `json:"creds"`
Ctty TtyInfo `json:"ctty"`
}

type ProcessExecEvent struct {
Expand Down

0 comments on commit 817e105

Please sign in to comment.