Skip to content
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

Go 1.19 binaries that use @resources SystemCallFilter crashing on startup due to SECCOMP failure #197443

Closed
tomfitzhenry opened this issue Oct 23, 2022 · 15 comments
Labels

Comments

@tomfitzhenry
Copy link
Contributor

tomfitzhenry commented Oct 23, 2022

Describe the bug

On 95aeaf8 (nixos-unstable), services.dnscrypt-proxy2 is crashing (core dumping) on startup, due to SECCOMP error.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix-build -A driverInteractive nixos/tests/dnscrypt-proxy2.nix && ./result/bin/nixos-test-driver
  2. start_all()
  3. test_script()

The tests succeeds https://hydra.nixos.org/build/196222051 but dnscrypt-proxy2 actually fails to start.

Excerpt from VM log:

client # [    7.179763] systemd[1]: Started Process Core Dump (PID 979/UID 0).
client # [    7.334395] systemd-coredump[980]: Process 974 (dnscrypt-proxy) of user 62396 dumped core.
client # 
client # Module linux-vdso.so.1 with build-id 8aef1613db87d17abfb3f09dccb11abfed4e95da
client # Module ld-linux-x86-64.so.2 with build-id 2d2d543cedf2d81d841c434bb7546559079cb6c2
client # Module libc.so.6 with build-id 28c673fe00b56ef505b898287c2654db0def666b
client # Module libpthread.so.0 with build-id cb028b537f0fdd26c58d2ef187ac92d0286066d3
client # Module dnscrypt-proxy without build-id.
client # Stack trace of thread 974:
client # #0  0x000000000040432e runtime/internal/syscall.Syscall6 (dnscrypt-proxy + 0x432e)
client # #1  0x00000000004b14fb syscall.RawSyscall (dnscrypt-proxy + 0xb14fb)
client # #2  0x00000000004b03cf syscall.Setrlimit (dnscrypt-proxy + 0xb03cf)
client # #3  0x00000000004da08e os.init.1 (dnscrypt-proxy + 0xda08e)
client # #4  0x00000000004472a6 runtime.doInit (dnscrypt-proxy + 0x472a6)
client # #5  0x00000000004471f1 runtime.doInit (dnscrypt-proxy + 0x471f1)
client # #6  0x00000000004471f1 runtime.doInit (dnscrypt-proxy + 0x471f1)
client # #7  0x0000000000439fd3 runtime.main (dnscrypt-proxy + 0x39fd3)
client # #8  0x00000000004683e1 runtime.goexit.abi0 (dnscrypt-proxy + 0x683e1)
client # ELF object binary architecture: AMD x86-64
client # 
client # [    7.350894] systemd[1]: dnscrypt-proxy2.service: Main process exited, code=dumped, status=31/SYS

From dmesg:

client # [  144.939671] Oct 23 22:19:27 client audit[669]: SECCOMP auid=4294967295 uid=62396 gid=62396 ses=4294967295 subj=unconfined pid=669 comm="dnscrypt-proxy" exe="/nix/store/fxb09q2lsswl9yzns32mjm4zhflmmwxp-dnscrypt-proxy2-2.1.2/bin/dnscrypt-proxy" sig=31 arch=c000003e syscall=160 compat=0 ip=0x40432e code=0x80000000

Expected behavior

dnscrypt-proxy2 should startup, and listen for DNS requests.

Notify maintainers

@joachifm

@tomfitzhenry tomfitzhenry added the 0.kind: bug Something is broken label Oct 23, 2022
@tomfitzhenry
Copy link
Contributor Author

tomfitzhenry commented Oct 23, 2022

#197379 looks like it could a fix for this? (Update: Confirmed this fixes it.)

Also, we should look into:

  • why the test passes, despite dnscrypt-proxy2 failing to start.
  • what triggered this issue? I see no recent changes to dnscrypt-proxy2 pkg or service.

@tomfitzhenry tomfitzhenry changed the title nixos-unstable: services.dnscrypt-proxy2 crashing on startup due to SECCOMP failure services.dnscrypt-proxy2 crashing on startup due to SECCOMP failure Oct 23, 2022
@tomfitzhenry
Copy link
Contributor Author

tomfitzhenry commented Oct 23, 2022

why the test passes, despite dnscrypt-proxy2 failing to start.

I think dnscrypt-proxy.service does reach active state briefly, and so client.wait_for_unit("dnscrypt-proxy2") succeeds, but then the binary crashes when it runs the Setrlimit syscall.

https://github.com/NixOS/nixpkgs/blob/f36801e4052c4b50c4d1df591d28fe9e1992a54f/nixos/tests/dnscrypt-proxy2.nix should have stronger assertions, e.g. that dnscrypt-proxy2 manages to listen on port 43 (localPortProxy). I've raised a PR for this: #197450.

@tomfitzhenry
Copy link
Contributor Author

tomfitzhenry commented Oct 23, 2022

what triggered this issue? I see no recent changes to dnscrypt-proxy2 pkg or service.

Hypothesis: A recent Go runtime update that now calls setrlimit? (Update: Reverting 0c7a6a0. didn't stop the issue occurring)

tomfitzhenry added a commit to tomfitzhenry/nixpkgs that referenced this issue Oct 23, 2022
Motivation: Ensure this test catches startup failures such as
NixOS#197443
@MidAutumnMoon
Copy link
Contributor

It's probably introduced in Go 1.19 because I didn't find significant changes on systemd side. We'd expect this kind of issues popping out in the near future.

@tomfitzhenry
Copy link
Contributor Author

tomfitzhenry commented Oct 24, 2022

It's probably introduced in Go 1.19 because I didn't find significant changes on systemd side. We'd expect this kind of issues popping out in the near future.

Confirmed. Changing dnscrypt2-proxy to use Go 1.18 fixes this (but allowing @resources syscalls is the better fix, as MidAutumnMoon has proposed).

golang/go@8427429 introduces the setrlimit syscall in an init function (matching the stack trace), released in Go 1.19.

This issue should be closed once the following are merged:

@tomfitzhenry tomfitzhenry changed the title services.dnscrypt-proxy2 crashing on startup due to SECCOMP failure Go 1.19 binaries that use @resources SystemCallFilter crashing on startup due to SECCOMP failure Oct 24, 2022
mweinelt added a commit to mweinelt/nixpkgs that referenced this issue Oct 24, 2022
The ACME module has long been an important part of every nixos server
deployment and we should therefore make sure the tests are working as
expected before allowing a channel bump to happen.

Related: NixOS#197443
zowoq pushed a commit that referenced this issue Oct 24, 2022
The ACME module has long been an important part of every nixos server
deployment and we should therefore make sure the tests are working as
expected before allowing a channel bump to happen.

Related: #197443
@xanderio
Copy link
Contributor

This also affects miniflux.

@MidAutumnMoon
Copy link
Contributor

MidAutumnMoon commented Oct 25, 2022

Some Go programs crashed but some didn't.

For example shiori has ~@resources set but still runs pretty fine. (However its tests
failed for unknown reasons.)

@MidAutumnMoon
Copy link
Contributor

MidAutumnMoon commented Oct 25, 2022

cc @minijackson Could you take a look at shiori's tests?

@MidAutumnMoon
Copy link
Contributor

cc @techknowlogick dex-oidc tests failed on my machine. Could you take a look?

@MidAutumnMoon
Copy link
Contributor

cc @ehmry Could you take a look at yggdrasil's tests?

@MidAutumnMoon
Copy link
Contributor

I think I've caught 'em all.

@SuperSandro2000
Copy link
Member

So, anything left?

@MidAutumnMoon
Copy link
Contributor

So, anything left?

Nothing :)

@ivan ivan closed this as completed Oct 27, 2022
@tomfitzhenry
Copy link
Contributor Author

Great work @MidAutumnMoon for searching for all the occurrences of this, and fixing them before users noticed!

@MidAutumnMoon
Copy link
Contributor

And thank @tomfitzhenry for sorting out this issue and reviewing changes.

Ma27 added a commit to Ma27/nixpkgs that referenced this issue Nov 8, 2022
See the discussion below the original PR[1] and NixOS#197443 for more
context.

I guess I missed that upon review because the branch was too old and I
cherry-picked the commit onto my deployment branch which is based on
22.05. Sorry for that!

[1] NixOS#162784 (comment)
rtimush pushed a commit to rtimush/nixpkgs that referenced this issue Sep 21, 2023
See the discussion below the original PR[1] and NixOS#197443 for more
context.

I guess I missed that upon review because the branch was too old and I
cherry-picked the commit onto my deployment branch which is based on
22.05. Sorry for that!

[1] NixOS#162784 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants