Revert "core: set RLIMIT_CORE to unlimited by default"
authorMartin Pitt <martin.pitt@ubuntu.com>
Sat, 27 Feb 2016 11:27:06 +0000 (12:27 +0100)
committerRaspbian forward porter <root@raspbian.org>
Tue, 9 Aug 2022 18:16:48 +0000 (19:16 +0100)
Partially revert commit 15a900327ab as this completely breaks core dumps
without systemd-coredump. It's also contradicting core(8), and it's not
systemd's place to redefine the kernel definitions of core files.

Commit bdfd7b2c now honours the process' RLIMIT_CORE for systemd-coredump. This
isn't what RLIMIT_CORE is supposed to do (it limits the size of the core
*file*, but the kernel deliberately ignores it for piping), so set a static
2^63 core size limit for systemd-coredump to go back to the previous behaviour
(otherwise the change above would break systemd-coredump).

Bug-Debian: https://bugs.debian.org/815020

Gbp-Pq: Topic debian
Gbp-Pq: Name Revert-core-set-RLIMIT_CORE-to-unlimited-by-default.patch

src/core/main.c
sysctl.d/50-coredump.conf.in

index 0cf2df6fab64c19e9de9139061b41a7251d17783..85283d84c82c863399f108cea9a3b0d46ee73647 100644 (file)
@@ -1619,24 +1619,6 @@ static void cmdline_take_random_seed(void) {
                    "This functionality should not be used outside of testing environments.");
 }
 
-static void initialize_coredump(bool skip_setup) {
-#if ENABLE_COREDUMP
-        if (getpid_cached() != 1)
-                return;
-
-        /* Don't limit the core dump size, so that coredump handlers such as systemd-coredump (which honour
-         * the limit) will process core dumps for system services by default. */
-        if (setrlimit(RLIMIT_CORE, &RLIMIT_MAKE_CONST(RLIM_INFINITY)) < 0)
-                log_warning_errno(errno, "Failed to set RLIMIT_CORE: %m");
-
-        /* But at the same time, turn off the core_pattern logic by default, so that no coredumps are stored
-         * until the systemd-coredump tool is enabled via sysctl. However it can be changed via the kernel
-         * command line later so core dumps can still be generated during early startup and in initramfs. */
-        if (!skip_setup)
-                disable_coredumps();
-#endif
-}
-
 static void initialize_core_pattern(bool skip_setup) {
         int r;
 
@@ -2763,8 +2745,6 @@ int main(int argc, char *argv[]) {
                         kernel_timestamp = DUAL_TIMESTAMP_NULL;
                 }
 
-                initialize_coredump(skip_setup);
-
                 r = fixup_environment();
                 if (r < 0) {
                         log_emergency_errno(r, "Failed to fix up PID 1 environment: %m");
index 5fb551a8cf9fd6260ea4dcee24eba63cb52ca430..13495f1267feb334daa60f6dfd597a8acf50652c 100644 (file)
@@ -13,7 +13,7 @@
 # the core dump.
 #
 # See systemd-coredump(8) and core(5).
-kernel.core_pattern=|{{ROOTLIBEXECDIR}}/systemd-coredump %P %u %g %s %t %c %h
+kernel.core_pattern=|{{ROOTLIBEXECDIR}}/systemd-coredump %P %u %g %s %t 9223372036854775808 %h
 
 # Allow 16 coredumps to be dispatched in parallel by the kernel.
 # We collect metadata from /proc/%P/, and thus need to make sure the crashed