-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling BPFLSM based KSP protection on Kubearmor itself #1831
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: daemon1024 <barun1024@gmail.com>
Signed-off-by: daemon1024 <barun1024@gmail.com>
Signed-off-by: daemon1024 <barun1024@gmail.com>
Signed-off-by: daemon1024 <barun1024@gmail.com>
Signed-off-by: daemon1024 <barun1024@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use filepath.Join()
to build paths.
@@ -193,13 +193,13 @@ func (ch *ContainerdHandler) GetContainerInfo(ctx context.Context, containerID s | |||
|
|||
pid := strconv.Itoa(int(taskRes.Processes[0].Pid)) | |||
|
|||
if data, err := os.Readlink("/proc/" + pid + "/ns/pid"); err == nil { | |||
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/pid"); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/pid"); err == nil { | |
if data, err :=os.Readlink(filepath.Join(cfg.GlobalCfg.ProcFsMount, pid, "ns/pid")); err == nil { |
if _, err := fmt.Sscanf(data, "pid:[%d]\n", &container.PidNS); err != nil { | ||
kg.Warnf("Unable to get PidNS (%s, %s, %s)", containerID, pid, err.Error()) | ||
} | ||
} | ||
|
||
if data, err := os.Readlink("/proc/" + pid + "/ns/mnt"); err == nil { | ||
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/mnt"); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/mnt"); err == nil { | |
if data, err := os.Readlink(filepath.Join(cfg.GlobalCfg.ProcFsMount, pid, "ns/pid")); err == nil { |
@@ -130,15 +130,15 @@ func (ch *CrioHandler) GetContainerInfo(ctx context.Context, containerID string, | |||
|
|||
pid := strconv.Itoa(containerInfo.Pid) | |||
|
|||
if data, err := os.Readlink("/proc/" + pid + "/ns/pid"); err == nil { | |||
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/pid"); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/pid"); err == nil { | |
if data, err := os.Readlink(filepath.Join(cfg.GlobalCfg.ProcFsMount, pid, "ns/pid")); err == nil{ |
if _, err := fmt.Sscanf(data, "pid:[%d]\n", &container.PidNS); err != nil { | ||
kg.Warnf("Unable to get PidNS (%s, %s, %s)", containerID, pid, err.Error()) | ||
} | ||
} else { | ||
return container, err | ||
} | ||
|
||
if data, err := os.Readlink("/proc/" + pid + "/ns/mnt"); err == nil { | ||
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/mnt"); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/mnt"); err == nil { | |
if data, err := os.Readlink( filepath.Join(cfg.GlobalCfg.ProcFsMount , pid , "/ns/mnt")); err == nil { |
@@ -144,13 +144,13 @@ func (dh *DockerHandler) GetContainerInfo(containerID string, OwnerInfo map[stri | |||
|
|||
pid := strconv.Itoa(inspect.State.Pid) | |||
|
|||
if data, err := os.Readlink("/proc/" + pid + "/ns/pid"); err == nil { | |||
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/pid"); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if data, err := os.Readlink(cfg.GlobalCfg.ProcFsMount + "/" + pid + "/ns/pid"); err == nil { | |
if data, err := os.Readlink(filepath.Join(cfg.GlobalCfg.ProcFsMount, pid ,"/ns/pid")); err == nil { |
Purpose of PR?:
Succeeds #1717
Fixes #1688
Does this PR introduce a breaking change?
If the changes in this PR are manually verified, list down the scenarios covered::
Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs
Checklist:
<type>(<scope>): <subject>