Commit Graph

67 Commits

Author SHA1 Message Date
Jakub Filak 7ed03ce69e coredump: save process container parent cmdline
Process container parent is the process used to start processes with a new
user namespace - e.g systemd-nspawn, runc, lxc, etc.

There is not standard way how to find such a process - or I do not know
about it - hence I have decided to find the first process in the parent
process hierarchy with a different mount namespace and different
/proc/self/root's inode.

I have decided for this criteria because in ABRT we take special care
only if the crashed process runs different code than installed on the
host. Other processes with namespaces different than PID 1's namespaces
are just processes running code shipped by the OS vendor and bug
reporting tools can get information about the provider of the code
without the need to deal with changed root and so on.
2016-08-02 16:01:18 +02:00
Jakub Filak d7032b1fcd coredump: save /proc/[pid]/mountinfo
The file contains information one can use to debug processes running
within a container.
2016-08-02 10:00:46 +02:00
Lennart Poettering c8091d92d5 coredump: turn off coredump collection only when PID 1 crashes, not when journald crashes (#3799)
As suggested:

5157879b75 (r71906971)
2016-07-25 20:03:43 +03:00
Zbigniew Jędrzejewski-Szmek d710aaf7a5 Use "return log_error_errno" in more places" 2016-07-22 21:25:09 -04:00
Lennart Poettering 5157879b75 coredump: turn off coredump collection entirely after journald or PID 1 crashed
Safe is safe, let's turn off the whole logic if we can, after all it is
unlikely we'll be able to process further crashes in a reasonable way.
2016-07-22 18:01:50 +02:00
Lennart Poettering 78f043f77b coredump: make sure to handle crashes of PID 1 and journald special
Fixes: #3285
2016-07-22 18:01:38 +02:00
Lennart Poettering fec603eb6c coredump: truncate overly long coredump metadata fields (#3780)
Fixes: #3573
Replaces: #3588
2016-07-22 17:39:47 +02:00
Torstein Husebø 61233823aa treewide: fix typos and remove accidental repetition of words 2016-07-11 16:18:43 +02:00
Evgeny Vereshchagin fe1ef0f86e coredump: use next_datagram_size_fd instead of ioctl(FIONREAD) (#3237)
We need to be sure that the size returned here actually matches what we will read with recvmsg() next

Fixes #2984
2016-05-11 14:29:24 +02:00
Lennart Poettering fc2fffe770 tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhere
The macro determines the right length of a AF_UNIX "struct sockaddr_un" to pass to
connect() or bind(). It automatically figures out if the socket refers to an
abstract namespace socket, or a socket in the file system, and properly handles
the full length of the path field.

This macro is not only safer, but also simpler to use, than the usual
offsetof() + strlen() logic.
2016-05-05 22:24:36 +02:00
Lennart Poettering 03532f0ae0 coredump,basic: generalize O_TMPFILE handling a bit
This moves the O_TMPFILE handling from the coredumping code into common library
code, and generalizes it as open_tmpfile_linkable() + link_tmpfile(). The
existing open_tmpfile() function (which creates an unlinked temporary file that
cannot be linked into the fs) is renamed to open_tmpfile_unlinkable(), to make
the distinction clear. Thus, code may now choose between:

 a) open_tmpfile_linkable() + link_tmpfile()
 b) open_tmpfile_unlinkable()

Depending on whether they want a file that may be linked back into the fs later
on or not.

In a later commit we should probably convert fopen_temporary() to make use of
open_tmpfile_linkable().

Followup for: #3065
2016-04-22 16:16:53 +02:00
Evgeny Vereshchagin 0c7739039b coredump: create unnamed temporary files if possible (O_TMPFILE) (#3065)
Don't leave temporary files if the coredump service is aborted during
the operation

Yeah, these are temporary files that systemd-coredump needs while
processing the coredumps. Of course, if the coredump service is aborted
during the operation we better shouldn't leave those files around. This
is hence a bug to fix in our coredumping code.
See https://github.com/systemd/systemd/issues/2804#issuecomment-210578147

Another option is to simply use O_TMPFILE, and when it is not available
fall back to the current behaviour. After all, the files are cleaned up
eventually, through normal tmpfiles aging, and the offending file
systems are pretty exotic these days, or not in the upstream kernel.

See https://github.com/systemd/systemd/issues/2804#issuecomment-211496707
2016-04-19 16:59:47 +02:00
Zbigniew Jędrzejewski-Szmek 81d621034b tree-wide: remove useless NULLs from strjoina
The coccinelle patch didn't work in some places, I have no idea why.
2016-04-13 08:56:44 -04:00
Lennart Poettering 888e378da2 coredump: dump priviliges when processing system coredumps
Let's add an extra-safety net and change UID/GID to the "systemd-coredump" user when processing coredumps from system
user. For coredumps of normal users we keep the current logic of processing the coredumps from the user id the coredump
was created under.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=87354
2016-02-10 16:09:24 +01:00
Lennart Poettering bdfd7b2c63 coredump: honour RLIMIT_CORE when saving/processing coredumps
With this change processing/saving of coredumps takes the RLIMIT_CORE resource limit of the crashing process into
account, given the user control whether specific processes shall core dump or not, and how large to make the core dump.

Note that this effectively disables core-dumping for now, as RLIMIT_CORE defaults to 0 (i.e. is disabled) for all
system processes.
2016-02-10 16:08:32 +01:00
Lennart Poettering 3c171f0b1e coredump: rework coredumping logic
This reworks the coredumping logic so that the coredump handler invoked from the kernel only collects runtime data
about the crashed process, and then submits it for processing to a socket-activate coredump service, which extracts a
stacktrace and writes the coredump to disk.

This has a number of benefits: the disk IO and stack trace generation may take a substantial amount of resources, and
hence should better be managed by PID 1, so that resource management applies. This patch uses RuntimeMaxSec=, Nice=, OOMScoreAdjust=
and various sandboxing settings to ensure that the coredump handler doesn't take away unbounded resources from normally
priorized processes.

This logic is also nice since this makes sure the coredump processing and storage is delayed correctly until
/var/systemd/coredump is mounted and writable.

Fixes: #2286
2016-02-10 16:08:32 +01:00
Lennart Poettering f50cd2b2f5 build-sys: move coredump logic into subdir of its own 2016-02-10 14:32:27 +01:00
Renamed from src/journal/coredump.c (Browse further)