Skip to content

Conversation

@Julio-Guerra
Copy link
Contributor

- What I did

Allow syscall membarrier in the default seccomp profile in order to fix memory coherency issues leading to segfault errors on Alpine containers. It was firstly noticed with AWS EC2 instances running the docker image node:10-alpine and failing almost all the time.
We could also reproduce it locally when slowing down the node process with ltrace.

The musl libc uses indeed the syscall in its implementation of dlopen(), leading to memory incoherence when used concurrently, which is the case with node's libuv.

- How I did it

Add membarrier to the list of allowed syscalls.

- How to verify it

Write a test using membarrier.

- Description for the changelog

seccomp: allow syscall membarrier

@richfelker
Copy link

richfelker commented Mar 23, 2020

This issue does not lead to memory incoherence. musl supports kernels far older than the membarrier syscall, and implements a costly fallback if the syscall fails. However it's perferable to allow the syscall so that the fallback isn't needed.

@Julio-Guerra
Copy link
Contributor Author

This issue does not lead to memory incoherence. musl supports kernels far older than the membarrier syscall, and implements a costly fallback if the syscall fails. However it's perferable to allow the syscall so that the fallback isn't needed.

FYI, we ran a lot of tests on AWS codebuild because they fail almost all the time and rarely succeed. But as soon as we add membarrier to seccomp profile json file, we no longer have the issue at all.

@AkihiroSuda
Copy link
Member

[2020-03-23T15:24:50.958Z] The result of go generate ./profiles/seccomp/ differs

[2020-03-23T15:24:50.958Z] 

[2020-03-23T15:24:50.958Z]  M profiles/seccomp/default.json

[2020-03-23T15:24:50.958Z] 

[2020-03-23T15:24:50.958Z] Please re-run go generate ./profiles/seccomp/

@richfelker
Copy link

What are the tests that fail doing/trying to assert? I think you'll find it's something unrelated to the use of membarrier in dlopen, but I'd be interested in hearing if not. The use in dlopen is really a virtual nop - the ordering properties it's ensuring are automatically satisfied on any architecture with "consume" type semantics, which is pretty much every architecture ever made except DEC Alpha. If something is going wrong related to dlopen, the mechanism of breakage is likely something different - maybe a problem stemming from other syscalls being blocked?

@AkihiroSuda AkihiroSuda added area/security/seccomp kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/1-design-review labels Mar 24, 2020
@thaJeztah
Copy link
Member

had a quick chat with @justincormack, and he thought the change to the seccomp profile should be ok

@thaJeztah
Copy link
Member

Changes look good; could you squash the two commits into one? Let me know if you need help with that

Add the membarrier syscall to the default seccomp profile.
It is for example used in the implementation of dlopen() in
the musl libc of Alpine images.

Signed-off-by: Julio Guerra <[email protected]>
@Julio-Guerra Julio-Guerra force-pushed the fix/seccomp-profile branch from 5f5a966 to 1026f87 Compare April 7, 2020 14:24
@Julio-Guerra Julio-Guerra requested a review from thaJeztah April 7, 2020 14:25
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (assuming CI passes), thanks!

@thaJeztah
Copy link
Member

@AkihiroSuda PTAL

@AkihiroSuda AkihiroSuda merged commit b2917ef into moby:master May 19, 2020
@richfelker
Copy link

That should close this issue, but I believe there may be another problem behind this, in the form of undersized stack that caused the crash when signal-based fallback was used. That should be checked out too, since an undersized stack could come back as crashes elsewhere later.

@Julio-Guerra Julio-Guerra deleted the fix/seccomp-profile branch May 29, 2020 10:13
@Julio-Guerra Julio-Guerra restored the fix/seccomp-profile branch May 29, 2020 10:13
@Julio-Guerra Julio-Guerra deleted the fix/seccomp-profile branch May 29, 2020 10:13
@Julio-Guerra Julio-Guerra restored the fix/seccomp-profile branch May 29, 2020 10:13
@thaJeztah thaJeztah added this to the 20.03.0 milestone Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/security/seccomp impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. process/cherry-picked status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants