-
Notifications
You must be signed in to change notification settings - Fork 317
Conversation
@pcmoore Can we discuss it in it's own thread? Interesting, it handles the seccomp BPF filter generation completely in Golang. I'm obviously a little biased so I won't comment on which approach is better, but I will mention that just a quick glance at the code in PR #529 revealed a few issues/concerns: It doesn't appear that x32 is handled correctly, resulting in a gap in protection on some systems
I suspect if I look closer there are more issues as well, not to mention the long term maintenence issues (who will keep the syscall tables updated?). |
Code review is a bit earlier, surely there would be lots of improvement for the code, I think we can have a design review first, have a comparison between these two approaches before we merge any of them. I think maintaining syscall tables is acceptable, it's quite stable now, and we already maintain other kernel related info, like rlimit, capability etc, so that won't be the problem. ping @crosbymichael |
I'll leave the code review to you guys as you are much more knowledgeable than I am about Golang, but I will advise you to carefully examine the generated BPF code from both approaches as well as consider how you would support a single Docker filter configuration across multiple platforms (e.g. the x86 socketcall() problem). |
@pcmoore The syscall tables are wrong for ARM, e.g. OABI_SYSCALL_BASE (?)
The code doesn't abstract away architecture specifics, e.g. socketcall()
The generated BPF filter code looks like it might be twice as large as necessary resulting in unnecessary per-syscall performance overhead
The generated BPF filter code has a trap/signal return action, yet I don't see a signal handler defined (?) ... possible this may be misunderstanding how Golang handles signals
@hqhq +1 I think maintaining syscall tables is acceptable |
A few follow-ups:
|
thanks for your follow-ups! |
@keloyang do you have the code that generates these tables? |
Can you disable certain flags passed to syscalls with this implementation. Like preventing the |
@crosbymichael I have change ScmpAdd(ctx *ScmpCtx, call sting ... to ScmpAdd(ctx *ScmpCtx, call int ... , we can use lxc seccomp config file now( refer to TestSeccompNotStat), and seccomp enable flags is added for easy control. though the local test of libcontainner is past, but docker can't use it except adding this to default config(refer to newTemplateConfig): |
@keloyang what about arguments to the specific syscalls? |
@crosbymichael, the code don't surport for arguments, and I'm doing this. |
@keloyang Looks like rebase is needed :/ |
@keloyang i guess one of the goals with seccomp support is to be able to prevent the CLONE_NEWUSER flag being passed to |
Blocking clone(CLONE_NEWUSER) is possible with libseccomp and the SCMP_CMP_MASKED_EQ comparison operator. |
@crosbymichael @LK4D4 |
Thanks for your work! It's amazing. |
maybe "chmod 755 hack/seccomp.sh" work! |
@@ -0,0 +1,56 @@ | |||
#!/usr/bin/perl |
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 you want I can help you rewrite this on go and use go generate
for generating. So, developers won't be dependent on golang.
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.
Also, of course you should commit generated code and not rely on generation tool. It is pretty hard to track bugs this way.
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.
ok
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.
Cool, I'll prepare PR to your PR.
@keloyang There is no seccomp_main in your PR. |
@@ -169,6 +169,13 @@ func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, parentPipe, c | |||
cmd.SysProcAttr.Credential = &syscall.Credential{} | |||
} | |||
} | |||
if cloneFlags&uintptr(configs.CLONE_SECCOMP) != 0 { |
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.
it should be done by client. Silently ignore security issue isn't good idea.
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.
- Can you disable certain flags passed to syscalls with this implementation. Like preventing the CLONE_NEW* flags to clone()?
kernel don' surport for CLONE_SECCOMP, it is a pseudo flag which give a way to enable the seccomp feature. I misunderstand ?
Hmm, it's weird to have |
@@ -4,17 +4,22 @@ package configs | |||
|
|||
import "syscall" | |||
|
|||
var ( | |||
CLONE_SECCOMP = 0x10000 //diffrent from other flag, hard code |
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.
It's actually CLONE_NEWUSER
. Why we need this at all?
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.
CLONE_NEWUSER = 0x10000000
CLONE_NEWSECCOMP is a pseudo flag, which is diffrent other CLONE_xx flag, and it can not pass to clone.
add seccomp feature which is not use third-party add multi arch surport add test case all code use golang this pr is relate to #511 because I close it and find it can not be reopen Signed-off-by: Yang Shukui <[email protected]>
1. add args surport for seccomp 2. add CLONE_SECCOMP flag for preventing seccomp feature Signed-off-by: Yang Shukui <[email protected]>
Signed-off-by: Yang Shukui <[email protected]>
add the generated go file Signed-off-by: Yang Shukui <[email protected]>
add maskequal surport Signed-off-by: Yang Shukui <[email protected]>
#613 was merged with your changes thanks again for all your help |
add seccomp feature which is not use third-party
add multi arch surport
add test case
all code use golang
this pr is relate to #511 because I close it and find it can not be reopen
Signed-off-by: Yang Shukui [email protected]