Skip to content

Commit

Permalink
fix(bpf/enforcer): streamline pidns,mntns in events and maps
Browse files Browse the repository at this point in the history
Signed-off-by: daemon1024 <[email protected]>
  • Loading branch information
daemon1024 committed Aug 7, 2024
1 parent b68922c commit 2f271ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
21 changes: 7 additions & 14 deletions KubeArmor/BPF/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,13 @@ static __always_inline u32 init_context(event *event_data) {
event_data->host_ppid = get_task_ppid(task);
event_data->host_pid = bpf_get_current_pid_tgid() >> 32;

u32 pid = get_task_ns_tgid(task);
if (event_data->host_pid == pid) { // host
event_data->pid_id = 0;
event_data->mnt_id = 0;

event_data->ppid = get_task_ppid(task);
event_data->pid = bpf_get_current_pid_tgid() >> 32;
} else { // container
event_data->pid_id = get_task_pid_ns_id(task);
event_data->mnt_id = get_task_mnt_ns_id(task);

event_data->ppid = get_task_ns_ppid(task);
event_data->pid = pid;
}
struct outer_key okey;
get_outer_key(&okey, task);
event_data->pid_id = okey.pid_ns;
event_data->mnt_id = okey.mnt_ns;

event_data->ppid = get_task_ppid(task);
event_data->pid = get_task_ns_tgid(task);

event_data->uid = bpf_get_current_uid_gid();

Expand Down
6 changes: 3 additions & 3 deletions KubeArmor/core/kubeUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,9 @@ func (dm *KubeArmorDaemon) WatchK8sPods() {
}

// exception: kubearmor
if _, ok := pod.Labels["kubearmor-app"]; ok {
pod.Annotations["kubearmor-policy"] = "audited"
}
// if _, ok := pod.Labels["kubearmor-app"]; ok {
// pod.Annotations["kubearmor-policy"] = "audited"
// }

// == Visibility == //

Expand Down

0 comments on commit 2f271ba

Please sign in to comment.