coredump: verify pidfd after parsing data in usermode helper

Ensure the pidfd is still valid before continuing

Follow-up for 313537da6f
This commit is contained in:
Luca Boccassi
2025-04-13 10:18:58 +01:00
parent e2603934d5
commit ba6c955f21
+5
View File
@@ -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);
}