Skip to content

seccomp: add support for "swapcontext" syscall in default policy#43092

Merged
thaJeztah merged 1 commit intomoby:masterfrom
nmeum:swapcontext-syscall
Jan 6, 2022
Merged

seccomp: add support for "swapcontext" syscall in default policy#43092
thaJeztah merged 1 commit intomoby:masterfrom
nmeum:swapcontext-syscall

Conversation

@nmeum
Copy link
Contributor

@nmeum nmeum commented Dec 18, 2021

- What I did
- How I did it
The swapcontext system call is only available on the 32- and 64-bit PowerPC architecture, it is
used by modern programming language implementations (such as gcc-go) to
implement coroutine features through userspace context switches.

Other container environment, such as Systemd nspawn already whitelist
this system call in their seccomp profile [1] [2]. As such, it would be
nice to also whitelist it in moby.

Issues with the current default seccomp profile were encountered on Alpine Linux's GitLab CI system, which uses
docker, when attempting to execute software compiled with gcc-go and libucontext on ppc64le.

- How to verify it

Try running a program using setcontext(3) on ppc64 in a docker container environment, see systemd nspawn for example code.

- Description for the changelog

Whitelist the PPC swapcontext system call in the default seccomp profile.

This system call is only available on the 32- and 64-bit PowerPC, it is
used by modern programming language implementations (such as gcc-go) to
implement coroutine features through userspace context switches.

Other container environment, such as Systemd nspawn already whitelist
this system call in their seccomp profile [1] [2]. As such, it would be
nice to also whitelist it in moby.

This issue was encountered on Alpine Linux GitLab CI system, which uses
moby, when attempting to execute gcc-go compiled software on ppc64le.

[1]: systemd/systemd#9487
[2]: systemd/systemd#9485

Signed-off-by: Sören Tempel <[email protected]>
@thaJeztah thaJeztah added the status/failing-ci Indicates that the PR in its current state fails the test suite label Dec 19, 2021
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, thanks for updating 👍

but let me ping @justincormack @AkihiroSuda for a review as well

"names": [
"sync_file_range2"
"sync_file_range2",
"swapcontext"
Copy link
Member

Choose a reason for hiding this comment

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

Just an observation (and for other reviewers); this adds the syscall conditionally for ppc64le only; the default profile currently doesn't have ppc (32-bit ppc), so it won't be available on those architectures.

I don't think we need to take 32-bit ppc into account, as we don't test/support that architecture, and it's a pretty niche use (I think there's some people doing their own custom builds of dockerd for 32-bit ppc, but not sure)

@thaJeztah thaJeztah added this to the 21.xx milestone Jan 3, 2022
@thaJeztah
Copy link
Member

@nmeum I should mention that the containerd project is also maintaining a seccomp profile that likely should be updated with the same changes as well; https://github.com/containerd/containerd/blob/main/contrib/seccomp/seccomp_default.go#L466-L473

@thaJeztah thaJeztah added status/4-merge and removed area/security/seccomp status/failing-ci Indicates that the PR in its current state fails the test suite labels Jan 6, 2022
@thaJeztah
Copy link
Member

test failures are unrelated; let me bring this one in

@thaJeztah thaJeztah merged commit b0806bd into moby:master Jan 6, 2022
@nmeum
Copy link
Contributor Author

nmeum commented Jan 6, 2022

test failures are unrelated; let me bring this one in

Great, thanks!

@nmeum I should mention that the containerd project is also maintaining a seccomp profile that likely should be updated with the same changes as well; https://github.com/containerd/containerd/blob/main/contrib/seccomp/seccomp_default.go#L466-L473

Should I send a PR for containerd too?

@thaJeztah
Copy link
Member

Should I send a PR for containerd too?

If you're interested in contributing there, yes, feel free to! We try to keep the projects a bit in sync, so that users get the same experience if they use either containerd or dockerd (I'm happy to open a PR myself as well if you don't have time for that) ❤️

@nmeum
Copy link
Contributor Author

nmeum commented Jan 7, 2022

I created containerd/containerd#6411 to get this syscall whitelisted in containerd as well 🤗

wllenyj pushed a commit to wllenyj/containerd that referenced this pull request Feb 8, 2022
This system call is only available on 32- and 64-bit PowerPC, it is used
by modern programming language implementations to implement coroutine
features through userspace context switches.

moby [1] and systemd nspawn [2] already whitelist this system call so it
makes sense to whitelist it in containerd as well.

[1]: moby/moby#43092
[2]: systemd/systemd#9487

Signed-off-by: Sören Tempel <[email protected]>
katiewasnothere pushed a commit to katiewasnothere/containerd that referenced this pull request Apr 21, 2022
This system call is only available on 32- and 64-bit PowerPC, it is used
by modern programming language implementations to implement coroutine
features through userspace context switches.

moby [1] and systemd nspawn [2] already whitelist this system call so it
makes sense to whitelist it in containerd as well.

[1]: moby/moby#43092
[2]: systemd/systemd#9487

Signed-off-by: Sören Tempel <[email protected]>
martinetd added a commit to martinetd/containers-common that referenced this pull request Jun 5, 2024
swapcontext seems to be used for coroutines in some languages (at least
ruby), enough to have been added to other major engines by an actual user.

Link: moby/moby#43092
Link: systemd/systemd#9487
Link: containerd/containerd#6411
martinetd added a commit to martinetd/containers-common that referenced this pull request Jun 5, 2024
swapcontext seems to be used for coroutines in some languages (at least
ruby), enough to have been added to other major engines by an actual user.

Link: moby/moby#43092
Link: systemd/systemd#9487
Link: containerd/containerd#6411
Signed-off-by: Dominique Martinet <[email protected]>
kiashok pushed a commit to kiashok/containerd that referenced this pull request Oct 23, 2024
This system call is only available on 32- and 64-bit PowerPC, it is used
by modern programming language implementations to implement coroutine
features through userspace context switches.

moby [1] and systemd nspawn [2] already whitelist this system call so it
makes sense to whitelist it in containerd as well.

[1]: moby/moby#43092
[2]: systemd/systemd#9487

Signed-off-by: Sören Tempel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants