coredump-context: cache if the crashed process in the same PID namespace

This commit is contained in:
Yu Watanabe
2025-10-28 14:31:41 +09:00
parent 7df4841e94
commit 91840f324e
3 changed files with 17 additions and 5 deletions
+15
View File
@@ -315,6 +315,19 @@ int coredump_context_build_iovw(CoredumpContext *context) {
return 0;
}
static void coredump_context_check_pidns(CoredumpContext *context) {
int r;
assert(context);
assert(pidref_is_set(&context->pidref));
r = pidref_in_same_namespace(/* pid1 = */ NULL, &context->pidref, NAMESPACE_PID);
if (r < 0)
log_debug_errno(r, "Failed to check pidns of crashing process, ignoring: %m");
context->same_pidns = r != 0;
}
static int coredump_context_parse_from_procfs(CoredumpContext *context) {
int r;
@@ -531,6 +544,7 @@ int coredump_context_parse_iovw(CoredumpContext *context) {
"Mandatory argument %s not received on socket.",
metadata_field_to_string(i));
coredump_context_check_pidns(context);
return 0;
}
@@ -556,5 +570,6 @@ int coredump_context_parse_from_argv(CoredumpContext *context, int argc, char **
return r;
}
coredump_context_check_pidns(context);
return coredump_context_parse_from_procfs(context);
}
+1
View File
@@ -59,6 +59,7 @@ struct CoredumpContext {
char *auxv; /* META_PROC_AUXV */
size_t auxv_size; /* META_PROC_AUXV */
bool got_pidfd; /* META_ARGV_PIDFD */
bool same_pidns;
bool forwarded;
int input_fd;
int mount_tree_fd;
+1 -5
View File
@@ -10,7 +10,6 @@
#include "format-util.h"
#include "iovec-wrapper.h"
#include "log.h"
#include "namespace-util.h"
#include "signal-util.h"
int coredump_kernel_helper(int argc, char *argv[]) {
@@ -50,10 +49,7 @@ int coredump_kernel_helper(int argc, char *argv[]) {
context.pidref.pid, context.comm, context.uid, context.signo,
signal_to_string(context.signo));
r = pidref_in_same_namespace(/* pid1 = */ NULL, &context.pidref, NAMESPACE_PID);
if (r < 0)
log_debug_errno(r, "Failed to check pidns of crashing process, ignoring: %m");
if (r == 0) {
if (!context.same_pidns) {
/* If this fails, fallback to the old behavior so that
* there is still some record of the crash. */
r = coredump_send_to_container(&context);