From ba6c955f21ac3f46a6914c3607b910e371a25dee Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 11 Apr 2025 14:44:30 +0100 Subject: [PATCH] coredump: verify pidfd after parsing data in usermode helper Ensure the pidfd is still valid before continuing Follow-up for 313537da6ffdea4049873571202679734d49f0a1 --- src/coredump/coredump.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index a207086d816..defc809c974 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -1463,6 +1463,11 @@ static int gather_pid_metadata_from_procfs(struct iovec_wrapper *iovw, Context * if (get_process_environ(pid, &t) >= 0) (void) iovw_put_string_field_free(iovw, "COREDUMP_ENVIRON=", t); + /* Now that we have parsed info from /proc/ ensure the pidfd is still valid before continuing */ + r = pidref_verify(&context->pidref); + if (r < 0) + return log_error_errno(r, "PIDFD validation failed: %m"); + /* we successfully acquired all metadata */ return context_parse_iovw(context, iovw); } -- 2.47.3