Remove dependency in dockerd on libseccomp#41395
Conversation
There was a problem hiding this comment.
Should be removed from vendor?
There was a problem hiding this comment.
Also Dockerfile should no longer need aptgetting libseccomp
There was a problem hiding this comment.
Still need libseccomp to build runc at least.
There was a problem hiding this comment.
I may push some images for runc and containerd since these rarely change and just consume those in our Dockerfile...
|
Build is failing; |
77ed42c to
c5d66fe
Compare
|
Updated to remove |
003d82b to
de6600f
Compare
There was a problem hiding this comment.
wondering; what would happen if we didn't even check, and just passed this down to containerd/runc (having them deal with wether or not to do something with it)?
There was a problem hiding this comment.
There was a problem hiding this comment.
Sorry that's different... when runc is not compiled with seccomp support.
There was a problem hiding this comment.
Most likely what will happen here is the kernel will throw an error.
There was a problem hiding this comment.
That's if runc applies it; I wonder if runc should do the check, and skip that part of the spec if it's not supported 🤔
Basically; if could have multiple OCI runtimes configured, and the docker daemon doesn't know what they support (hope you follow my train of thought)
There was a problem hiding this comment.
I follow, but I think at the runc level you just want it to execute what you told it to.
If you pass a seccomp profile and it doesn't load it but continues anyway, seems like this would cause some security issues at the very least.
de6600f to
841d085
Compare
|
Hold off on merging... realized there's an issue here where some files are still depending on the 'seccomp' build tag. |
841d085 to
1dcd4ee
Compare
|
I pulled back on those buildtag changes just because there's a ton of places where it's used. |
tianon
left a comment
There was a problem hiding this comment.
LGTM (although test failure looks weird)
|
@cpuguy83 tests are still failing, so looks related |
|
Old profile -> New profile... 🤔 - "arch_prctl"
- ],
- "action": "SCMP_ACT_ALLOW"
- },
- {
- "names": [
- "modify_ldt"
- ],
- "action": "SCMP_ACT_ALLOW"
- },
- {
- "names": [ |
1dcd4ee to
0ff9eae
Compare
|
Should be fixed now. |
There was a problem hiding this comment.
nice catch that this was inside the loop 👍
There was a problem hiding this comment.
couldn't we change this to goarchToSeccomp ?
so change this to "386" ?
There was a problem hiding this comment.
ah, nevermind; looks like arch is used further down (didn't show in the diff)
There was a problem hiding this comment.
Guess we could still do it, but we would need both mapping (but it would change to GOARCH -> native, and GOARCH -> seccomp)
There was a problem hiding this comment.
Yeah this was pretty much why it was failing. Didn't realize we were using the libseccomp arch string.
There was a problem hiding this comment.
Do you think it will be cleaner to have GOARCH -> nativeArch and GOARCh -> seccompArch, so that they can be used independently?
diff --git a/profiles/seccomp/seccomp_linux.go b/profiles/seccomp/seccomp_linux.go
index 7847085a0a..ac6441d6c3 100644
--- a/profiles/seccomp/seccomp_linux.go
+++ b/profiles/seccomp/seccomp_linux.go
@@ -27,16 +27,16 @@ func LoadProfile(body string, rs *specs.Spec) (*specs.LinuxSeccomp, error) {
return setupSeccomp(&config, rs)
}
-// libseccomp string => seccomp arch
-var nativeToSeccomp = map[string]types.Arch{
- "x86": types.ArchX86,
+// GOARCH => seccomp arch
+var goToSeccomp = map[string]types.Arch{
+ "386": types.ArchX86,
"amd64": types.ArchX86_64,
"arm": types.ArchARM,
"arm64": types.ArchAARCH64,
"mips64": types.ArchMIPS64,
- "mips64n32": types.ArchMIPS64N32,
- "mipsel64": types.ArchMIPSEL64,
- "mips3l64n32": types.ArchMIPSEL64N32,
+ "mips64p32": types.ArchMIPS64N32,
+ "mips64le": types.ArchMIPSEL64,
+ "mips64p32le": types.ArchMIPSEL64N32,
"mipsle": types.ArchMIPSEL,
"ppc": types.ArchPPC,
"ppc64": types.ArchPPC64,
@@ -97,8 +97,7 @@ func setupSeccomp(config *types.Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, e
}
}
- arch := goToNative[runtime.GOARCH]
- seccompArch, archExists := nativeToSeccomp[arch]
+ seccompArch, archExists := goToSeccomp[runtime.GOARCH]
if len(config.ArchMap) != 0 && archExists {
for _, a := range config.ArchMap {
@@ -115,6 +114,8 @@ func setupSeccomp(config *types.Seccomp, rs *specs.Spec) (*specs.LinuxSeccomp, e
newConfig.DefaultAction = specs.LinuxSeccompAction(config.DefaultAction)
Loop:
+ arch := goToNative[runtime.GOARCH]
+
// Loop through all syscall blocks and convert them to libcontainer format after filtering them
for _, call := range config.Syscalls {
if len(call.Excludes.Arches) > 0 {There was a problem hiding this comment.
It's different, I don't think it's better or worse.
There was a problem hiding this comment.
Yeah, it's not a blocker, as non of this is exported. Thought it would be slightly easier to understand, as we wouldn't be mapping twice (GOOS -> native -> seccomp).
I can open a follow-up to discuss
This was just using libseccomp to get the right arch, but we can use GOARCH to get this. The nativeToSeccomp map needed to be adjusted a bit for mipsle vs mipsel since that's go how refers to it. Also added some other arches to it. Signed-off-by: Brian Goff <[email protected]>
Signed-off-by: Brian Goff <[email protected]>
As it turns out, we call this function every time someone calls `docker info`, every time a contianer is created, and every time a container is started. Certainly this should be refactored as a whole, but for now, memoize the seccomp value. Signed-off-by: Brian Goff <[email protected]>
0ff9eae to
df7031b
Compare
This was just using libseccomp to get the right arch, but we can use
GOARCH to get this.
The nativeToSeccomp map needed to be adjusted a bit for mipsle vs mipsel
since that's go how refers to it. Also added some other arches to it.
Closes #41299