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

root coredumps warn "Cannot resolve systemd-coredump user" #120803

Closed
pennae opened this issue Apr 27, 2021 · 5 comments · Fixed by #131948
Closed

root coredumps warn "Cannot resolve systemd-coredump user" #120803

pennae opened this issue Apr 27, 2021 · 5 comments · Fixed by #131948
Labels

Comments

@pennae
Copy link
Contributor

pennae commented Apr 27, 2021

Describe the bug
when a root-owned process dumps core (eg recent sshd, due to a known bug) and coredumps are enabled, systemd-coredump warns Cannot resolve systemd-coredump user. Proceeding to dump core as root: No such process (but proceeds successfully).

To Reproduce
Steps to reproduce the behavior:

  1. have systemd coredumps enabled
  2. send a SIGABRT to any root-owned process (eg by running timeout -s ABRT 1s cat)

Expected behavior
coredumps succeeds with proper privsep

Screenshots

Additional context

Notify maintainers
@andir @edolstra @flokli @kloenk

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.10.29, NixOS, 21.05pre282878.652749c4ca7 (Okapi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.10
  • channels(root): "nixos-21.05pre282878.652749c4ca7"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@pennae pennae added the 0.kind: bug Something is broken label Apr 27, 2021
@flokli
Copy link
Contributor

flokli commented Apr 27, 2021

Can you reproduce this with a simple c binary you interactively run as root user?

@pennae
Copy link
Contributor Author

pennae commented Apr 27, 2021

yes, timeout -s ABRT 1s cat as root does it. amended the original post

addendum: if you want a minimal C example that causes it:

#include <signal.h>
#include <unistd.h>

int main() {
	kill(getpid(), SIGABRT);
}

@pennae
Copy link
Contributor Author

pennae commented Jun 3, 2021

still happening regularly due to a bug in openssh (race conditions in process shutdown can cause seccomp filters to trigger)

@solson
Copy link
Member

solson commented Jul 14, 2021

I am also observing this problem, both sshd dumping core and the systemd-coredump error when it happens. I can also reproduce it with timeout -s ABRT 1s cat as root.

@flokli
Copy link
Contributor

flokli commented Jul 29, 2021

I can confirm I see the log messages:

Jul 29 14:49:38 tp sudo[695842]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Jul 29 14:49:38 tp systemd[1]: Started Process Core Dump (PID 695844/UID 0).
Jul 29 14:49:38 tp systemd-coredump[695845]: Cannot resolve systemd-coredump user. Proceeding to dump core as root: No such process
Jul 29 14:49:38 tp systemd-coredump[695845]: [🡕] Process 695843 (foo) of user 0 dumped core.
Jul 29 14:49:38 tp sudo[695842]: pam_unix(sudo:session): session closed for user root

I looked at src/coredump/coredump.c. It seems systemd-coredump wants to drop privileges to a systemd-coredump user (but falls back to root if it can't find it).

sysusers.d/systemd.conf.in suggests we should create it (like we create one for systemd-networkd).

I opened #131948, which does that.

flokli added a commit to flokli/nixpkgs that referenced this issue Jul 29, 2021
systemd-coredump tries to drop privileges to a systemd-coredump user if
present (and falls back to the root user if it's not available).

Create that user, and recycle uid 151 for it. We don't really care about
the gid.

Fixes NixOS#120803.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants